Comments
Patch
@@ -2423,6 +2423,11 @@ def fold(ui, repo, *revs, **opts):
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()
@@ -1316,3 +1316,35 @@ Check that prune respects the allowunsta
[255]
$ hg prune 897e7966b9ef
1 changesets pruned
+
+Check that fold respects the allowunstable option
+ $ glog -r "25::"
+ @ 54:3cb1092f72f3@default(draft) add c5_
+ |
+ 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 aa4f5bf8925e
+ 1 files updated, 0 files merged, 4 files removed, 0 files unresolved
+ $ mkcommit unstableifparentisfolded
+ created new head
+
+ $ hg fold --exact "aa4f5bf8925e + 2b5cbe59aeca"
+ abort: cannot fold chain not ending with a head or with branching
+ [255]
+ $ hg fold --exact "aa4f5bf8925e + 2b5cbe59aeca + e543e9e71376"
+ abort: cannot fold chain not ending with a head or with branching
+ [255]
+ $ hg fold --exact "2b5cbe59aeca + e543e9e71376"
+ 2 changesets folded