[PATCH 5 of 6 evolve-ext-V2] evolve: make prune respect allowunsable

Laurent Charignon lcharignon at fb.com
Thu Jun 4 18:09:20 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 5bb1a7c466988c57ba224c9aa59b02c4e778b4bd
# Parent  eb63b8ee80f4d9de5dc61aef279cf3e46a0784f3
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
@@ -1944,6 +1944,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
@@ -1428,3 +1428,15 @@
   |/
   o  25:4c0bc042ef3b at default(draft) add j1
   |
+
+Check that prune respects the allowunstable option
+  $ cat >> $HGRCPATH <<EOF
+  > [experimental]
+  > evolution=createmarkers
+  > evolutioncommands=^prune
+  > EOF
+  $ 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