comparison mercurial/merge.py @ 44383:218feb1a7e00

graft: always allow hg graft --base . (issue6248) `hg graft --base . -r abc` is rejected before this change with a "nothing to merge" error, if `abc` does not descend from `.`. This looks like an artifact of the implementation rather than intended behavior. It makes perfect sense to apply the diff between `.` and `abc` to the working copy (i.e. degenerate into `hg revert`), regardless of what `abc` is. Differential Revision: https://phab.mercurial-scm.org/D8127
author Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
date Mon, 17 Feb 2020 20:30:03 -0500
parents 9f8eddd2723f
children 5e3402a0b868
comparison
equal deleted inserted replaced
44382:f0027a3dd7cb 44383:218feb1a7e00
2652 # mergeancestor=True to update. This does two things: 1) allows the merge if 2652 # mergeancestor=True to update. This does two things: 1) allows the merge if
2653 # the destination is the same as the parent of the ctx (so we can use graft 2653 # the destination is the same as the parent of the ctx (so we can use graft
2654 # to copy commits), and 2) informs update that the incoming changes are 2654 # to copy commits), and 2) informs update that the incoming changes are
2655 # newer than the destination so it doesn't prompt about "remote changed foo 2655 # newer than the destination so it doesn't prompt about "remote changed foo
2656 # which local deleted". 2656 # which local deleted".
2657 # We also pass mergeancestor=True when base is the same revision as p1. 2)
2658 # doesn't matter as there can't possibly be conflicts, but 1) is necessary.
2657 wctx = wctx or repo[None] 2659 wctx = wctx or repo[None]
2658 pctx = wctx.p1() 2660 pctx = wctx.p1()
2659 base = base or ctx.p1() 2661 base = base or ctx.p1()
2660 mergeancestor = repo.changelog.isancestor(pctx.node(), ctx.node()) 2662 mergeancestor = (
2663 repo.changelog.isancestor(pctx.node(), ctx.node())
2664 or pctx.rev() == base.rev()
2665 )
2661 2666
2662 stats = update( 2667 stats = update(
2663 repo, 2668 repo,
2664 ctx.node(), 2669 ctx.node(),
2665 True, 2670 True,