How to Merge Conflicts by Selecting Lines from Both?
Asked Answered
V

1

10

I'm learning the use of version control (with Tortoise HG) so this question might be very basic, but I can't figure out how to solve it.

Suppose Branch A has a text file with the following:

A
B
C
D
E
F

Branch B has the same text file with:

A
B
3
4
E
F

When merging these two files with TortoiseHG, the merges are resolved with KDiff. Kdiff allows us to Select Lines from only one of the two. I want the Merged Code to contain lines from both like:

A
B
C
D
3
4
E
F

The order is not important. How do I solve the merge conflict in KDiff3 to get what I want?

This isn't an academic discussion. It is a simplified version of what is happening with code for a small Android application, where the XML files for Strings is edited in both Branches.

Ventura answered 28/6, 2013 at 9:56 Comment(0)
F
16

Actually quite simple, in kdiff3 you turn off the auto-advance, the button after the A B C set, then you go through the conflicts using the next conflict button, (immediately before A), and on each conflict you toggle A or B or A then B or B then A to get the desired result - you can even manually edit the file in the bottom pane if necessary.

Fivepenny answered 28/6, 2013 at 11:30 Comment(5)
I don't know why auto-advance is default. It seems to confuse much more than it helps.Arpent
There are three options to choose from. You are likely to need a combination of B and C rather than A and B.Arpent
As @SteveKaye mentioned, I had to select first B and then C, rather than A and then B. (These 'ABC' are the windows in Kdiff3, rather than the Branches). After that, the merge worked.Ventura
Not sure how to edit at the bottom pane. Only lets me choose between A,B, and C. There is no option to manually edit.Honeyed
Ah I figured it out. You have to choose 1 of the 3 before you are allowed to manually edit. Then, after choosing 1 of the 3 and manually editing, you can save the merge and move on to the next one.Honeyed

© 2022 - 2024 — McMap. All rights reserved.