Question about internal:fail

Greg Ward greg-hg at gerg.ca
Thu Dec 1 19:35:19 CST 2011


On Thu, Dec 1, 2011 at 6:47 PM, Mike Meyer <mwm at mired.org> wrote:
>> The only reason I can think of is that you actually want to have a
>> tool to determine
>> the complete differences (or conflicts, as you might call them)
>> between the two "snapshots" you are merging to help you decide on how
>> to do a meaningful merge.
>
> Yes. I figured that would be an external merge tool to invoke via
> resolve.
>
>> If that's what you want, "hg diff 1 2", might help as it shows you the
>> differences
>> between the two snapshots. But I assume that's not exactly what you
>> are looking for,
>> you are looking for a kind of 3-way-diff between common base, r1 and
>> r2, correct?
>
> Right. I'm paranoid about merges. Not as paranoid as some, but
> apparently more so than most.

The more I read of this, the more I am convinced that you want a
completely different manifest merge algorithm. And I'm pretty sure you
can do what you want with an extension. Start in mercurial/merge.py.
Read manifestmerge() forwards, backwards, and sideways. Then roll up
your sleeves and see if you can write your own manifest merge
algorithm.

You might end up concocting a better way of doing dummy merges, incidentally.

Recall: the usual recipe for dummy merge is

  hg merge otherhead --tool internal:local
  hg revert --all -r .
  hg commit -m"dummy merge otherhead"

That's annoying because you still get asked "remote modified X which
local deleted", even though you want to keep all local changes. And
it's a two-step dance. Say your extension adds a --strategy option to
merge; I suspect the "local" strategy (presumably equivalent to "git
merge --strategy ours"?) would be easy to implement. Then dummy merges
would just be

  hg merge otherhead --strategy local
  hg commit -m"dummy merge otherhead"

No interactive questions, no need to revert. Nifty.

Bottom line: the separation between manifest merge and file merge can
be confusing, especially when combined with internal:local or
internal:other. But it has its benefits: you can replace manifest
merge without affecting file merge. And vice-versa of course, but that
has been part of Mercurial for ages.

Greg


More information about the Mercurial mailing list