Patchwork [2,of,2,evolve-ext-V4] evolve: make fold aware of allowunstable

login
register
mail settings
Submitter Laurent Charignon
Date June 17, 2015, 8:39 p.m.
Message ID <6decb0f06976226456e3.1434573581@lcharignon-mbp.dhcp.thefacebook.com>
Download mbox | patch
Permalink /patch/9698/
State Changes Requested
Delegated to: Pierre-Yves David
Headers show

Comments

Laurent Charignon - June 17, 2015, 8:39 p.m.
# HG changeset patch
# User Laurent Charignon <lcharignon@fb.com>
# Date 1432072589 25200
#      Tue May 19 14:56:29 2015 -0700
# Node ID 6decb0f06976226456e3a809bd2d4314f53634a8
# Parent  adb791429c95d8ca9df9fa427b97afae14ebfc6e
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.

Patch

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -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()
diff --git a/tests/test-evolve.t b/tests/test-evolve.t
--- a/tests/test-evolve.t
+++ b/tests/test-evolve.t
@@ -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