hgext/evolve.py
changeset 1420 0b714c4ad9ff
parent 1419 b54524ae77c0
child 1421 8f18c7b3af14
--- 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):