evolve: don't crash on singled out revisions
authorLaurent Charignon <lcharignon@fb.com>
Mon, 01 Jun 2015 12:29:12 -0700
changeset 1354 b4a62d6f0353
parent 1353 935508184d47
child 1355 5b66cff0e470
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.
hgext/evolve.py
tests/test-evolve.t
--- a/hgext/evolve.py	Mon Jun 01 10:58:50 2015 -0700
+++ b/hgext/evolve.py	Mon Jun 01 12:29:12 2015 -0700
@@ -1398,9 +1398,12 @@
                    progresscb=None):
     """Stabilize a unstable changeset"""
     obs = orig.parents()[0]
-    if not obs.obsolete():
+    if not obs.obsolete() and len(orig.parents()) == 2:
         obs = orig.parents()[1] # second parent is obsolete ?
-    assert obs.obsolete()
+
+    if not 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 == [()]:
--- a/tests/test-evolve.t	Mon Jun 01 10:58:50 2015 -0700
+++ b/tests/test-evolve.t	Mon Jun 01 12:29:12 2015 -0700
@@ -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 log -G
+  @  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
+