[PATCH 5 of 5] crecord: change the verb according to the operation

Jun Wu quark at fb.com
Mon Nov 28 18:52:09 EST 2016


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1480376326 0
#      Mon Nov 28 23:38:46 2016 +0000
# Node ID 762e7ed9f64b079ffa5c80c21bc9c2618b0ef755
# Parent  799c420180287cbe9bb2626c5c6286444ba695ab
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 762e7ed9f64b
crecord: change the verb according to the operation

This will make crecord consistent with record when being used in the revert
situation. It will say "Select hunks to revert / discard" accordingly.

This should make the revert crecord interface less confusing.

diff --git a/mercurial/crecord.py b/mercurial/crecord.py
--- a/mercurial/crecord.py
+++ b/mercurial/crecord.py
@@ -502,4 +502,10 @@ def testchunkselector(testfn, ui, header
     return chunkselector.opts
 
+_headermessages = { # {operation: text}
+    'revert': _('Select hunks to revert'),
+    'discard': _('Select hunks to discard'),
+    None: _('Select hunks to record'),
+}
+
 class curseschunkselector(object):
     def __init__(self, headerlist, ui, operation=None):
@@ -558,4 +564,6 @@ class curseschunkselector(object):
 
         # affects some ui text
+        if operation not in _headermessages:
+            raise RuntimeError('unexpected operation: %s' % operation)
         self.operation = operation
 
@@ -951,5 +959,5 @@ class curseschunkselector(object):
         selected = self.currentselecteditem.applied
         segments = [
-            _('Select hunks to record'),
+            _headermessages[self.operation],
             '-',
             _('[x]=selected **=collapsed'),


More information about the Mercurial-devel mailing list