Submitter | Denis Laxalde |
---|---|
Date | June 7, 2016, 8:38 a.m. |
Message ID | <6727a55b29e931b6318c.1465288730@sh77.tls.logilab.fr> |
Download | mbox | patch |
Permalink | /patch/15427/ |
State | Superseded |
Headers | show |
Comments
07.06.2016, 16:39, "Denis Laxalde" <denis.laxalde@logilab.fr>: > # HG changeset patch > # User Denis Laxalde <denis.laxalde@logilab.fr> > # Date 1465288639 -7200 > # Tue Jun 07 10:37:19 2016 +0200 > # Node ID 6727a55b29e931b6318c9227c68a39d7c77ece2d > # Parent 1b3a0b0c414faa3d6d4dbcf4c5abbbe18aa9efd4 > patch: define full messages for interactive record/revert > > Followup 14eee72c8d52 to provide complete context for proper localization. > > diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py > --- a/mercurial/cmdutil.py > +++ b/mercurial/cmdutil.py > @@ -3301,7 +3301,7 @@ def _performrevert(repo, parents, ctx, a > else: > diff = patch.diff(repo, None, ctx.node(), m, opts=diffopts) > originalchunks = patch.parsepatch(diff) > - operation = _('discard') if node == parent else _('revert') > + operation = 'discard' if node == parent else 'revert' Here are the first lines of cmdutil.recordfilter function for context: def recordfilter(ui, originalhunks, operation=None): """ Prompts the user to filter the originalhunks and return a list of selected hunks. *operation* is used for ui purposes to indicate the user what kind of filtering they are doing: reverting, committing, shelving, etc. *operation* has to be a translated string. """ Does this patch change the requirement that operation has to be pre-translated? (The docstring also mentions shelving, but I'm not sure how shelve uses recordfilter)
Anton Shestakov a écrit : > 07.06.2016, 16:39, "Denis Laxalde" <denis.laxalde@logilab.fr>: >> # HG changeset patch >> # User Denis Laxalde <denis.laxalde@logilab.fr> >> # Date 1465288639 -7200 >> # Tue Jun 07 10:37:19 2016 +0200 >> # Node ID 6727a55b29e931b6318c9227c68a39d7c77ece2d >> # Parent 1b3a0b0c414faa3d6d4dbcf4c5abbbe18aa9efd4 >> patch: define full messages for interactive record/revert >> >> Followup 14eee72c8d52 to provide complete context for proper localization. >> >> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py >> --- a/mercurial/cmdutil.py >> +++ b/mercurial/cmdutil.py >> @@ -3301,7 +3301,7 @@ def _performrevert(repo, parents, ctx, a >> else: >> diff = patch.diff(repo, None, ctx.node(), m, opts=diffopts) >> originalchunks = patch.parsepatch(diff) >> - operation = _('discard') if node == parent else _('revert') >> + operation = 'discard' if node == parent else 'revert' > > Here are the first lines of cmdutil.recordfilter function for context: > > def recordfilter(ui, originalhunks, operation=None): > """ Prompts the user to filter the originalhunks and return a list of > selected hunks. > *operation* is used for ui purposes to indicate the user > what kind of filtering they are doing: reverting, committing, shelving, etc. > *operation* has to be a translated string. > """ > > Does this patch change the requirement that operation has to be pre-translated? Concerning record/revert, without curse mode, we go down to patch.filterpatch where the full message is now built using the specified operation (which hence does not have to be a translated string). With curse mode, it goes into crecord.filterpatch where the "operation" parameter does not seem to be used. > (The docstring also mentions shelving, but I'm not sure how shelve uses recordfilter) > In shelve mode, the operation parameter does not seem to be specified and this would falls back to a record operation. Will update that docstring.
Patch
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -3301,7 +3301,7 @@ def _performrevert(repo, parents, ctx, a else: diff = patch.diff(repo, None, ctx.node(), m, opts=diffopts) originalchunks = patch.parsepatch(diff) - operation = _('discard') if node == parent else _('revert') + operation = 'discard' if node == parent else 'revert' try: diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -978,7 +978,19 @@ class recordhunk(object): def filterpatch(ui, headers, operation=None): """Interactively filter patch chunks into applied-only chunks""" if operation is None: - operation = _('record') + operation = 'record' + messages = { + 'multiple': { + 'discard': _("discard change %d/%d to '%s'?"), + 'record': _("record change %d/%d to '%s'?"), + 'revert': _("revert change %d/%d to '%s'?"), + }[operation], + 'single': { + 'discard': _("discard this change to '%s'?"), + 'record': _("record this change to '%s'?"), + 'revert': _("revert this change to '%s'?"), + }[operation], + } def prompt(skipfile, skipall, query, chunk): """prompt query, and process base inputs @@ -1109,12 +1121,10 @@ the hunk is left unchanged. if skipfile is None and skipall is None: chunk.pretty(ui) if total == 1: - msg = _("%s this change to '%s'?") % (operation, - chunk.filename()) + msg = messages['single'] % chunk.filename() else: idx = pos - len(h.hunks) + i - msg = _("%s change %d/%d to '%s'?") % (operation, idx, total, - chunk.filename()) + msg = messages['multiple'] % (idx, total, chunk.filename()) r, skipfile, skipall, newpatches = prompt(skipfile, skipall, msg, chunk) if r: