[PATCH 1 of 5] record: extract ishunk to a function

Laurent Charignon lcharignon at fb.com
Thu May 21 18:17:13 CDT 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1432243682 25200
#      Thu May 21 14:28:02 2015 -0700
# Node ID 6a07454641dd43d5b7ba727769df984f1647b4e9
# Parent  451df92cec4912aefac57a4cf82e9268192c867b
record: extract ishunk to a function

We extract this code as we want to reuse it in revert -i.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -17,6 +17,10 @@
 import crecord as crecordmod
 import lock as lockmod
 
+def ishunk(x):
+    hunkclasses = (crecordmod.uihunk, patch.recordhunk)
+    return isinstance(x, hunkclasses)
+
 def parsealiases(cmd):
     return cmd.lstrip("^").split("|")
 
@@ -59,8 +63,6 @@
 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') %


More information about the Mercurial-devel mailing list