evolve: make fold aware of allowunstable
Before this patch, the fold command was performing the same way regardless of
the value of experimental.evolution.
With this patch if the configuration does not allow unstability, fold won't
create instability.
--- a/hgext/evolve.py Fri Jun 19 11:03:51 2015 -0700
+++ b/hgext/evolve.py Fri Jun 19 11:04:18 2015 -0700
@@ -2445,6 +2445,11 @@
raise util.Abort(_("cannot fold non-linear revisions "
"(multiple heads given)"))
head = repo[heads.first()]
+ disallowunstable = not obsolete.isenabled(repo, obsolete.allowunstableopt)
+ if disallowunstable:
+ if len(repo.revs("(%ld::) - %ld", revs, revs)) != 0:
+ raise util.Abort(_("cannot fold chain not ending with a head "\
+ "or with branching"))
wlock = lock = None
try:
wlock = repo.wlock()
--- a/tests/test-evolve.t Fri Jun 19 11:03:51 2015 -0700
+++ b/tests/test-evolve.t Fri Jun 19 11:04:18 2015 -0700
@@ -1148,3 +1148,29 @@
|/
o 18:0bb66d4c1968@default(draft) a3
|
+
+Check that fold respects the allowunstable option
+ $ hg up 0bb66d4c1968
+ 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+ $ mkcommit unstableifparentisfolded
+ created new head
+ $ glog -r "18::"
+ @ 30:30ecefd67c0a@default(draft) add unstableifparentisfolded
+ |
+ | o 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
+ |
+
+ $ hg fold --exact "19 + 18"
+ abort: cannot fold chain not ending with a head or with branching
+ [255]
+ $ hg fold --exact "18::29"
+ abort: cannot fold chain not ending with a head or with branching
+ [255]
+ $ hg fold --exact "19::"
+ 2 changesets folded