D959: patch: invalidate messages after encoding change
yuja requested changes to this revision. yuja added a comment. This revision now requires changes to proceed. So the messages may be rolled back, which seems to be against the original intent, "take messages out of the function so that extensions can add entries." Since extensions have to wrap the _getmessages() function, the messages table isn't necessary, so we don't need the callback mechanism, too. Alternatively, the messages table could keep the raw (untranslated) messages, to which gettext() will be applied later. messages = { ... 'discard': "discard change %d/%d to '%s'?", } i18nblahblah = messages # tell hggettext to extract strings i18n.gettext(messages[k][op]) REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D959 To: quark, #hg-reviewers, yuja Cc: yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D959: patch: invalidate messages after encoding change
quark updated this revision to Diff 2491. quark edited the summary of this revision. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D959?vs=2474=2491 REVISION DETAIL https://phab.mercurial-scm.org/D959 AFFECTED FILES mercurial/patch.py CHANGE DETAILS diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -994,50 +994,59 @@ def __repr__(self): return '' % (self.filename(), self.fromline) -messages = { -'multiple': { -'discard': _("discard change %d/%d to '%s'?"), -'record': _("record change %d/%d to '%s'?"), -'revert': _("revert change %d/%d to '%s'?"), -}, -'single': { -'discard': _("discard this change to '%s'?"), -'record': _("record this change to '%s'?"), -'revert': _("revert this change to '%s'?"), -}, -'help': { -'discard': _('[Ynesfdaq?]' - '$$ , discard this change' - '$$ , skip this change' - '$$ this change manually' - '$$ remaining changes to this file' - '$$ Discard remaining changes to this ' - '$$ , skip remaining changes and files' - '$$ Discard changes to all remaining files' - '$$ , discarding no changes' - '$$ &? (display help)'), -'record': _('[Ynesfdaq?]' -'$$ , record this change' -'$$ , skip this change' -'$$ this change manually' -'$$ remaining changes to this file' -'$$ Record remaining changes to this ' -'$$ , skip remaining changes and files' -'$$ Record changes to all remaining files' -'$$ , recording no changes' -'$$ &? (display help)'), -'revert': _('[Ynesfdaq?]' -'$$ , revert this change' -'$$ , skip this change' -'$$ this change manually' -'$$ remaining changes to this file' -'$$ Revert remaining changes to this ' -'$$ , skip remaining changes and files' -'$$ Revert changes to all remaining files' -'$$ , reverting no changes' -'$$ &? (display help)') +def _getmessages(): +return { +'multiple': { +'discard': _("discard change %d/%d to '%s'?"), +'record': _("record change %d/%d to '%s'?"), +'revert': _("revert change %d/%d to '%s'?"), +}, +'single': { +'discard': _("discard this change to '%s'?"), +'record': _("record this change to '%s'?"), +'revert': _("revert this change to '%s'?"), +}, +'help': { +'discard': _('[Ynesfdaq?]' + '$$ , discard this change' + '$$ , skip this change' + '$$ this change manually' + '$$ remaining changes to this file' + '$$ Discard remaining changes to this ' + '$$ , skip remaining changes and files' + '$$ Discard changes to all remaining files' + '$$ , discarding no changes' + '$$ &? (display help)'), +'record': _('[Ynesfdaq?]' +'$$ , record this change' +'$$ , skip this change' +'$$ this change manually' +'$$ remaining changes to this file' +'$$ Record remaining changes to this ' +'$$ , skip remaining changes and files' +'$$ Record changes to all remaining files' +'$$ , recording no changes' +'$$ &? (display help)'), +'revert': _('[Ynesfdaq?]' +'$$ , revert this change' +'$$ , skip this change' +'$$ this change manually' +'$$ remaining changes to this file' +'$$ Revert remaining changes to this ' +'$$ , skip remaining changes and files' +'$$ Revert changes to all remaining files' +'$$ , reverting no changes' +'$$ &? (display help)') +} } -} + +messages = _getmessages() + +def _resetmessages(): +global messages +messages = _getmessages() + +encoding.setencodingcallbacks.append(_resetmessages) def filterpatch(ui, headers, operation=None): """Interactively filter patch chunks into applied-only chunks""" To: quark, #hg-reviewers Cc: mercurial-devel
D959: patch: invalidate messages after encoding change
quark created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY Previously the code caches i18n._ results in module variables. That should be invalidated with encoding change. This makes test-commit-interactive.t work as expected. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D959 AFFECTED FILES mercurial/patch.py tests/test-commit-interactive.t CHANGE DETAILS diff --git a/tests/test-commit-interactive.t b/tests/test-commit-interactive.t --- a/tests/test-commit-interactive.t +++ b/tests/test-commit-interactive.t @@ -913,7 +913,7 @@ > ? > q > EOF - y - ???(yes) + y - \x82\xb1\x82\xcc\x95\xcf\x8dX\x82\xf0\x8bL\x98^(yes) $ LANGUAGE= #endif diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -994,50 +994,59 @@ def __repr__(self): return '' % (self.filename(), self.fromline) -messages = { -'multiple': { -'discard': _("discard change %d/%d to '%s'?"), -'record': _("record change %d/%d to '%s'?"), -'revert': _("revert change %d/%d to '%s'?"), -}, -'single': { -'discard': _("discard this change to '%s'?"), -'record': _("record this change to '%s'?"), -'revert': _("revert this change to '%s'?"), -}, -'help': { -'discard': _('[Ynesfdaq?]' - '$$ , discard this change' - '$$ , skip this change' - '$$ this change manually' - '$$ remaining changes to this file' - '$$ Discard remaining changes to this ' - '$$ , skip remaining changes and files' - '$$ Discard changes to all remaining files' - '$$ , discarding no changes' - '$$ &? (display help)'), -'record': _('[Ynesfdaq?]' -'$$ , record this change' -'$$ , skip this change' -'$$ this change manually' -'$$ remaining changes to this file' -'$$ Record remaining changes to this ' -'$$ , skip remaining changes and files' -'$$ Record changes to all remaining files' -'$$ , recording no changes' -'$$ &? (display help)'), -'revert': _('[Ynesfdaq?]' -'$$ , revert this change' -'$$ , skip this change' -'$$ this change manually' -'$$ remaining changes to this file' -'$$ Revert remaining changes to this ' -'$$ , skip remaining changes and files' -'$$ Revert changes to all remaining files' -'$$ , reverting no changes' -'$$ &? (display help)') +def _getmessages(): +return { +'multiple': { +'discard': _("discard change %d/%d to '%s'?"), +'record': _("record change %d/%d to '%s'?"), +'revert': _("revert change %d/%d to '%s'?"), +}, +'single': { +'discard': _("discard this change to '%s'?"), +'record': _("record this change to '%s'?"), +'revert': _("revert this change to '%s'?"), +}, +'help': { +'discard': _('[Ynesfdaq?]' + '$$ , discard this change' + '$$ , skip this change' + '$$ this change manually' + '$$ remaining changes to this file' + '$$ Discard remaining changes to this ' + '$$ , skip remaining changes and files' + '$$ Discard changes to all remaining files' + '$$ , discarding no changes' + '$$ &? (display help)'), +'record': _('[Ynesfdaq?]' +'$$ , record this change' +'$$ , skip this change' +'$$ this change manually' +'$$ remaining changes to this file' +'$$ Record remaining changes to this ' +'$$ , skip remaining changes and files' +'$$ Record changes to all remaining files' +'$$ , recording no changes' +'$$ &? (display help)'), +'revert': _('[Ynesfdaq?]' +'$$ , revert this change' +'$$ , skip this change' +'$$ this change manually' +'$$ remaining changes to this file' +'$$ Revert remaining changes to this ' +'$$ , skip remaining changes and files' +'$$ Revert changes to all remaining files' +