Patchwork D567: patch: take messages out of the function so that extensions can add entries

login
register
mail settings
Submitter phabricator
Date Sept. 1, 2017, 1:58 p.m.
Message ID <1ebcd5c31e86222368a0ba5cdaa8cef7@localhost.localdomain>
Download mbox | patch
Permalink /patch/23593/
State Not Applicable
Headers show

Comments

phabricator - Sept. 1, 2017, 1:58 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGc0170d88ed2b: patch: take messages out of the function so that extensions can add entries (authored by pulkit).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D567?vs=1436&id=1537#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D567?vs=1436&id=1537

REVISION DETAIL
  https://phab.mercurial-scm.org/D567

AFFECTED FILES
  mercurial/patch.py

CHANGE DETAILS




To: pulkit, #hg-reviewers, lothiraldan, yuja
Cc: yuja, lothiraldan, mercurial-devel

Patch

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -996,54 +996,55 @@ 
     def __repr__(self):
         return '<hunk %r@%d>' % (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?]'
+                     '$$ &Yes, discard this change'
+                     '$$ &No, skip this change'
+                     '$$ &Edit this change manually'
+                     '$$ &Skip remaining changes to this file'
+                     '$$ Discard remaining changes to this &file'
+                     '$$ &Done, skip remaining changes and files'
+                     '$$ Discard &all changes to all remaining files'
+                     '$$ &Quit, discarding no changes'
+                     '$$ &? (display help)'),
+        'record': _('[Ynesfdaq?]'
+                    '$$ &Yes, record this change'
+                    '$$ &No, skip this change'
+                    '$$ &Edit this 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'
+                    '$$ &? (display help)'),
+        'revert': _('[Ynesfdaq?]'
+                    '$$ &Yes, revert this change'
+                    '$$ &No, skip this change'
+                    '$$ &Edit this change manually'
+                    '$$ &Skip remaining changes to this file'
+                    '$$ Revert remaining changes to this &file'
+                    '$$ &Done, skip remaining changes and files'
+                    '$$ Revert &all changes to all remaining files'
+                    '$$ &Quit, reverting no changes'
+                    '$$ &? (display help)')
+    }
+}
+
 def filterpatch(ui, headers, operation=None):
     """Interactively filter patch chunks into applied-only chunks"""
     if operation is None:
         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],
-        'help': {
-            'discard': _('[Ynesfdaq?]'
-                         '$$ &Yes, discard this change'
-                         '$$ &No, skip this change'
-                         '$$ &Edit this change manually'
-                         '$$ &Skip remaining changes to this file'
-                         '$$ Discard remaining changes to this &file'
-                         '$$ &Done, skip remaining changes and files'
-                         '$$ Discard &all changes to all remaining files'
-                         '$$ &Quit, discarding no changes'
-                         '$$ &? (display help)'),
-            'record': _('[Ynesfdaq?]'
-                        '$$ &Yes, record this change'
-                        '$$ &No, skip this change'
-                        '$$ &Edit this 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'
-                        '$$ &? (display help)'),
-            'revert': _('[Ynesfdaq?]'
-                        '$$ &Yes, revert this change'
-                        '$$ &No, skip this change'
-                        '$$ &Edit this change manually'
-                        '$$ &Skip remaining changes to this file'
-                        '$$ Revert remaining changes to this &file'
-                        '$$ &Done, skip remaining changes and files'
-                        '$$ Revert &all changes to all remaining files'
-                        '$$ &Quit, reverting no changes'
-                        '$$ &? (display help)')
-        }[operation]
-    }
 
     def prompt(skipfile, skipall, query, chunk):
         """prompt query, and process base inputs
@@ -1061,7 +1062,7 @@ 
         if skipfile is not None:
             return skipfile, skipfile, skipall, newpatches
         while True:
-            resps = messages['help']
+            resps = messages['help'][operation]
             r = ui.promptchoice("%s %s" % (query, resps))
             ui.write("\n")
             if r == 8: # ?
@@ -1166,10 +1167,11 @@ 
             if skipfile is None and skipall is None:
                 chunk.pretty(ui)
             if total == 1:
-                msg = messages['single'] % chunk.filename()
+                msg = messages['single'][operation] % chunk.filename()
             else:
                 idx = pos - len(h.hunks) + i
-                msg = messages['multiple'] % (idx, total, chunk.filename())
+                msg = messages['multiple'][operation] % (idx, total,
+                                                         chunk.filename())
             r, skipfile, skipall, newpatches = prompt(skipfile,
                     skipall, msg, chunk)
             if r: