[PATCH v2-dederpified] histedit: support editing of the first commit (issue3767)

Bryan O'Sullivan bos at serpentine.com
Fri Apr 12 16:20:45 CDT 2013


# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1365801616 25200
#      Fri Apr 12 14:20:16 2013 -0700
# Node ID 0431c546a0afaad7fd722f6af4bbe673a72ed392
# Parent  0b355eb5ac4142610f74c83347392beb598f2618
histedit: support editing of the first commit (issue3767)

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -580,14 +580,15 @@ def bootstrapcontinue(ui, repo, parentct
     # 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 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 = _('update to %s or descendant and run "hg histedit '
-                 '--continue" again') % parentctx
-        raise util.Abort(msg % parentctx, hint=hint)
-    newchildren.pop(0)  # remove parentctxnode
+    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 = _('update to %s or descendant and run "hg histedit '
+                     '--continue" again') % parentctx
+            raise util.Abort(msg % parentctx, hint=hint)
+        newchildren.pop(0)  # remove parentctxnode
     # Commit dirty working directory if necessary
     new = None
     m, a, r, d = repo.status()[:4]
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
@@ -209,3 +209,16 @@ rollback should not work after a histedi
   [1]
 
   $ cd ..
+  $ hg clone -qr0 r r0
+  $ cd r0
+  $ echo edit cb9a9f314b8b a > $EDITED
+  $ hg phase -fdr0
+  $ HGEDITOR="cat \"$EDITED\" > " hg histedit 0 2>&1
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  adding a
+  abort: Make changes as needed, you may commit or record as needed now.
+  When you are finished, run hg histedit --continue to resume.
+  [255]
+  $ HGEDITOR=true hg histedit --continue
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  saved backup bundle to $TESTTMP/r0/.hg/strip-backup/cb9a9f314b8b-backup.hg (glob)


More information about the Mercurial-devel mailing list