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

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 28, 2012, 10:44 p.m.
Message ID <a85521cba1859b1e8405.1356734697@yamac.lan>
Download mbox | patch
Permalink /patch/323/
State Superseded, archived
Headers show

Comments

Pierre-Yves David - Dec. 28, 2012, 10:44 p.m.
# 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.

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):
+        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