[PATCH 3 of 5 V2] histedit: move logic for finding child nodes to new function

Olle Lundberg olle.lundberg at gmail.com
Thu Mar 6 05:26:16 CST 2014


# HG changeset patch
# User Olle Lundberg <geek at nerd.sh>
# Date 1394065443 -3600
#      Thu Mar 06 01:24:03 2014 +0100
# Node ID ab2d2ac49a0293653398995ef2de73f31485341a
# Parent  0f4009fb0e1373e4fa9d5814f8f41e49bb3ec37b
histedit: move logic for finding child nodes to new function

This function will be used in later patches.

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -662,27 +662,32 @@
     cleanupnode(ui, repo, 'temp', tmpnodes)
     os.unlink(os.path.join(repo.path, 'histedit-state'))
     if os.path.exists(repo.sjoin('undo')):
         os.unlink(repo.sjoin('undo'))
 
+def gatherchildren(repo, ctx):
+    # is there any new commit between the expected parent and "."
+    #
+    # note: does not take non linear new change in account (but previous
+    #       implementation didn't used them anyway (issue3655)
+    newchildren = [c.node() for c in repo.set('(%d::.)', ctx)]
+    if ctx.node() != node.nullid:
+        if not newchildren:
+            # `ctx` should match but no result. This means that
+            # currentnode is not a descendant from ctx.
+            msg = _('%s is not an ancestor of working directory')
+            hint = _('use "histedit --abort" to clear broken state')
+            raise util.Abort(msg % ctx, hint=hint)
+        newchildren.pop(0)  # remove ctx
+    return newchildren
 
 def bootstrapcontinue(ui, repo, parentctx, rules, opts):
     action, currentnode = rules.pop(0)
     ctx = repo[currentnode]
-    # is there any new commit between the expected parent and "."
-    #
-    # note: does not take non linear new change in account (but previous
-    #       implementation didn't used them anyway (issue3655)
-    newchildren = [c.node() for c in repo.set('(%d::.)', parentctx)]
-    if parentctx.node() != node.nullid:
-        if not newchildren:
-            # `parentctxnode` should match but no result. This means that
-            # currentnode is not a descendant from parentctxnode.
-            msg = _('%s is not an ancestor of working directory')
-            hint = _('use "histedit --abort" to clear broken state')
-            raise util.Abort(msg % parentctx, hint=hint)
-        newchildren.pop(0)  # remove parentctxnode
+
+    newchildren = gatherchildren(repo, parentctx)
+
     # Commit dirty working directory if necessary
     new = None
     m, a, r, d = repo.status()[:4]
     if m or a or r or d:
         # prepare the message for the commit to comes


More information about the Mercurial-devel mailing list