diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py --- a/hgext/largefiles/overrides.py +++ b/hgext/largefiles/overrides.py @@ -376,8 +376,6 @@ def overridemanifestmerge(origfn, repo, continue f, m, args, msg = action - choices = (_('&Largefile'), _('&Normal file')) - splitstandin = lfutil.splitstandin(f) if (m == "g" and splitstandin is not None and splitstandin in p1 and f in p2): @@ -386,8 +384,9 @@ def overridemanifestmerge(origfn, repo, lfile = splitstandin standin = f msg = _('%s has been turned into a largefile\n' - 'use (l)argefile or keep as (n)ormal file?') % lfile - if repo.ui.promptchoice(msg, choices, 0) == 0: + 'use (l)argefile or keep as (n)ormal file?' + '$$ &Largefile $$ &Normal file') % lfile + if repo.ui.promptchoice(msg, 0) == 0: processed.append((lfile, "r", None, msg)) processed.append((standin, "g", (p2.flags(standin),), msg)) else: @@ -398,8 +397,9 @@ def overridemanifestmerge(origfn, repo, standin = lfutil.standin(f) lfile = f msg = _('%s has been turned into a normal file\n' - 'keep as (l)argefile or use (n)ormal file?') % lfile - if repo.ui.promptchoice(msg, choices, 0) == 0: + 'keep as (l)argefile or use (n)ormal file?' + '$$ &Largefile $$ &Normal file') % lfile + if repo.ui.promptchoice(msg, 0) == 0: processed.append((lfile, "r", None, msg)) else: processed.append((standin, "r", None, msg)) @@ -444,9 +444,9 @@ def overridefilemerge(origfn, repo, myno return 0 if repo.ui.promptchoice(_('largefile %s has a merge conflict\n' - 'keep (l)ocal or take (o)ther?') % - lfutil.splitstandin(orig), - (_('&Local'), _('&Other')), 0) == 0: + 'keep (l)ocal or take (o)ther?' + '$$ &Local $$ &Other') % + lfutil.splitstandin(orig), 0) == 0: return 0 else: repo.wwrite(fcdest.path(), fcother.data(), fcother.flags()) diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py --- a/hgext/patchbomb.py +++ b/hgext/patchbomb.py @@ -482,8 +482,8 @@ def patchbomb(ui, repo, *revs, **opts): if ds: ui.write(ds) ui.write('\n') - if ui.promptchoice(_('are you sure you want to send (yn)?'), - (_('&Yes'), _('&No'))): + if ui.promptchoice(_('are you sure you want to send (yn)?' + '$$ &Yes $$ &No')): raise util.Abort(_('patchbomb canceled')) ui.write('\n') diff --git a/hgext/record.py b/hgext/record.py --- a/hgext/record.py +++ b/hgext/record.py @@ -283,17 +283,17 @@ def filterpatch(ui, headers): if skipfile is not None: return skipfile, skipfile, skipall, newpatches while True: - resps = _('[Ynesfdaq?]') - choices = (_('&Yes, record this change'), - _('&No, skip this change'), - _('&Edit the change manually'), - _('&Skip remaining changes to this file'), - _('Record remaining changes to this &file'), - _('&Done, skip remaining changes and files'), - _('Record &all changes to all remaining files'), - _('&Quit, recording no changes'), - _('&?')) - r = ui.promptchoice("%s %s" % (query, resps), choices) + resps = _('[Ynesfdaq?]' + '$$ &Yes, record this change' + '$$ &No, skip this change' + '$$ &Edit the change manually' + '$$ &Skip remaining changes to this file' + '$$ Record remaining changes to this &file' + '$$ &Done, skip remaining changes and files' + '$$ Record &all changes to all remaining files' + '$$ &Quit, recording no changes' + '$$ &?') + r = ui.promptchoice("%s %s" % (query, resps)) ui.write("\n") if r == 8: # ? doc = gettext(record.__doc__) diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py --- a/mercurial/filemerge.py +++ b/mercurial/filemerge.py @@ -144,8 +144,8 @@ def _iprompt(repo, mynode, orig, fcd, fc fd = fcd.path() if ui.promptchoice(_(" no tool found to merge %s\n" - "keep (l)ocal or take (o)ther?") % fd, - (_("&Local"), _("&Other")), 0): + "keep (l)ocal or take (o)ther?" + "$$ &Local $$ &Other") % fd, 0): return _iother(repo, mynode, orig, fcd, fco, fca, toolconf) else: return _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf) @@ -348,16 +348,16 @@ def filemerge(repo, mynode, orig, fcd, f checked = False if 'prompt' in _toollist(ui, tool, "check"): checked = True - if ui.promptchoice(_("was merge of '%s' successful (yn)?") % fd, - (_("&Yes"), _("&No")), 1): + if ui.promptchoice(_("was merge of '%s' successful (yn)?" + "$$ &Yes $$ &No") % fd, 1): r = 1 if not r and not checked and (_toolbool(ui, tool, "checkchanged") or 'changed' in _toollist(ui, tool, "check")): if filecmp.cmp(a, back): if ui.promptchoice(_(" output file %s appears unchanged\n" - "was merge successful (yn)?") % fd, - (_("&Yes"), _("&No")), 1): + "was merge successful (yn)?" + "$$ &Yes $$ &No") % fd, 1): r = 1 if _toolbool(ui, tool, "fixeol"): diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -365,8 +365,8 @@ def manifestmerge(repo, wctx, p2, pa, br actions.append((f, "r", None, "remote delete")) elif repo.ui.promptchoice( _("local changed %s which remote deleted\n" - "use (c)hanged version or (d)elete?") % f, - (_("&Changed"), _("&Delete")), 0): + "use (c)hanged version or (d)elete?" + "$$ &Changed $$ &Delete") % f, 0): actions.append((f, "r", None, "prompt delete")) else: actions.append((f, "a", None, "prompt keep")) @@ -375,8 +375,8 @@ def manifestmerge(repo, wctx, p2, pa, br actions.append((f, "g", (m2.flags(f),), "remote recreating")) elif repo.ui.promptchoice( _("remote changed %s which local deleted\n" - "use (c)hanged version or leave (d)eleted?") % f, - (_("&Changed"), _("&Deleted")), 0) == 0: + "use (c)hanged version or leave (d)eleted?" + "$$ &Changed $$ &Deleted") % f, 0) == 0: actions.append((f, "g", (m2.flags(f),), "prompt recreating")) else: assert False, m return actions diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -191,9 +191,8 @@ def submerge(repo, wctx, mctx, actx, ove elif ld[0] != r[0]: # sources differ if repo.ui.promptchoice( _(' subrepository sources for %s differ\n' - 'use (l)ocal source (%s) or (r)emote source (%s)?') - % (s, l[0], r[0]), - (_('&Local'), _('&Remote')), 0): + 'use (l)ocal source (%s) or (r)emote source (%s)?' + '$$ &Local $$ &Remote') % (s, l[0], r[0]), 0): debug(s, "prompt changed, get", r) wctx.sub(s).get(r, overwrite) sm[s] = r @@ -215,8 +214,8 @@ def submerge(repo, wctx, mctx, actx, ove else: if repo.ui.promptchoice( _(' local changed subrepository %s which remote removed\n' - 'use (c)hanged version or (d)elete?') % s, - (_('&Changed'), _('&Delete')), 0): + 'use (c)hanged version or (d)elete?' + '$$ &Changed $$ &Delete') % s, 0): debug(s, "prompt remove") wctx.sub(s).remove() @@ -230,8 +229,8 @@ def submerge(repo, wctx, mctx, actx, ove elif r != sa[s]: if repo.ui.promptchoice( _(' remote changed subrepository %s which local removed\n' - 'use (c)hanged version or (d)elete?') % s, - (_('&Changed'), _('&Delete')), 0) == 0: + 'use (c)hanged version or (d)elete?' + '$$ &Changed $$ &Delete') % s, 0) == 0: debug(s, "prompt recreate", r) wctx.sub(s).get(r) sm[s] = r @@ -242,14 +241,16 @@ def submerge(repo, wctx, mctx, actx, ove def _updateprompt(ui, sub, dirty, local, remote): if dirty: msg = (_(' subrepository sources for %s differ\n' - 'use (l)ocal source (%s) or (r)emote source (%s)?\n') + 'use (l)ocal source (%s) or (r)emote source (%s)?\n' + '$$ &Local $$ &Remote') % (subrelpath(sub), local, remote)) else: msg = (_(' subrepository sources for %s differ (in checked out ' 'version)\n' - 'use (l)ocal source (%s) or (r)emote source (%s)?\n') + 'use (l)ocal source (%s) or (r)emote source (%s)?\n' + '$$ &Local $$ &Remote') % (subrelpath(sub), local, remote)) - return ui.promptchoice(msg, (_('&Local'), _('&Remote')), 0) + return ui.promptchoice(msg, 0) def reporelpath(repo): """return path to this (sub)repo as seen from outermost repo""" diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -639,13 +639,20 @@ class ui(object): except EOFError: raise util.Abort(_('response expected')) - def promptchoice(self, msg, choices, default=0): - """Prompt user with msg, read response, and ensure it matches - one of the provided choices. The index of the choice is returned. - choices is a sequence of acceptable responses with the format: - ('&None', 'E&xec', 'Sym&link') Responses are case insensitive. - If ui is not interactive, the default is returned. + def promptchoice(self, prompt, default=0): + """Prompt user with a message, read response, and ensure it matches + one of the provided choices. The prompt is formatted as follows: + + "would you like fries with that (Yn)? $$ &Yes $$ &No" + + The index of the choice is returned. Responses are case + insensitive. If ui is not interactive, the default is + returned. """ + + parts = prompt.split('$$') + msg = parts[0].rstrip(' ') + choices = [p.strip(' ') for p in parts[1:]] resps = [s[s.index('&') + 1].lower() for s in choices] while True: r = self.prompt(msg, resps[default])