Patchwork [3,of,3,V2] histedit: allow operation from non-head if obsolete is enabled

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 29, 2012, 4:27 a.m.
Message ID <7d0ac10cb95b3a4613b3.1356755243@yamac.lan>
Download mbox | patch
Permalink /patch/332/
State Accepted
Commit 0f5a0a2073a84f869e9b93706c312361d3729dfd
Headers show

Comments

Pierre-Yves David - Dec. 29, 2012, 4:27 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1356754802 -3600
# Node ID 7d0ac10cb95b3a4613b336a80778a9958fe6fcc9
# Parent  04b52e58f3a811e9210025d8ca6088dcc7cf7dbc
histedit: allow operation from non-head if obsolete is enabled

Obsolescence marker can represent this situation just fine. Rewritten revisions
are marked as precursors of the ones creates by histedit. Unaffected descendants
becomes "unstable".

When obsolescence is not enabled we keep aborting. This new default behavior
only apply when obsolete is enabled and is subject to future discussion and
changes.

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -591,11 +591,12 @@  def between(repo, old, new, keep):
     """select and validate the set of revision to edit
 
     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():
             raise util.Abort(_('cannot edit immutable changeset: %s') % root)
     return [c.node() for c in ctxs]
diff --git a/tests/test-histedit-obsolete.t b/tests/test-histedit-obsolete.t
--- a/tests/test-histedit-obsolete.t
+++ b/tests/test-histedit-obsolete.t
@@ -139,5 +139,17 @@  Check that histedit respect phases
   $ hg ph -pv '.^'
   phase changed for 2 changesets
   $ 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