diff hgext/evolve.py @ 1420:0b714c4ad9ff

evolve: consider all potential candidates on bare evolve Instead of stopping at the first resolution, we returns all matches. If there is ambiguity, we abort. The function itself seems fairly flawed but will do the job in simple case.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 22 Jun 2015 19:24:21 -0700
parents b54524ae77c0
children 8f18c7b3af14
line wrap: on
line diff
--- a/hgext/evolve.py	Tue Jun 23 13:20:00 2015 -0700
+++ b/hgext/evolve.py	Mon Jun 22 19:24:21 2015 -0700
@@ -1410,9 +1410,12 @@
     elif anyopt:
         revs = repo.revs('first(%s())' % (targetcat))
     elif targetcat == 'unstable':
-        tro = _stabilizableunstable(repo, repo['.'])
-        if tro is not None:
-            revs = set([tro])
+        revs = set(_aspiringchildren(repo, repo['.']))
+        if 1 < len(revs):
+            msg = "multiple evolve candidates"
+            hint = (_("select one of %s with --rev")
+                    % ', '.join([str(repo[r]) for r in sorted(revs)]))
+            raise error.Abort(msg, hint=hint)
     elif targetcat in repo['.'].troubles():
         revs = set([repo['.'].rev()])
     return revs
@@ -1586,10 +1589,9 @@
     progresscb()
     _cleanup(ui, repo, startnode, showprogress)
 
-def _stabilizableunstable(repo, pctx):
-    """Return a changectx for an unstable changeset which can be
-    stabilized on top of pctx or one of its descendants. None if none
-    can be found.
+def _aspiringchildren(repo, pctx):
+    """Return a list of changectx which can be stabilized on top of pctx or
+    one of its descendants. Empty list if none can be found.
     """
     def selfanddescendants(repo, pctx):
         yield pctx
@@ -1602,14 +1604,15 @@
 
     # Look for an unstable which can be stabilized as a child of
     # node. The unstable must be a child of one of node predecessors.
+    result = []
     directdesc = set([pctx.rev()])
     for ctx in selfanddescendants(repo, pctx):
         for child in ctx.children():
             if ctx.rev() in directdesc and not child.obsolete():
                 directdesc.add(child.rev())
             elif child.unstable():
-                return child
-    return None
+                result.append(child)
+    return result
 
 def _solveunstable(ui, repo, orig, dryrun=False, confirm=False,
                    progresscb=None):