[PATCH V3] record: display the running operation for recording commands

Laurent Charignon lcharignon at fb.com
Mon Jun 1 12:38:21 CDT 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1432767495 25200
#      Wed May 27 15:58:15 2015 -0700
# Node ID 1e379d0f63b47fba888724c5a90717c67c874552
# Parent  6084926366b979e81e5dcc84fa595965d4c07883
record: display the running operation for recording commands

This patch is part of a series of patches to change the recording ui to reflect
the operation currently running (commit, shelve, revert ...).
This patch makes the UI change to display the running operation on the UI.
It does not change any tests since we are not using the feature in any command
yet.

diff --git a/mercurial/crecord.py b/mercurial/crecord.py
--- a/mercurial/crecord.py
+++ b/mercurial/crecord.py
@@ -441,7 +441,7 @@
     uiheaders = [uiheader(h) for h in headers]
     # let user choose headers/hunks/lines, and mark their applied flags
     # accordingly
-    chunkselector(ui, uiheaders)
+    chunkselector(ui, uiheaders, operation)
     appliedhunklist = []
     for hdr in uiheaders:
         if (hdr.applied and
@@ -474,14 +474,14 @@
         "hhhh", fcntl.ioctl(_origstdout, termios.TIOCGWINSZ, "\000"*8))[0:2]
     return h, w
 
-def chunkselector(ui, headerlist):
+def chunkselector(ui, headerlist, operation):
     """
     curses interface to get selection of chunks, and mark the applied flags
     of the chosen chunks.
 
     """
     ui.write(_('starting interactive selection\n'))
-    chunkselector = curseschunkselector(headerlist, ui)
+    chunkselector = curseschunkselector(headerlist, ui, operation)
     curses.wrapper(chunkselector.main)
 
 def testdecorator(testfn, f):
@@ -489,7 +489,7 @@
         return f(testfn, *args, **kwargs)
     return u
 
-def testchunkselector(testfn, ui, headerlist):
+def testchunkselector(testfn, ui, headerlist, operation):
     """
     test interface to get selection of chunks, and mark the applied flags
     of the chosen chunks.
@@ -505,10 +505,11 @@
                 break
 
 class curseschunkselector(object):
-    def __init__(self, headerlist, ui):
+    def __init__(self, headerlist, ui, operation=_('confirm')):
         # put the headers into a patch object
         self.headerlist = patch(headerlist)
 
+        self.operation = operation
         self.ui = ui
 
         # list of all chunks
@@ -1322,10 +1323,7 @@
         helptext = """            [press any key to return to the patch-display]
 
 crecord allows you to interactively choose among the changes you have made,
-and confirm only those changes you select for further processing by the command
-you are running (commit/shelve/revert), after confirming the selected
-changes, the unselected changes are still present in your working copy, so you
-can use crecord multiple times to split large changes into smaller changesets.
+and %s only those changes you select.
 the following are valid keystrokes:
 
                 [space] : (un-)select item ([~]/[x] = partly/fully applied)
@@ -1339,10 +1337,11 @@
                       m : edit / resume editing the commit message
                       e : edit the currently selected hunk
                       a : toggle amend mode (hg rev >= 2.2)
-                      c : confirm selected changes
+                      c : %s selected changes
                       r : review/edit and confirm selected changes
                       q : quit without confirming (no changes will be made)
-                      ? : help (what you're currently reading)"""
+                      ? : help (what you're currently reading)"""\
+                      % (self.operation, self.operation)
 
         helpwin = curses.newwin(self.yscreensize, 0, 0, 0)
         helplines = helptext.split("\n")
@@ -1391,11 +1390,12 @@
 note: don't add/remove lines unless you also modify the range information.
       failing to follow this rule will result in the commit aborting.
 
-are you sure you want to review/edit and confirm the selected changes [yn]?
-""")
+are you sure you want to review/edit and %s the selected changes [yn]?
+""" %(self.operation))
         else:
             confirmtext = (
-                "are you sure you want to confirm the selected changes [yn]? ")
+                "are you sure you want to %s the selected changes [yn]? "
+                %(self.operation))
 
         response = self.confirmationwindow(confirmtext)
         if response is None:
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -970,7 +970,7 @@
             return skipfile, skipfile, skipall, newpatches
         while True:
             resps = _('[Ynesfdaq?]'
-                      '$$ &Yes, record this change'
+                      '$$ &Yes, ') + operation + _(' this change'
                       '$$ &No, skip this change'
                       '$$ &Edit this change manually'
                       '$$ &Skip remaining changes to this file'
@@ -1080,10 +1080,10 @@
             if skipfile is None and skipall is None:
                 chunk.pretty(ui)
             if total == 1:
-                msg = _("record this change to '%s'?") % chunk.filename()
+                msg = operation + _(" this change to '%s'?") % chunk.filename()
             else:
                 idx = pos - len(h.hunks) + i
-                msg = _("record change %d/%d to '%s'?") % (idx, total,
+                msg = operation + _(" change %d/%d to '%s'?") % (idx, total,
                                                            chunk.filename())
             r, skipfile, skipall, newpatches = prompt(skipfile,
                     skipall, msg, chunk)


More information about the Mercurial-devel mailing list