Mercurial > evolve
changeset 3529:d90e0faaec80
evolve: fix stabilization of orphan merge changesets in case of conflicts
As demonstrated by tests added in previous patch, if one of the parent of a
merge changeset has a new version and merge changeset gets, running `hg evolve`
to stabilize that if results in conflicts will lead to lose of other parent of
that merge changeset when we resolve conflicts and do `hg evolve --continue`.
This patch fixes the behavior, by checking whether we are continuing evolving a
merge changeset and if yes, setting the dirstate parents according to that.
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Tue, 13 Mar 2018 18:17:50 +0530 |
parents | 92f1e2408fd0 |
children | 3f056d3a1f70 |
files | hgext3rd/evolve/evolvecmd.py tests/test-evolve-orphan-merge.t |
diffstat | 2 files changed, 50 insertions(+), 51 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/evolvecmd.py Tue Mar 13 15:29:35 2018 +0530 +++ b/hgext3rd/evolve/evolvecmd.py Tue Mar 13 18:17:50 2018 +0530 @@ -1134,6 +1134,34 @@ targetphase = max(ctx.phase(), phases.draft) overrides = {('phases', 'new-commit'): targetphase} + ctxparents = orig.parents() + if len(ctxparents) == 2: + currentp1 = repo.dirstate.parents()[0] + p1obs = ctxparents[0].obsolete() + p2obs = ctxparents[1].obsolete() + # asumming that the parent of current wdir is successor of one + # of p1 or p2 of the original changeset + if p1obs and not p2obs: + # p1 is obsolete and p2 is not obsolete, current working + # directory parent should be successor of p1, so we should + # set dirstate parents to (succ of p1, p2) + with repo.dirstate.parentchange(): + repo.dirstate.setparents(currentp1, + ctxparents[1].node()) + elif p2obs and not p1obs: + # p2 is obsolete and p1 is not obsolete, current working + # directory parent should be successor of p2, so we should + # set dirstate parents to (succ of p2, p1) + with repo.dirstate.parentchange(): + repo.dirstate.setparents(currentp1, + ctxparents[0].node()) + + else: + # both the parents were obsolete, not sure what logic will + # required here + # XXX: add tests for this and see what is required here + pass + with repo.ui.configoverride(overrides, 'evolve-continue'): node = repo.commit(text=message, user=user, date=date, extra=extra)
--- a/tests/test-evolve-orphan-merge.t Tue Mar 13 15:29:35 2018 +0530 +++ b/tests/test-evolve-orphan-merge.t Tue Mar 13 18:17:50 2018 +0530 @@ -230,47 +230,10 @@ continue: hg evolve --continue $ hg evolve --continue evolving 10:fd41d25a3e90 "foobar to c" - working directory is now at 6b42180a13dd - -XXX: we lost the second parent here after interrupted evolve - $ hg glog - @ 12:6b42180a13dd foobar to c - | () draft - o 11:31c317b7bdb1 foo to c - | () draft - | o 9:d0f84b25d4e3 bar to c - |/ () draft - o 0:8fa14d15e168 added hgignore - () draft - - $ hg parents - changeset: 12:6b42180a13dd - tag: tip - user: test - date: Thu Jan 01 00:00:00 1970 +0000 - summary: foobar to c - -Getting back to a state from where we can test the same thing with obsoleting -the second parent - - $ hg prune -r . - 1 files updated, 0 files merged, 0 files removed, 0 files unresolved - working directory now at 31c317b7bdb1 - 1 changesets pruned - $ hg merge - merging c - warning: conflicts while merging c! (edit, then use 'hg resolve --mark') - 0 files updated, 0 files merged, 0 files removed, 1 files unresolved - use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon - [1] - - $ echo FOObar > c - $ hg resolve -m - (no more unresolved files) - $ hg commit -m "FOObar to c" + working directory is now at c5405d2da7a1 $ hg glog - @ 13:14ac829917d7 FOObar to c + @ 12:c5405d2da7a1 foobar to c |\ () draft | o 11:31c317b7bdb1 foo to c | | () draft @@ -279,6 +242,15 @@ o 0:8fa14d15e168 added hgignore () draft + $ hg parents + changeset: 12:c5405d2da7a1 + tag: tip + parent: 11:31c317b7bdb1 + parent: 9:d0f84b25d4e3 + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: foobar to c + Testing a conlficting merge with second parent obsoleted $ hg up 31c317b7bdb1 @@ -288,9 +260,9 @@ 1 new orphan changesets $ hg glog - @ 14:928097d0b5b5 foo to c + @ 13:928097d0b5b5 foo to c | () draft - | * 13:14ac829917d7 FOObar to c + | * 12:c5405d2da7a1 foobar to c | |\ () draft +---x 11:31c317b7bdb1 foo to c | | () draft @@ -300,8 +272,8 @@ () draft $ hg evolve --all - move:[13] FOObar to c - atop:[14] foo to c + move:[12] foobar to c + atop:[13] foo to c merging c warning: conflicts while merging c! (edit, then use 'hg resolve --mark') evolve failed! @@ -315,16 +287,15 @@ continue: hg evolve --continue $ hg evolve --continue - evolving 13:14ac829917d7 "FOObar to c" - working directory is now at 910c14950386 + evolving 12:c5405d2da7a1 "foobar to c" + working directory is now at dc1948a6eeab -XXX: we lost a parent here again. $ hg glog - @ 15:910c14950386 FOObar to c - | () draft - o 14:928097d0b5b5 foo to c - | () draft - | o 9:d0f84b25d4e3 bar to c + @ 14:dc1948a6eeab foobar to c + |\ () draft + | o 13:928097d0b5b5 foo to c + | | () draft + o | 9:d0f84b25d4e3 bar to c |/ () draft o 0:8fa14d15e168 added hgignore () draft