hgext/evolve.py
changeset 1422 c868a69c29c5
parent 1421 8f18c7b3af14
child 1423 ecd669c36c12
--- a/hgext/evolve.py	Tue Jun 23 00:02:23 2015 -0700
+++ b/hgext/evolve.py	Mon Jun 22 21:01:30 2015 -0700
@@ -1291,7 +1291,7 @@
             if othertroubles:
                 hint = hintmap['+'.join(othertroubles)]
 
-    elif allopt or anyopt:
+    elif anyopt:
         msg = _("no %s changesets to evolve") % targetcat
         othertroubles = []
         for cat in unselectedcategories:
@@ -1407,6 +1407,8 @@
         revs = repo.revs(targetcat+'()')
         if revopt:
             revs = scmutil.revrange(repo, revopt) & revs
+        elif not anyopt and targetcat == 'unstable':
+            revs = set(_aspiringdescendant(repo, repo.revs('(.::) - obsolete()::')))
     elif anyopt:
         revs = repo.revs('first(%s())' % (targetcat))
     elif targetcat == 'unstable':
@@ -1466,8 +1468,8 @@
     ('', 'bumped', False, 'solves only bumped changesets'),
     ('', 'divergent', False, 'solves only divergent changesets'),
     ('', 'unstable', False, 'solves only unstable changesets (default)'),
-    ('a', 'all', False, 'evolve all troubled changesets in the repo '
-                        '(implies any)'),
+    ('a', 'all', False, 'evolve all troubled changesets related to the current '
+                         'working directory and its descendants'),
     ('c', 'continue', False, 'continue an interrupted evolution'),
     ] + mergetoolopts,
     _('[OPTIONS]...'))
@@ -1488,6 +1490,9 @@
     will result in a new children for the current working copy parent or its
     descendants. The working copy will be updated on the result
     (this last behavior will most likely to change in the future).
+    You can evolve all the unstable changesets that will be evolved on the
+    parent of the working copy and all its descendants recursively by using
+    :hg:`evolve` --all.
 
     You can decide to evolve other categories of trouble using the --divergent
     and --bumped flags. If no other option are specified, this will try to
@@ -1498,7 +1503,7 @@
     repo using --any.
 
     You can evolve all the changesets affected by troubles of the selected
-    category using --all.
+    category using --all --any.
 
     The working directory is updated to the newly created revision.
     """
@@ -1622,6 +1627,17 @@
             result.append(r)
     return result
 
+def _aspiringdescendant(repo, revs):
+    """Return a list of changectx which can be stabilized on top of pctx or
+    one of its descendants recursively. Empty list if none can be found."""
+    target = set(revs)
+    result = set(target)
+    sizeresult = 0
+    while sizeresult != len(result):
+        sizeresult = len(result)
+        result.update(_aspiringchildren(repo, result))
+    return sorted(result - target)
+
 def _solveunstable(ui, repo, orig, dryrun=False, confirm=False,
                    progresscb=None):
     """Stabilize a unstable changeset"""