evolve: fix selection of changeset to evolve from the middle of a stack (issue4434) stable
authorPierre-Yves David <pierre-yves.david@fb.com>
Tue, 11 Nov 2014 12:38:49 +0000
branchstable
changeset 1157 5951969400ce
parent 1156 0f53c24096c6
child 1158 0f6c97421cd9
child 1160 e29a813f6af5
evolve: fix selection of changeset to evolve from the middle of a stack (issue4434) The evolve algorithm picked a bad changesets to evolve (unstable changeset with no obsolete parent (but unstable parent). And then get confused assuming that is the first parent was not obsolete, the second should be. This changeset fixed the issue by preventing selection of direct descendant of [.] when evolving.
hgext/evolve.py
tests/test-evolve.t
--- a/hgext/evolve.py	Tue Nov 11 11:28:01 2014 +0000
+++ b/hgext/evolve.py	Tue Nov 11 12:38:49 2014 +0000
@@ -1191,7 +1191,6 @@
                     displayer.show(ctx)
 
                 if dryrunopt:
-                    print 'hg update %s' % ctx.rev()
                     return 0
                 else:
                     res = hg.update(repo, ctx.rev())
@@ -1303,9 +1302,12 @@
 
     # Look for an unstable which can be stabilized as a child of
     # node. The unstable must be a child of one of node predecessors.
+    directdesc = set([pctx.rev()])
     for ctx in selfanddescendants(repo, pctx):
         for child in ctx.children():
-            if child.unstable():
+            if ctx.rev() in directdesc and not child.obsolete():
+                directdesc.add(child.rev())
+            elif child.unstable():
                 return child
     return None
 
@@ -1314,9 +1316,7 @@
     """Stabilize a unstable changeset"""
     obs = orig.parents()[0]
     if not obs.obsolete():
-        print obs.rev(), orig.parents()
-        print orig.rev()
-        obs = orig.parents()[1]
+        obs = orig.parents()[1] # second parent is obsolete ?
     assert obs.obsolete()
     newer = obsolete.successorssets(repo, obs.node())
     # search of a parent which is not killed
--- a/tests/test-evolve.t	Tue Nov 11 11:28:01 2014 +0000
+++ b/tests/test-evolve.t	Tue Nov 11 12:38:49 2014 +0000
@@ -846,3 +846,17 @@
   |
   o  0 [default] a0
   
+
+Evolve from the middle of a stack pick the right changesets.
+
+  $ hg up 7
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg ci --amend -m 'a1__'
+  2 new unstable changesets
+
+  $ hg up 8
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg evolve
+  nothing to evolve here
+  (2 troubled changesets, do you want --any ?)
+  [2]