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

login
register
mail settings
Submitter Olle Lundberg
Date March 6, 2014, 11:26 a.m.
Message ID <ab2d2ac49a0293653398.1394105176@SE-C02KQ0DADR55>
Download mbox | patch
Permalink /patch/3873/
State Accepted
Commit 0838bd2f600fb9f7e3ae6a4a821514e3bf53b71f
Headers show

Comments

Olle Lundberg - March 6, 2014, 11:26 a.m.
# HG changeset patch
# User Olle Lundberg <geek@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.

Patch

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