Revision 38cd6772
b/devflow/flow.py | ||
---|---|---|
8 | 8 |
from devflow import utils, versioning |
9 | 9 |
from devflow.version import __version__ |
10 | 10 |
from devflow.autopkg import call |
11 |
from functools import wraps |
|
11 |
from devflow.ui import query_action |
|
12 |
from functools import wraps, partial |
|
12 | 13 |
from contextlib import contextmanager |
13 | 14 |
from git.exc import GitCommandError |
14 | 15 |
|
... | ... | |
158 | 159 |
if not feature_upstream in repo.branches: |
159 | 160 |
raise ValueError("Branch %s does not exist." % feature_upstream) |
160 | 161 |
feature_debian = "debian-%s" % feature_upstream |
161 |
self.edit_changelog(feature_upstream) |
|
162 |
action = partial(self.edit_changelog, feature_upstream) |
|
163 |
query_action("Edit changelog", action = action) |
|
164 |
# self.edit_changelog(feature_upstream) |
|
162 | 165 |
repo.git.checkout("develop") |
163 | 166 |
with conflicts(): |
164 | 167 |
repo.git.merge(feature_upstream) |
b/devflow/ui.py | ||
---|---|---|
1 |
#!/usr/bin/env python |
|
2 |
|
|
3 |
import sys |
|
4 |
|
|
5 |
#http://stackoverflow.com/questions/3041986/python-command-line-yes-no-input |
|
6 |
def query_yes_no(question, default="yes"): |
|
7 |
"""Ask a yes/no question via raw_input() and return their answer. |
|
8 |
|
|
9 |
"question" is a string that is presented to the user. |
|
10 |
"default" is the presumed answer if the user just hits <Enter>. |
|
11 |
It must be "yes" (the default), "no" or None (meaning |
|
12 |
an answer is required of the user). |
|
13 |
|
|
14 |
The "answer" return value is one of "yes" or "no". |
|
15 |
""" |
|
16 |
valid = {"yes":True, "y":True, "ye":True, |
|
17 |
"no":False, "n":False} |
|
18 |
if default == None: |
|
19 |
prompt = " [y/n] " |
|
20 |
elif default == "yes": |
|
21 |
prompt = " [Y/n] " |
|
22 |
elif default == "no": |
|
23 |
prompt = " [y/N] " |
|
24 |
else: |
|
25 |
raise ValueError("invalid default answer: '%s'" % default) |
|
26 |
|
|
27 |
while True: |
|
28 |
sys.stdout.write(question + prompt) |
|
29 |
choice = raw_input().lower() |
|
30 |
if default is not None and choice == '': |
|
31 |
return valid[default] |
|
32 |
elif choice in valid: |
|
33 |
return valid[choice] |
|
34 |
else: |
|
35 |
sys.stdout.write("Please respond with 'yes' or 'no' "\ |
|
36 |
"(or 'y' or 'n').\n") |
|
37 |
|
|
38 |
def query_action(question, default="yes", action=None): |
|
39 |
answer = query_yes_no(question, default) |
|
40 |
if answer and action is not None: |
|
41 |
action() |
Also available in: Unified diff