Mercurial > hg
changeset 19226:c58b6ab4c26f
ui: merge prompt text components into a singe string
This will help avoid problems with partial or mismatched translation
of the components.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 22 May 2013 17:31:43 -0500 |
parents | 6cf8e3b4e074 |
children | 8eef5b93db9d |
files | hgext/largefiles/overrides.py hgext/patchbomb.py hgext/record.py mercurial/filemerge.py mercurial/merge.py mercurial/subrepo.py mercurial/ui.py |
diffstat | 7 files changed, 56 insertions(+), 48 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/largefiles/overrides.py Tue May 21 15:32:15 2013 -0500 +++ b/hgext/largefiles/overrides.py Wed May 22 17:31:43 2013 -0500 @@ -376,8 +376,6 @@ 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 @@ 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 @@ 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 @@ 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())
--- a/hgext/patchbomb.py Tue May 21 15:32:15 2013 -0500 +++ b/hgext/patchbomb.py Wed May 22 17:31:43 2013 -0500 @@ -482,8 +482,8 @@ 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')
--- a/hgext/record.py Tue May 21 15:32:15 2013 -0500 +++ b/hgext/record.py Wed May 22 17:31:43 2013 -0500 @@ -283,17 +283,17 @@ 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__)
--- a/mercurial/filemerge.py Tue May 21 15:32:15 2013 -0500 +++ b/mercurial/filemerge.py Wed May 22 17:31:43 2013 -0500 @@ -144,8 +144,8 @@ 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 @@ 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"):
--- a/mercurial/merge.py Tue May 21 15:32:15 2013 -0500 +++ b/mercurial/merge.py Wed May 22 17:31:43 2013 -0500 @@ -365,8 +365,8 @@ 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 @@ 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
--- a/mercurial/subrepo.py Tue May 21 15:32:15 2013 -0500 +++ b/mercurial/subrepo.py Wed May 22 17:31:43 2013 -0500 @@ -191,9 +191,8 @@ 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 @@ 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 @@ 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 _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"""
--- a/mercurial/ui.py Tue May 21 15:32:15 2013 -0500 +++ b/mercurial/ui.py Wed May 22 17:31:43 2013 -0500 @@ -639,13 +639,20 @@ 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])