patch versus 3-way merge for moved contents
Jan Hudec
bulb at ucw.cz
Fri Oct 28 10:33:59 BST 2005
On Thu, Oct 27, 2005 at 17:48:09 -0500, John A Meinel wrote:
> Sometimes, one of the advantages of patch is that it uses a local
> context to determine where the patch should be applied.
>
> The specific advantage I'm mentioning is if code has been moved (without
> being modified).
>
> For example if I had:
>
> int function2(int a, int b)
> {
> // do something
> // and then something else
> return 1;
> }
>
> int function1(int a)
> {
> // do something different
> // and return an integer
> return 2;
> }
>
>
> Then I realize that function1 should come before function2
> alphabetically, and rearrange the code.
> If someone then submitted patches which made corrections to both
> function1 and function2, it would be possible for patch to determine the
> correct location from context.
The downside is, that patch can go spectacularly wrong if the context matches
in more than one place by accident. I have actually seen patch to duplicate
a piece of code because of false match of context (when merging with tla).
> With diff3/3-way merge (and probably weave merge), these lines show up
> as a completely new set of lines, unrelated to the previous ones.
> (at least one set shows up that way).
>
> I don't know if that use case is worth doing anything about. But I
> thought I would mention it since I just thought about it.
The only solution I could see would be if the weave somehow recorded, that
the lines were swapped. However it is pretty hard to guess when that
happened.
--
Jan 'Bulb' Hudec <bulb at ucw.cz>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20051028/fcd75caf/attachment.pgp
More information about the bazaar
mailing list