Patchwork [4,of,6,evolve-ext-V2] evolve: make uncommit respect allowunsable

login
register
mail settings
Submitter Laurent Charignon
Date June 4, 2015, 11:09 p.m.
Message ID <eb63b8ee80f4d9de5dc6.1433459359@lcharignon-mbp.local>
Download mbox | patch
Permalink /patch/9496/
State Changes Requested
Headers show

Comments

Laurent Charignon - June 4, 2015, 11:09 p.m.
# HG changeset patch
# User Laurent Charignon <lcharignon@fb.com>
# Date 1432151173 25200
#      Wed May 20 12:46:13 2015 -0700
# Node ID eb63b8ee80f4d9de5dc61aef279cf3e46a0784f3
# Parent  bbe6b4b57f1bb6d7ca29a3a6ffc5618c41c3a6fe
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.

Patch

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -2225,6 +2225,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
@@ -1097,6 +1097,7 @@ 
   
   (use "hg help" for the full list of commands or "hg -v" for details)
   [255]
+
 Enabling commands selectively, only fold enabled, next is still unknown
   $ cat >> $HGRCPATH <<EOF
   > [experimental]
@@ -1372,3 +1373,58 @@ 
   o  25:4c0bc042ef3b@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
+  > evolutioncommands=uncommit
+  > EOF
+  $ glog -r "25::"
+  @  52:456e647fbe11@default(draft) add c4_
+  |
+  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 .^
+  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@default(draft) add c4_
+  |
+  o  51:07aaa06da467@default(draft) add c3_
+  |
+  | @  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
+  |