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

Jun Wu quark at fb.com
Wed Nov 23 18:24:43 EST 2016


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1479942213 0
#      Wed Nov 23 23:03:33 2016 +0000
# Node ID a25fb0c50bc0ad20511621d15e1cc7c6478528c1
# Parent  18b6dea42fcdf5922926d6a0ab84f09c0cf5bd1a
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r a25fb0c50bc0
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'),
             _('c: confirm'),


More information about the Mercurial-devel mailing list