changeset 25310:c1f5ef76d1c2

record: add an operation arguments to customize recording ui 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 adds a new argument to the recording function to reflect in the UI what operation we are running.
author Laurent Charignon <lcharignon@fb.com>
date Wed, 27 May 2015 15:49:24 -0700
parents b333ca94403d
children d2e88f960d1a
files mercurial/cmdutil.py mercurial/crecord.py mercurial/patch.py
diffstat 3 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Sun Apr 26 18:13:48 2015 +0900
+++ b/mercurial/cmdutil.py	Wed May 27 15:49:24 2015 -0700
@@ -45,7 +45,7 @@
     setattr(ui, 'write', wrap)
     return oldwrite
 
-def filterchunks(ui, originalhunks, usecurses, testfile):
+def filterchunks(ui, originalhunks, usecurses, testfile, operation=None):
     if usecurses:
         if testfile:
             recordfn = crecordmod.testdecorator(testfile,
@@ -53,17 +53,23 @@
         else:
             recordfn = crecordmod.chunkselector
 
-        return crecordmod.filterpatch(ui, originalhunks, recordfn)
+        return crecordmod.filterpatch(ui, originalhunks, recordfn, operation)
 
     else:
-        return patch.filterpatch(ui, originalhunks)
-
-def recordfilter(ui, originalhunks):
+        return patch.filterpatch(ui, originalhunks, operation)
+
+def recordfilter(ui, originalhunks, operation=None):
+    """ Prompts the user to filter the originalhunks and return a list of
+    selected hunks.
+    *operation* is used for ui purposes to indicate the user
+    what kind of filtering they are doing: reverting, commiting, shelving, etc.
+    """
     usecurses =  ui.configbool('experimental', 'crecord', False)
     testfile = ui.config('experimental', 'crecordtest', None)
     oldwrite = setupwrapcolorwrite(ui)
     try:
-        newchunks = filterchunks(ui, originalhunks, usecurses, testfile)
+        newchunks = filterchunks(ui, originalhunks, usecurses, testfile,
+                                 operation)
     finally:
         ui.write = oldwrite
     return newchunks
--- a/mercurial/crecord.py	Sun Apr 26 18:13:48 2015 +0900
+++ b/mercurial/crecord.py	Wed May 27 15:49:24 2015 -0700
@@ -425,7 +425,7 @@
     def __repr__(self):
         return '<hunk %r@%d>' % (self.filename(), self.fromline)
 
-def filterpatch(ui, chunks, chunkselector):
+def filterpatch(ui, chunks, chunkselector, operation=None):
     """interactively filter patch chunks into applied-only chunks"""
 
     chunks = list(chunks)
--- a/mercurial/patch.py	Sun Apr 26 18:13:48 2015 +0900
+++ b/mercurial/patch.py	Wed May 27 15:49:24 2015 -0700
@@ -948,7 +948,7 @@
     def __repr__(self):
         return '<hunk %r@%d>' % (self.filename(), self.fromline)
 
-def filterpatch(ui, headers):
+def filterpatch(ui, headers, operation=None):
     """Interactively filter patch chunks into applied-only chunks"""
 
     def prompt(skipfile, skipall, query, chunk):