mirror of https://github.com/golang/go.git
codereview: accommodate recent change to ui.prompt
Fixes #525. R=r CC=golang-dev https://golang.org/cl/190044
This commit is contained in:
parent
a6736fa4ff
commit
ff7343f8d0
|
|
@ -77,6 +77,15 @@ if hgversion < '1.3':
|
||||||
msg += linuxMessage
|
msg += linuxMessage
|
||||||
raise util.Abort(msg)
|
raise util.Abort(msg)
|
||||||
|
|
||||||
|
def promptyesno(ui, msg):
|
||||||
|
# Arguments to ui.prompt changed between 1.3 and 1.3.1.
|
||||||
|
# Even so, some 1.3.1 distributions seem to have the old prompt!?!?
|
||||||
|
# What a terrible way to maintain software.
|
||||||
|
try:
|
||||||
|
return ui.promptchoice(msg, ["&yes", "&no"], 0) == 0
|
||||||
|
except AttributeError:
|
||||||
|
return ui.prompt(msg, ["&yes", "&no"], "y") != "n"
|
||||||
|
|
||||||
# To experiment with Mercurial in the python interpreter:
|
# To experiment with Mercurial in the python interpreter:
|
||||||
# >>> repo = hg.repository(ui.ui(), path = ".")
|
# >>> repo = hg.repository(ui.ui(), path = ".")
|
||||||
|
|
||||||
|
|
@ -590,7 +599,7 @@ def EditCL(ui, repo, cl):
|
||||||
s = ui.edit(s, ui.username())
|
s = ui.edit(s, ui.username())
|
||||||
clx, line, err = ParseCL(s, cl.name)
|
clx, line, err = ParseCL(s, cl.name)
|
||||||
if err != '':
|
if err != '':
|
||||||
if ui.prompt("error parsing change list: line %d: %s\nre-edit (y/n)?" % (line, err), ["&yes", "&no"], "y") == "n":
|
if not promptyesno(ui, "error parsing change list: line %d: %s\nre-edit (y/n)?" % (line, err)):
|
||||||
return "change list not modified"
|
return "change list not modified"
|
||||||
continue
|
continue
|
||||||
cl.desc = clx.desc;
|
cl.desc = clx.desc;
|
||||||
|
|
@ -598,7 +607,7 @@ def EditCL(ui, repo, cl):
|
||||||
cl.cc = clx.cc
|
cl.cc = clx.cc
|
||||||
cl.files = clx.files
|
cl.files = clx.files
|
||||||
if cl.desc == '':
|
if cl.desc == '':
|
||||||
if ui.prompt("change list should have description\nre-edit (y/n)?", ["&yes", "&no"], "y") != "n":
|
if promptyesno(ui, "change list should have description\nre-edit (y/n)?"):
|
||||||
continue
|
continue
|
||||||
break
|
break
|
||||||
return ""
|
return ""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue