Patchwork [2,of,4] record: refactor the filtering code

login
register
mail settings
Submitter Laurent Charignon
Date March 18, 2015, 2:17 a.m.
Message ID <69389fa752562fb5888f.1426645054@dev919.prn2.facebook.com>
Download mbox | patch
Permalink /patch/8135/
State Accepted
Commit 2da601ab3125fefc619485698f081af725657d88
Headers show

Comments

Laurent Charignon - March 18, 2015, 2:17 a.m.
# HG changeset patch
# User Laurent Charignon <lcharignon@fb.com>
# Date 1426545350 25200
#      Mon Mar 16 15:35:50 2015 -0700
# Node ID 69389fa752562fb5888ffa44716d120c242d4f0f
# Parent  34f7b9ef6a7a96acf292f2721006e5e000bb4d68
record: refactor the filtering code

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -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,13 @@ 
     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