histedit: allow operation from non-head if obsolete is enabled
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Mon, 31 Dec 2012 17:46:22 -0600
changeset 18165 0f5a0a2073a8
parent 18164 bacf55bd8f90
child 18166 3a2e810dd3d8
histedit: allow operation from non-head if obsolete is enabled Obsolescence markers can represent this situation just fine. Rewritten revisions are marked as precursors of the ones creates by histedit. Unaffected descendants become "unstable". If obsolescence is not enabled we keep the current behavior of aborting. This new behavior only applies when obsolete is enabled and is subject to future discussion and changes.
hgext/histedit.py
tests/test-histedit-obsolete.t
--- a/hgext/histedit.py	Mon Dec 31 17:45:52 2012 -0600
+++ b/hgext/histedit.py	Mon Dec 31 17:46:22 2012 -0600
@@ -593,7 +593,8 @@
     When keep is false, the specified set can't have children."""
     ctxs = list(repo.set('%n::%n', old, new))
     if ctxs and not keep:
-        if repo.revs('(%ld::) - (%ld + hidden())', ctxs, ctxs):
+        if (not obsolete._enabled and
+            repo.revs('(%ld::) - (%ld + hidden())', ctxs, ctxs)):
             raise util.Abort(_('cannot edit history that would orphan nodes'))
         root = ctxs[0] # list is already sorted by repo.set
         if not root.phase():
--- a/tests/test-histedit-obsolete.t	Mon Dec 31 17:45:52 2012 -0600
+++ b/tests/test-histedit-obsolete.t	Mon Dec 31 17:46:22 2012 -0600
@@ -141,3 +141,15 @@
   $ hg histedit -r '.~2'
   abort: cannot edit immutable changeset: cb9a9f314b8b
   [255]
+
+
++Test ui.prevent-unstable option
++------------------------------------
+
+  $ hg up '.^'
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg phase --force --draft .
+  $ hg log -r 'children(.)'
+  9:7c044e3e33a9 f (no-eol)
+  $ hg histedit -r '.'
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved