[PATCH 1 of 3 evolve-ext-V3] evolve: make uncommit respect allowunsable

Laurent Charignon lcharignon at fb.com
Mon Jun 15 17:30:12 UTC 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1432151173 25200
#      Wed May 20 12:46:13 2015 -0700
# Node ID c73aa260e157a1e5d534d3447d16664992a0e7a5
# Parent  5c13945b32fc4bcb4998a1bdd0b669ac43c26574
evolve: make uncommit respect allowunsable

Before this patch, the uncommit command was performing the same way regardless
of the value of experimental.evolution.
With this patch if the configuration does not allow unstability, uncommit won't
create instability.

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -2204,6 +2204,11 @@
             if ctx.p1() == rev or ctx.p2() == rev:
                 raise util.Abort(_("cannot uncommit to parent changeset"))
 
+        onahead = old.rev() in repo.changelog.headrevs()
+        disallowunstable = not obsolete.isenabled(repo, obsolete.allowunstableopt)
+        if disallowunstable and not onahead:
+            raise util.Abort(_("cannot uncommit in the middle of a stack"))
+
         # Recommit the filtered changeset
         tr = repo.transaction('uncommit')
         newid = None
diff --git a/tests/test-evolve.t b/tests/test-evolve.t
--- a/tests/test-evolve.t
+++ b/tests/test-evolve.t
@@ -1248,3 +1248,57 @@
   o  25:4c0bc042ef3b at default(draft) add j1
   |
 
+Check that uncommit respects the allowunstable option
+With only createmarkers we can only uncommit on a head
+  $ hg up 456e647fbe11
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cat >> $HGRCPATH <<EOF
+  > [experimental]
+  > evolution=createmarkers, allnewcommands
+  > EOF
+  $ glog -r "25::"
+  @  52:456e647fbe11 at default(draft) add c4_
+  |
+  o  51:07aaa06da467 at default(draft) add c3_
+  |
+  | o  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 up .^
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg uncommit --all
+  abort: cannot uncommit in the middle of a stack
+  [255]
+  $ hg up 456e647fbe11
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg uncommit --all
+  new changeset is empty
+  (use "hg prune ." to remove it)
+  $ hg up e543e9e71376 -C
+  3 files updated, 0 files merged, 3 files removed, 0 files unresolved
+  $ glog -r "25::"
+  o  53:897e7966b9ef at default(draft) add c4_
+  |
+  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
+  |


More information about the Mercurial-devel mailing list