Patchwork [3,of,3] histedit: allow histedit --continue when not on a descendant

login
register
mail settings
Submitter Durham Goode
Date April 6, 2015, 2:30 a.m.
Message ID <49d4cd6f8fcd8a16c70f.1428287416@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/8508/
State Accepted
Headers show

Comments

Durham Goode - April 6, 2015, 2:30 a.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1428134405 25200
#      Sat Apr 04 01:00:05 2015 -0700
# Node ID 49d4cd6f8fcd8a16c70f59ac34b55e814f19d985
# Parent  43bc5bae453a1832b03ad63385dae200bc260f99
histedit: allow histedit --continue when not on a descendant

Previously we would not allow --continue if the current working copy parent was
not a descendant of the commit produced by the previous histedit step. There's
nothing really blocking us from continuing the histedit in this situation, so
let's stop aborting in this case.

In the future we will likely add an 'exec' action to histedit, which means the
user can do whatever they want during the middle of a histedit (like perhaps
calling 'hg update'), which means we'll need to support this case eventually
anyway.

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -774,11 +774,7 @@  def gatherchildren(repo, ctx):
     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)
+            return []
         newchildren.pop(0)  # remove ctx
     return newchildren
 
diff --git a/tests/test-histedit-arguments.t b/tests/test-histedit-arguments.t
--- a/tests/test-histedit-arguments.t
+++ b/tests/test-histedit-arguments.t
@@ -112,33 +112,6 @@  Test config specified default
   > EOF
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
-Run on a revision not descendants of the initial parent
---------------------------------------------------------------------
-
-Test the message shown for inconsistent histedit state, which may be
-created (and forgotten) by Mercurial earlier than 2.7. This emulates
-Mercurial earlier than 2.7 by renaming ".hg/histedit-state"
-temporarily.
-
-  $ HGEDITOR=cat hg histedit -r 4 --commands - << EOF
-  > edit 08d98a8350f3 4 five
-  > EOF
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  reverting alpha
-  Make changes as needed, you may commit or record as needed now.
-  When you are finished, run hg histedit --continue to resume.
-  [1]
-
-  $ mv .hg/histedit-state .hg/histedit-state.back
-  $ hg update --quiet --clean 2
-  $ mv .hg/histedit-state.back .hg/histedit-state
-
-  $ hg histedit --continue
-  abort: c8e68270e35a is not an ancestor of working directory
-  (use "histedit --abort" to clear broken state)
-  [255]
-
-  $ hg histedit --abort
   $ hg update --quiet --clean
 
 Test that missing revisions are detected