evolve: distinct between '--all' and '--all --any'
authorPierre-Yves David <pierre-yves.david@fb.com>
Mon, 22 Jun 2015 21:01:30 -0700
changeset 1422 c868a69c29c5
parent 1421 8f18c7b3af14
child 1423 ecd669c36c12
evolve: distinct between '--all' and '--all --any' Before this patch, evolve --all implied evolve --all --any. With this patch evolve --all evolves all the aspiring descendants of the parent of the working copy. evolve --all --any does what evolve --all did before: evolving all the troubles in the repo. We add anew function _aspiringdescendant for this purpose
README
hgext/evolve.py
tests/test-evolve-bumped.t
tests/test-evolve.t
tests/test-userguide.t
--- a/README	Tue Jun 23 00:02:23 2015 -0700
+++ b/README	Mon Jun 22 21:01:30 2015 -0700
@@ -61,6 +61,9 @@
           do as invocated.
 - evolve: bare `hg evolve` commands now abort when multiple changesets could be
           a target.
+- evolve: `hg evolve --all` only evolve changeset that will end up as
+          descendant of the current working copy. The old behavior of `--all`
+          in now in `--all --any`.
 
 5.1.5 --
 
--- 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"""
--- a/tests/test-evolve-bumped.t	Tue Jun 23 00:02:23 2015 -0700
+++ b/tests/test-evolve-bumped.t	Mon Jun 22 21:01:30 2015 -0700
@@ -69,7 +69,7 @@
   no changes found
   1 new bumped changesets
 
-  $ hg evolve -a --bumped
+  $ hg evolve -a -A --bumped
   recreate:[2] tweak a
   atop:[1] modify a
   computing new diff
--- a/tests/test-evolve.t	Tue Jun 23 00:02:23 2015 -0700
+++ b/tests/test-evolve.t	Mon Jun 22 21:01:30 2015 -0700
@@ -919,6 +919,17 @@
 
   $ hg up 8
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg log -G --template '{rev} [{branch}] {desc|firstline}\n'
+  o  10 [default] a1__
+  |
+  | o  9 [mybranch] a3
+  | |
+  | @  8 [mybranch] a2
+  | |
+  | x  7 [default] a1_
+  |/
+  o  0 [default] a0
+  
   $ hg evolve
   nothing to evolve on current working copy parent
   (2 other unstable in the repository, do you want --any or --rev)
@@ -1156,7 +1167,13 @@
 Check that prune respects the allowunstable option
   $ hg up -C .
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg evolve --rev "22::"
+  $ hg up 20
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg evolve --all
+  nothing to evolve on current working copy parent
+  (2 other unstable in the repository, do you want --any or --rev)
+  [2]
+  $ hg evolve --all --any
   move:[22] add j2
   atop:[26] add j1
   move:[23] add j3
--- a/tests/test-userguide.t	Tue Jun 23 00:02:23 2015 -0700
+++ b/tests/test-userguide.t	Mon Jun 22 21:01:30 2015 -0700
@@ -219,7 +219,7 @@
   |
   o  18:1f33e68b18b9  draft  useful work
   |
-  $ hg evolve -q --all
+  $ hg evolve -q --all --any
   $ hg --hidden shortlog -G -r 18::
   @  21:4393e5877437  draft  more work
   |
@@ -251,7 +251,7 @@
   $ hg status
   M file2.c
   $ hg revert file2.c
-  $ hg evolve --all
+  $ hg evolve --all --any
   move:[23] fix bug 67
   atop:[24] fix bug 53
   working directory is now at 0d972d6888e6
@@ -300,7 +300,7 @@
   |/
   o  25:0d972d6888e6  draft  fix bug 67
   |
-  $ hg evolve --all
+  $ hg evolve --all --any
   move:[27] new feature
   atop:[28] fix a bug
   working directory is now at 166c1c368ab6