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

Laurent Charignon lcharignon at fb.com
Mon Jun 15 12:30:13 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 344c3067174c08634e8564a1067028625c16b536
# Parent  c73aa260e157a1e5d534d3447d16664992a0e7a5
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
@@ -1923,6 +1923,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
@@ -1302,3 +1302,10 @@
   |/
   o  25:4c0bc042ef3b at default(draft) add j1
   |
+
+Check that prune respects the allowunstable option
+  $ hg prune 2b5cbe59aeca
+  abort: cannot prune in the middle of a stack
+  [255]
+  $ hg prune 897e7966b9ef
+  1 changesets pruned


More information about the Mercurial-devel mailing list