# HG changeset patch # User Pierre-Yves David # Date 1415709529 0 # Node ID 5951969400cec1a513cb07ea4a10cd356ea769ea # Parent 0f53c24096c6c18699d54c6ea56a10fc33ed9ea6 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. diff -r 0f53c24096c6 -r 5951969400ce hgext/evolve.py --- 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 diff -r 0f53c24096c6 -r 5951969400ce tests/test-evolve.t --- 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]