changeset 24357:2da601ab3125

record: refactor the filtering code
author Laurent Charignon <lcharignon@fb.com>
date Mon, 16 Mar 2015 15:35:50 -0700
parents a38f384f2a57
children 8d9e9063b040
files mercurial/cmdutil.py
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Mon Mar 16 15:30:33 2015 -0700
+++ b/mercurial/cmdutil.py	Mon Mar 16 15:35:50 2015 -0700
@@ -34,10 +34,8 @@
     setattr(ui, 'write', wrap)
     return oldwrite
 
-def recordfilter(ui, originalhunks):
-    usecurses =  ui.configbool('experimental', 'crecord', False)
+def filterchunks(ui, originalhunks, usecurses, testfile):
     if usecurses:
-        testfile = ui.config('experimental', 'crecordtest', None)
         if testfile:
             recordfn = crecordmod.testdecorator(testfile,
                                                 crecordmod.testchunkselector)
@@ -49,6 +47,12 @@
     else:
         return patch.filterpatch(ui, originalhunks)
 
+def recordfilter(ui, originalhunks):
+    usecurses =  ui.configbool('experimental', 'crecord', False)
+    testfile = ui.config('experimental', 'crecordtest', None)
+    newchunks = filterchunks(ui, originalhunks, usecurses, testfile)
+    return newchunks
+
 def dorecord(ui, repo, commitfunc, cmdsuggest, backupall,
             filterfn, *pats, **opts):
     import merge as mergemod