Page 1 of 1

3-way merges

PostPosted: Wed Oct 31, 2012 5:23 pm
by RobertGordon
While performing a merge from a branch into a trunk, one of my text files was in conflict. If I 'Edit conflict' the file, I only see two versions of the file: my local copy (Program.cs) and something called (Program.cs.merge-right.r22655).

I guess the left file (Program.cs) is my working copy of the trunk version, and the right file (Program.cs.merge-right.r22655) is the latest version in the branch that is being merged. Can someone verify this?

Why is this view not a 4 pane view showing the latest trunk version, a base version that is the common ancestor of the trunk and branch versions, the latest branch version, and the merged output file? Is that something that just isn't supported by Syncro SVN Client?

Since the built-in merge tool doesn't meet my needs, I played around with using an external tool for diffing and merging. Under Options->Preferences->Diff I can check the "Compare With External Application" and then specify which program to use and order how the ${ancestorFile} ${firstFile} ${secondFile} parameters are passed to it. This all seems great, until I looked up the arguments for p4merge, the external tool I wanted to use:
p4merge [options] left right
p4merge [options] [base] left right
p4merge [options] [base] left right [merge]
The order of arguments is different depending on if it is a simple 2-file diff vs a 3-way merge. Syncro SVN Client doesn't let me specify different argument orders for a 2-file diff vs a 3-way merge. I like many things about Syncro SVN Client, but if I can't properly set up my external diff/merge tool, then I can't use Syncro SVN Client.

Re: 3-way merges

PostPosted: Thu Nov 01, 2012 10:59 am
by Florin

Indeed, the left file is the one in your working copy (which is checked out from the trunk), and the right file is the revision of the branch which generates the conflict.

Syncro SVN Client does not have the support to present 4 files in a compare window. It only presents 2, but it is aware of both 2-way and 3-way merges.
If you compare your working copy file with the BASE revision (pristine), then it does a 2-way comparison (same if you compare two revisions from History view, for example). In the case of merge conflicts, it performs a 3-way comparison (working against base/common revision, right against base/common revision, and finally it matches changes from both sides).

Regarding the external tool, given the fact that the number of tools that can be used is unlimited and each can have different command-lines, the only solution I see is to create your own script as an intermediate step, and call it from Syncro SVN Client. It should receive only the files to be used for comparison.
Syncro SVN Client has:
  • ${first} as the working file (if comparing working file against other file/revision), or as a specific file revision (if comparing two revisions from History view, for example; the file's revision will be saved in a local temporary file);
  • ${second} as the file to compare against (which generates the conflict, or a second file's revision if comparing from History view, for example);
  • ${ancestor} as the one being the common revision of both. Depending on the compare cases (working against another version, merge case), it can be missing (not transmitted by SVN Client).

Now, your script should see how many arguments it receives.
If there are only two, use those as "left right" (the order is the same as the order in which you put ${first} and ${second} in the command line to be called by Syncro SVN Client). If there are three, the same applies - use the argument corresponding to ${ancestor} for [base].
A forth parameter is not given, but if [merge] is the file where the result should be saved, then it should be same as ${first}, since this should be the working copy file being in conflict.

Regarding the use of an external diff & merge tool, there is place for improvements and we have this scheduled for a future version, but the current support should be enough to solve most needs.

A last thing to have in sight is that, if you specify an external tool, all compares triggered by Syncro SVN Client (from every place of the application which allows comparing) will be forwarded to that external tool.

Best Regards,
Florin Avram
Syncro SVN Client Team