Discussion about merging
Aaron Bentley
aaron.bentley at utoronto.ca
Sat Jun 4 18:48:11 BST 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
David Allouche wrote:
> And I have found no explanation as to why cherrypicks _have_ to be
> handled specially.
>
> I understand that Codeville merging makes that irrelevant, but it annoys
> me a bit that this question stands unanswered.
Practically speaking, because it will produce more conflicts than you'd
get otherwise. To consider a pathological case:
A, B and C are lines of development, derived ultimately from D.
A commits a whitespace change that no one wants, like changing all the
line endings to \r\n (called "the changes introduced by A-1")
A commits a useful change to a file that already had \r\n line endings.
(called "the changes introduced by A-2")
B cherry-picks the changes introduced by A-2.
C cherry-picks the changes introduced by A-2.
C merges B. If A-2 is selected as a base, we have a problem: note that
we're no longer talking about "the changes introduced by A-2", we're
talking about the snapshot A-2 itself. And most of the text of A-2 is
gratuitously different from both C and B.
So for cases where C and B and have the same text, the three-way merge
algorithm will work properly. But for cases where C and B have
differing text, and that text was also changed in A-1 (because almost
everything was changed in A-1), you'll get conflicts. However, in many
cases, only B or C has made a real change. If you had a better base,
you'd see that B was exactly the same as BASE, so the text of C should
be taken (or vice versa).
In essence, one of the assumptions of three-way merge is that any
difference between THIS and BASE represents a change introduced by THIS.
Similarly it assumes that a difference between OTHER and BASE
represents a change introduced by OTHER.
When you cherry-pick, there are more differences than that. Now the
difference between THIS and BASE may be a change introduced by THIS, or
it may be a change introduced by BASE that was not picked up by THIS.
So what about rejects? Let's say B and C each did a complete merge of
A-2 and committed. Then they reversed the textual changes of A-1 and
committed again. Now when they try to merge each other, it's legitimate
that they get conflicts galore, because they really did both change the
text that was introduced by A-1 into different things.
I can get more theoretical than this, if you'd like. I don't guarantee
the results will be comprehensible, though. :-)
Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFCoelb0F+nu1YWqI0RAsfwAKCDq7p8s/BcnpntIySZGWvo38hUrQCeJ3Qr
dnrX7JSub3NUdHIn5Nxb+gI=
=VXGy
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list