[PATCH 2 of 4 evolve-ext] evolve: make uncommit respect allowunsable

Laurent Charignon lcharignon at fb.com
Thu Jun 4 13:52:15 CDT 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1432151173 25200
#      Wed May 20 12:46:13 2015 -0700
# Node ID 534f9500c108f4b953116de055ecfc99ae7a475f
# Parent  8f30edd12b336ecdaec68439d0a92085b6ed8340
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
@@ -2138,6 +2138,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
@@ -1079,6 +1079,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]
@@ -1116,3 +1117,52 @@
   (use "hg help" for the full list of commands or "hg -v" for details)
   [255]
 
+Check that uncommit respects the allowunstable option
+With only createmarkers we can only uncommit on a head
+  $ cat >> $HGRCPATH <<EOF
+  > [experimental]
+  > evolution=createmarkers
+  > evolutioncommands=uncommit
+  > EOF
+  $ glog
+  @  20:db3d894869b0 at default(draft) add gh
+  |
+  | o  19:10ffdd7e3cc9 at default(draft) add gg
+  |/
+  o  18:0bb66d4c1968 at default(draft) a3
+  |
+  o  13:d66b1e328488 at default(draft) bumped update to f37ed7a60f43:
+  |
+  o  11:f37ed7a60f43 at mybranch(public) a2
+  |
+  o  10:9f8b83c2e7f3 at default(public) a1__
+  |
+  o  0:07c1c36d9ef0 at default(public) a0
+  
+  $ 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 db3d894869b0
+  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 10ffdd7e3cc9 -C
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ glog
+  o  21:bb4ea90d7601 at default(draft) add gh
+  |
+  | @  19:10ffdd7e3cc9 at default(draft) add gg
+  |/
+  o  18:0bb66d4c1968 at default(draft) a3
+  |
+  o  13:d66b1e328488 at default(draft) bumped update to f37ed7a60f43:
+  |
+  o  11:f37ed7a60f43 at mybranch(public) a2
+  |
+  o  10:9f8b83c2e7f3 at default(public) a1__
+  |
+  o  0:07c1c36d9ef0 at default(public) a0
+  


More information about the Mercurial-devel mailing list