evolve: make prune respect allowunsable
authorLaurent Charignon <lcharignon@fb.com>
Fri, 19 Jun 2015 11:03:51 -0700
changeset 1397 35f2f54b557c
parent 1396 ba95cec18fe9
child 1398 7ddcbf5469bc
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.
hgext/evolve.py
tests/test-evolve.t
--- a/hgext/evolve.py	Fri Jun 19 10:47:02 2015 -0700
+++ b/hgext/evolve.py	Fri Jun 19 11:03:51 2015 -0700
@@ -1950,6 +1950,10 @@
         if not precs:
             raise util.Abort('nothing to prune')
 
+        if not obsolete.isenabled(repo, obsolete.allowunstableopt):
+            if len(repo.revs("(%ld::) - %ld", revs, revs)) != 0:
+                raise util.Abort(_("cannot prune in the middle of a stack"))
+
         # defines successors changesets
         sucs = scmutil.revrange(repo, succs)
         sucs.sort()
--- a/tests/test-evolve.t	Fri Jun 19 10:47:02 2015 -0700
+++ b/tests/test-evolve.t	Fri Jun 19 11:03:51 2015 -0700
@@ -1104,3 +1104,47 @@
   |/
   o  18:0bb66d4c1968@default(draft) a3
   |
+
+Check that prune respects the allowunstable option
+  $ hg up -C .
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg evolve --rev "22::"
+  move:[22] add j2
+  atop:[26] add j1
+  move:[23] add j3
+  atop:[27] add j2
+  working directory is now at 920a35e8dbd0
+  $ glog -r "18::"
+  @  28:920a35e8dbd0@default(draft) add j3
+  |
+  o  27:31e050d895dd@default(draft) add j2
+  |
+  o  26:04b32348803e@default(draft) add j1
+  |
+  | o  20:db3d894869b0@default(draft) add gh
+  | |
+  o |  19:10ffdd7e3cc9@default(draft) add gg
+  |/
+  o  18:0bb66d4c1968@default(draft) a3
+  |
+  $ hg up 19
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ mkcommit c5_
+  created new head
+  $ hg prune '26 + 27'
+  abort: cannot prune in the middle of a stack
+  [255]
+  $ hg prune '19::28'
+  abort: cannot prune in the middle of a stack
+  [255]
+  $ hg prune '26::'
+  3 changesets pruned
+  $ glog -r "18::"
+  @  29:5a6c53544778@default(draft) add c5_
+  |
+  | o  20:db3d894869b0@default(draft) add gh
+  | |
+  o |  19:10ffdd7e3cc9@default(draft) add gg
+  |/
+  o  18:0bb66d4c1968@default(draft) a3
+  |