[PATCH 06 of 12] histedit: simplify computation of `newchildren` during --continue

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Thu Sep 27 07:23:25 CDT 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1348746916 -7200
# Node ID 5e47f33617804b53ae125f042d8e9a5dd8cac822
# Parent  395622e18051ea08908bcb745ac6cef41b967c5c
histedit: simplify computation of `newchildren` during --continue

We are now checking for any changesets between the previous `parentctx` and the
current working directory parent. If the current working directory parent is
inconsistent, we abort.

This change is useful as it simplify the --continue process, easing upcoming
changes.

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -548,25 +548,24 @@ def histedit(ui, repo, *parent, **opts):
         os.unlink(repo.sjoin('undo'))
 
 
 def bootstrapcontinue(ui, repo, parentctx, existing, replacemap, rules,
                       tmpnodes, created, replaced, opts):
-    currentparent, wantnull = repo.dirstate.parents()
-    # existing is the list of revisions initially considered by
-    # histedit. Here we use it to list new changesets, descendants
-    # of parentctx without an 'existing' changeset in-between. We
-    # also have to exclude 'existing' changesets which were
-    # previously dropped.
-    descendants = set(c.node() for c in
-            repo.set('(%d::) - %d', parentctx, parentctx))
-    notdropped = set(n for n in existing if n in descendants and
-            (n not in replacemap or replacemap[n] in descendants))
-    # Discover any nodes the user has added in the interim. We can
-    # miss changesets which were dropped and recreated the same.
-    newchildren = list(c.node() for c in repo.set(
-        'sort(%ln - (%ln or %ln::))', descendants, existing, notdropped))
     action, currentnode = rules.pop(0)
+    ctx = repo[currentnode]
+    # is there any new commit between the expected parent and "."
+    # XXX does not take non linear new change in account (but previous
+    # XXX implementation didn't used them anyway
+    newchildren = [c.node() for c in repo.set('(%d::.)', parentctx)]
+    if not newchildren:
+        # `parentctxnode` should match but no result. This means that
+        # currentnode is not a descendant from parentctxnode.
+        msg = _('Current working direct parents is not a descendant of %s')
+        hint = _('update backto the proper location and type rebase '
+                 '--continue again')
+        raise util.Abort(msg % parentctx, hint=hint)
+    newchildren.pop(0)  # remove parentctxnode
     if action in ('f', 'fold'):
         tmpnodes.extend(newchildren)
     else:
         created.extend(newchildren)
 
diff --git a/tests/test-histedit-edit.t b/tests/test-histedit-edit.t
--- a/tests/test-histedit-edit.t
+++ b/tests/test-histedit-edit.t
@@ -64,10 +64,23 @@ edit the history
   $ HGEDITOR="cat \"$EDITED\" > " hg histedit 177f92b77385 2>&1 | fixbundle
   0 files updated, 0 files merged, 2 files removed, 0 files unresolved
   abort: Make changes as needed, you may commit or record as needed now.
   When you are finished, run hg histedit --continue to resume.
 
+Go at a random point and try to continue
+
+  $ hg id -n
+  3+
+  $ hg up 0
+  0 files updated, 0 files merged, 3 files removed, 0 files unresolved
+  $ HGEDITOR='echo foobaz > ' hg histedit --continue
+  abort: Current working direct parents is not a descendant of 055a42cdd887
+  (update backto the proper location and type rebase --continue again)
+  [255]
+  $ hg up 3
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
 commit, then edit the revision
   $ hg ci -m 'wat'
   created new head
   $ echo a > e
   $ HGEDITOR='echo foobaz > ' hg histedit --continue 2>&1 | fixbundle


More information about the Mercurial-devel mailing list