evolve: make uncommit respect allowunsable
Before this patch, the uncommit command was performing the same way regardless
of the value of experimental.evolution.
With this patch if the configuration does not allow unstability, uncommit won't
create instability.
--- a/hgext/evolve.py Sat Jun 13 11:14:07 2015 -0700
+++ b/hgext/evolve.py Wed May 20 12:46:13 2015 -0700
@@ -2209,6 +2209,11 @@
if ctx.p1() == rev or ctx.p2() == rev:
raise util.Abort(_("cannot uncommit to parent changeset"))
+ onahead = old.rev() in repo.changelog.headrevs()
+ disallowunstable = not obsolete.isenabled(repo, obsolete.allowunstableopt)
+ if disallowunstable and not onahead:
+ raise util.Abort(_("cannot uncommit in the middle of a stack"))
+
# Recommit the filtered changeset
tr = repo.transaction('uncommit')
newid = None
--- a/tests/test-evolve.t Sat Jun 13 11:14:07 2015 -0700
+++ b/tests/test-evolve.t Wed May 20 12:46:13 2015 -0700
@@ -1248,3 +1248,57 @@
o 25:4c0bc042ef3b@default(draft) add j1
|
+Check that uncommit respects the allowunstable option
+With only createmarkers we can only uncommit on a head
+ $ hg up 456e647fbe11
+ 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ cat >> $HGRCPATH <<EOF
+ > [experimental]
+ > evolution=createmarkers, allnewcommands
+ > EOF
+ $ glog -r "25::"
+ @ 52:456e647fbe11@default(draft) add c4_
+ |
+ o 51:07aaa06da467@default(draft) add c3_
+ |
+ | o 50:e543e9e71376@default(draft) add b4_
+ | |
+ o | 49:9379d7237601@default(draft) add c2prime
+ | |
+ | o 48:2b5cbe59aeca@default(draft) add b3prime
+ | |
+ | o 47:aa4f5bf8925e@default(draft) add b1prime
+ | |
+ o | 42:4a34f6744d4b@default(draft) add c1second
+ |/
+ o 25:4c0bc042ef3b@default(draft) add j1
+ |
+ $ hg up .^
+ 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+ $ hg uncommit --all
+ abort: cannot uncommit in the middle of a stack
+ [255]
+ $ hg up 456e647fbe11
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ hg uncommit --all
+ new changeset is empty
+ (use "hg prune ." to remove it)
+ $ hg up e543e9e71376 -C
+ 3 files updated, 0 files merged, 3 files removed, 0 files unresolved
+ $ glog -r "25::"
+ o 53:897e7966b9ef@default(draft) add c4_
+ |
+ o 51:07aaa06da467@default(draft) add c3_
+ |
+ | @ 50:e543e9e71376@default(draft) add b4_
+ | |
+ o | 49:9379d7237601@default(draft) add c2prime
+ | |
+ | o 48:2b5cbe59aeca@default(draft) add b3prime
+ | |
+ | o 47:aa4f5bf8925e@default(draft) add b1prime
+ | |
+ o | 42:4a34f6744d4b@default(draft) add c1second
+ |/
+ o 25:4c0bc042ef3b@default(draft) add j1
+ |