record: refactor the filtering code
authorLaurent Charignon <lcharignon@fb.com>
Mon, 16 Mar 2015 15:35:50 -0700
changeset 24357 2da601ab3125
parent 24356 a38f384f2a57
child 24358 8d9e9063b040
record: refactor the filtering code
mercurial/cmdutil.py
--- 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