[PATCH 3 of 4 evolve-ext] evolve: make prune respect allowunsable

Laurent Charignon lcharignon at fb.com
Thu Jun 4 13:52:16 CDT 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1432759785 25200
#      Wed May 27 13:49:45 2015 -0700
# Node ID 1c2467a8f3a936b7e1d9c02a5a750ef0de140187
# Parent  534f9500c108f4b953116de055ecfc99ae7a475f
evolve: make prune respect allowunsable

Before this patch, the prune command was performing the same way regardless
of the value of experimental.evolution.
With this patch if the configuration does not allow unstability, prune won't
create instability.

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -1857,6 +1857,14 @@
         if not precs:
             raise util.Abort('nothing to prune')
 
+        if not obsolete.isenabled(repo, obsolete.allowunstableopt):
+            repoheads = repo.changelog.headrevs()
+            pruneheads = repo.revs("heads(%ld)", precs)
+            # If a prune head is not a repo head then we will create
+            # unstability by operating on the midddle of the stack
+            if not all([h in repoheads for h in pruneheads]):
+                raise util.Abort(_("cannot prune in the middle of a stack"))
+
         # defines successors changesets
         sucs = scmutil.revrange(repo, succs)
         sucs.sort()
diff --git a/tests/test-evolve.t b/tests/test-evolve.t
--- a/tests/test-evolve.t
+++ b/tests/test-evolve.t
@@ -1166,3 +1166,16 @@
   |
   o  0:07c1c36d9ef0 at default(public) a0
   
+
+Check that prune respects the allowunstable option
+  $ cat >> $HGRCPATH <<EOF
+  > [experimental]
+  > evolution=createmarkers
+  > evolutioncommands=^prune
+  > EOF
+  $ hg prune 0bb66d4c1968
+  abort: cannot prune in the middle of a stack
+  [255]
+  $ hg prune bb4ea90d7601
+  1 changesets pruned
+


More information about the Mercurial-devel mailing list