[PATCH 1 of 4 evolve-ext] evolve: don't crash on singled out revisions

Laurent Charignon lcharignon at fb.com
Tue Jun 2 18:01:48 CDT 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1433186952 25200
#      Mon Jun 01 12:29:12 2015 -0700
# Node ID 9a20329fa7e7d62ad59053be9353ec1285023763
# Parent  69e5de3e6129185469c2cbf98383ac6d58260d0c
evolve: don't crash on singled out revisions

Before this patch, we were crashing on unsolvable revisions when using
evolve --rev. This patch removes the crash and prints a warning when we
encounter such revision.

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -1398,9 +1398,12 @@
                    progresscb=None):
     """Stabilize a unstable changeset"""
     obs = orig.parents()[0]
+    if not obs.obsolete() and len(orig.parents()) == 2:
+        obs = orig.parents()[1] # second parent is obsolete ?
+
     if not obs.obsolete():
-        obs = orig.parents()[1] # second parent is obsolete ?
-    assert obs.obsolete()
+        ui.warn("Cannot solve instability of %s, skipping\n" % orig)
+        return False
     newer = obsolete.successorssets(repo, obs.node())
     # search of a parent which is not killed
     while not newer or newer == [()]:
diff --git a/tests/test-evolve.t b/tests/test-evolve.t
--- a/tests/test-evolve.t
+++ b/tests/test-evolve.t
@@ -1027,5 +1027,44 @@
   |
   o  0	: a0 - test
   
+Check hg evolve --rev on singled out commit
 
 
+  $ hg up 19 -C
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ mkcommit j1
+  $ mkcommit j2
+  $ mkcommit j3
+  $ hg up .^^
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ echo "hello" > j4
+  $ hg add j4
+  $ hg amend
+  2 new unstable changesets
+  $ hg glog 
+  @  25	: add j1 - test
+  |
+  | o  23	: add j3 - test
+  | |
+  | o  22	: add j2 - test
+  | |
+  | x  21	: add j1 - test
+  |/
+  | o  20	: add gh - test
+  | |
+  o |  19	: add gg - test
+  |/
+  o  18	: a3 - test
+  |
+  o  13	: bumped update to f37ed7a60f43: - test
+  |
+  o  11	: a2 - test
+  |
+  o  10	testbookmark: a1__ - test
+  |
+  o  0	: a0 - test
+  
+
+  $ hg evolve --rev 23
+  Cannot solve instability of c70048fd3350, skipping
+


More information about the Mercurial-devel mailing list