evolve: skip unstable changesets with multiple successorssets
authorLaurent Charignon <lcharignon@fb.com>
Tue, 16 Jun 2015 17:56:23 -0700
changeset 1408 b3afdc0815d0
parent 1407 552687eb4856
child 1409 3276730e4b32
evolve: skip unstable changesets with multiple successorssets We were previously crashing when encountering them, but we want to be able to solve the other solvable troubles instead of stopping right there.
hgext/evolve.py
tests/test-evolve-order.t
--- a/hgext/evolve.py	Fri Jun 19 14:18:45 2015 -0700
+++ b/hgext/evolve.py	Tue Jun 16 17:56:23 2015 -0700
@@ -1260,6 +1260,16 @@
     if repo['.'] != startnode:
         ui.status(_('working directory is now at %s\n') % repo['.'])
 
+class MultipleSuccessorsError(RuntimeError):
+    """Exception raised by _singlesuccessor when multiple sucessors sets exists
+
+    The object contains the list of successorssets in its 'successorssets'
+    attribute to call to easily recover.
+    """
+
+    def __init__(self, successorssets):
+        self.successorssets = successorssets
+
 def _singlesuccessor(repo, p):
     """returns p (as rev) if not obsolete or its unique latest successors
 
@@ -1278,7 +1288,8 @@
         obs = obs.parents()[0]
         newer = obsolete.successorssets(repo, obs.node())
     if len(newer) > 1:
-        raise util.Abort(_("conflict rewriting. can't choose destination\n"))
+        raise MultipleSuccessorsError(newer)
+
     return repo[newer[0][0]].rev()
 
 def builddependencies(repo, revs):
@@ -1296,7 +1307,10 @@
     for r in revs:
         dependencies[r] = set()
         for p in repo[r].parents():
-            succ = _singlesuccessor(repo, p)
+            try:
+                succ = _singlesuccessor(repo, p)
+            except MultipleSuccessorsError, exc:
+                dependencies[r] = exc.successorssets
             if succ in revs:
                 dependencies[r].add(succ)
                 rdependencies[succ].add(r)
--- a/tests/test-evolve-order.t	Fri Jun 19 14:18:45 2015 -0700
+++ b/tests/test-evolve-order.t	Tue Jun 16 17:56:23 2015 -0700
@@ -233,5 +233,30 @@
   o  15:225d2cc5d3fc@default(draft) add _d
   |
 
+Test multiple revision with some un-evolvable because parent is splitted
+------------------------------------------------------------------------
 
+  $ hg up 'desc(c2prime)'
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ mkcommit c3part1
+  created new head
+  $ hg prev
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  [29] add c2prime
+  $ mkcommit c3part2
+  created new head
+  $ hg prune -s 'desc(c3part1)' 'desc(c3_)'
+  1 changesets pruned
+  1 new unstable changesets
+  $ hg prune -s 'desc(c3part2)' 'desc(c3_)'
+  1 changesets pruned
+  2 new divergent changesets
+  $ hg up 'desc(b3prime)'
+  2 files updated, 0 files merged, 3 files removed, 0 files unresolved
+  $ hg amend -m 'b3second'
+  1 new unstable changesets
+  $ hg evolve --rev 'unstable()'
+  move:[30] add b4_
+  atop:[35] b3second
+  working directory is now at a51a8a82fdba