[PATCH 6 of 6 evolve-ext-V2] evolve: make fold aware of allowunstable

Laurent Charignon lcharignon at fb.com
Thu Jun 4 18:09:21 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 edd9447f3242ef2a4bdf0070e33f2f22e6fab797
# Parent  5bb1a7c466988c57ba224c9aa59b02c4e778b4bd
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
@@ -2443,6 +2443,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
@@ -1440,3 +1440,32 @@
   [255]
   $ hg prune 897e7966b9ef
   1 changesets pruned
+
+Check that fold respects the allowunstable option
+  $ cat >> $HGRCPATH <<EOF
+  > [experimental]
+  > evolution=createmarkers
+  > evolutioncommands=fold
+  > EOF
+  $ 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