[PATCH 4 of 4] histedit: honor prevent-unstable configuration option

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Dec 28 16:44:57 CST 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1356725892 -3600
# Node ID a85521cba1859b1e8405c2abb5c0f7a22279c543
# Parent  7a8371309613a664efd3fa6353e67b6659478f4f
histedit: honor prevent-unstable configuration option

If configured properly, histedit now accepts to orphan nodes. Orphaned nodes
becomes unstable.

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):
+        orphans = repo.revs('(%ld::) - (%ld + hidden())', ctxs, ctxs)
+        if orphans and obsolete.preventunstable(repo.ui):
             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,22 @@ 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 histedit -r '.'
+  abort: cannot edit history that would orphan nodes
+  [255]
+  $ cat >> $HGRCPATH << EOF
+  > [ui]
+  > prevent-unstable=False
+  > EOF
+  $ hg histedit -r '.'
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved


More information about the Mercurial-devel mailing list