Commit 1a56aea7 authored by Pierre-Yves David's avatar Pierre-Yves David 🐙

merge: respect parents order when using `graft` on a merge

The previous code did not record the index of the replaced parent. It was always
using the "graft" destination as `p1`. This could switch parents order in some
situation (eg: some of the evolve evolving merge case). Recording and using the
information fixes the issue in evolve.

We are not aware of core commands calling graft in that fashion, so we could not
build a simple test case for it using core commands.

--HG--
branch : stable
parent 344a086bb764
......@@ -2249,17 +2249,23 @@ def graft(repo, ctx, pctx, labels=None, keepparent=False,
mergeancestor=mergeancestor, labels=labels)
potherp1 = False
if keepconflictparent and stats.unresolvedcount:
pother = ctx.node()
else:
pother = nullid
parents = ctx.parents()
if keepparent and len(parents) == 2 and pctx in parents:
if pctx == parents[0]:
potherp1 = True
parents.remove(pctx)
pother = parents[0].node()
with repo.dirstate.parentchange():
repo.setparents(repo['.'].node(), pother)
if potherp1:
repo.setparents(pother, repo['.'].node())
else:
repo.setparents(repo['.'].node(), pother)
repo.dirstate.write(repo.currenttransaction())
# fix up dirstate for copies and renames
copies.duplicatecopies(repo, repo[None], ctx.rev(), pctx.rev())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment