record: extract ishunk to a function
authorLaurent Charignon <lcharignon@fb.com>
Thu, 21 May 2015 14:28:02 -0700
changeset 25256 5a8398b085ed
parent 25255 ad1d2c952889
child 25257 07326d76f19d
record: extract ishunk to a function We extract this code as we want to reuse it in revert -i.
mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Sun Apr 26 22:26:44 2015 +0900
+++ b/mercurial/cmdutil.py	Thu May 21 14:28:02 2015 -0700
@@ -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') %