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

login
register
mail settings
Submitter Jun Wu
Date Nov. 23, 2016, 11:24 p.m.
Message ID <a25fb0c50bc0ad205116.1479943483@x1c>
Download mbox | patch
Permalink /patch/17740/
State Accepted
Headers show

Comments

Jun Wu - Nov. 23, 2016, 11:24 p.m.
# HG changeset patch
# User Jun Wu <quark@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.

Patch

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'),