[PATCH 3 of 3 evolve-ext-V3] evolve: make fold aware of allowunstable

Laurent Charignon lcharignon at fb.com
Mon Jun 15 12:30:14 CDT 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1432072589 25200
#      Tue May 19 14:56:29 2015 -0700
# Node ID a99f044f1d2b66f4afc3412f3a571b613d326504
# Parent  344c3067174c08634e8564a1067028625c16b536
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.

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -2422,6 +2422,10 @@
         raise util.Abort(_("cannot fold non-linear revisions "
                            "(multiple heads given)"))
     head = repo[heads.first()]
+    disallowunstable = not obsolete.isenabled(repo, obsolete.allowunstableopt)
+    notarepohead = not head.rev() in repo.changelog.headrevs()
+    if disallowunstable and notarepohead:
+        raise util.Abort(_("cannot fold chain not ending with a head"))
     wlock = lock = None
     try:
         wlock = repo.wlock()
diff --git a/tests/test-evolve.t b/tests/test-evolve.t
--- a/tests/test-evolve.t
+++ b/tests/test-evolve.t
@@ -1309,3 +1309,27 @@
   [255]
   $ hg prune 897e7966b9ef
   1 changesets pruned
+
+Check that fold respects the allowunstable option
+  $ glog -r "25::"
+  o  51:07aaa06da467 at default(draft) add c3_
+  |
+  | @  50:e543e9e71376 at default(draft) add b4_
+  | |
+  o |  49:9379d7237601 at default(draft) add c2prime
+  | |
+  | o  48:2b5cbe59aeca at default(draft) add b3prime
+  | |
+  | o  47:aa4f5bf8925e at default(draft) add b1prime
+  | |
+  o |  42:4a34f6744d4b at default(draft) add c1second
+  |/
+  o  25:4c0bc042ef3b at default(draft) add j1
+  |
+ 
+  $ hg fold --exact "aa4f5bf8925e + 2b5cbe59aeca"
+  abort: cannot fold chain not ending with a head
+  [255]
+  $ hg fold --exact "aa4f5bf8925e + 2b5cbe59aeca + e543e9e71376"
+  3 changesets folded
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved


More information about the Mercurial-devel mailing list