Patchwork [5,of,6] record: minor refactoring of dorecord

login
register
mail settings
Submitter Laurent Charignon
Date March 13, 2015, 9:21 p.m.
Message ID <c5650ec7e9b12e14b7d9.1426281716@dev919.prn2.facebook.com>
Download mbox | patch
Permalink /patch/8069/
State Accepted
Headers show

Comments

Laurent Charignon - March 13, 2015, 9:21 p.m.
# HG changeset patch
# User Laurent Charignon <lcharignon@fb.com>
# Date 1426207823 25200
#      Thu Mar 12 17:50:23 2015 -0700
# Node ID c5650ec7e9b12e14b7d9be5b0997f0712e17016e
# Parent  2fdd632353a2381e88ed2572a4e691502adc5992
record: minor refactoring of dorecord

It prepares the way for introducing the flag to reverse hunk selection

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -39,6 +39,9 @@ 
 def dorecord(ui, repo, commitfunc, cmdsuggest, backupall,
             filterfn, *pats, **opts):
     import merge as mergemod
+    hunkclasses = (crecordmod.uihunk, patch.recordhunk)
+    ishunk = lambda x: isinstance(x, hunkclasses)
+
     if not ui.interactive():
         raise util.Abort(_('running non-interactively, use %s instead') %
                          cmdsuggest)
@@ -96,10 +99,8 @@ 
 
         newandmodifiedfiles = set()
         for h in chunks:
-            iscrecordhunk = isinstance(h, crecordmod.uihunk)
-            ishunk = isinstance(h, patch.recordhunk)
             isnew = h.filename() in status.added
-            if (ishunk or iscrecordhunk) and isnew and not h in originalchunks:
+            if ishunk(h) and isnew and not h in originalchunks:
                 newandmodifiedfiles.add(h.filename())
 
         modified = set(status.modified)