diff/merge configuration in Team Foundation - common Command and Argument values
One of the extensibility points we have in Team Foundation V1 is that you can configure any other diff and merge tools you want. The purpose of this article is to start collecting the most common ones we know or heard about in a central place so people don't have to figure these out on their own. This UI is available via tools -> options -> source control -> visual studio team foundation server -> "configure user tools" button or via the command-line with "tf diff /configure"
For additional background, try to remember that there are 2 operations that both involve "merge", so we on the TFVC team have tried to use 2 different terms to help clarify which operation is being talked about.
First, there is "tree merge", which you do via the Merge Wizard in the UI or via the "tf merge" command from the command-line. This operation brings over changesets (or parts of them) from one branch into another (or, in the case of /discard, communicates that you don't want them brought over). Many times those changes will just "come over" - the target will have the changes pended on them and you'll be free to check them in with no manual intervention needed.
Second is "content merge", the operation where you take changes inside an individual file and merge them together to make a final output. This is typically needed when the changes are such that they won't automatically merge together (2 users both changing the same line of a file, for instance), but that's not a requirement.
With this in mind, try to remember that what you're really configuring here is diff and "content merge" tools - the "tree merge" operations are done by TF, the extensibility here is the tool being used for content merging individual files.
We use the SourceSafe-style syntax for argument passing. We don't cover this on our doc page about configuring these diff tools, but these are what the argument parameters mean. Note that we're already adding double-quotes around the parameters (since most of the time, there's at least one temp file involved, at the path to that typically has spaces in it), so you typically don't need to add your own quoting.
- %1 = Original file (in diff, the pre-changes file, in merge, the "server" or "theirs" file, the file that is the base file after "their" changes were applied)
- %2 = Modified file (in diff, the post-changes file, in merge the "yours" file - the base file with "your" changes applied)
- %3 = Base file (in the 3-way merge operation, the file which both "theirs" and "yours" are derived from - the common ancestor. This doesn't mean it's the version the changes were based from, since this may be a cherry-pick merge)
- %4 = Merged file (The output file for the merge operation - the filename that the merge tool should write to)
- %5 = Diff options (any additional command-line options you want to pass to your diff tool - this comes into play only when using "tf diff /options" from the command-line)
- %6 = Original file label (The label for the %1 file)
- %7 = Modified file label (The label for the %2 file)
- %8 = Base file label (The label for the %3 file)
- %9 = Merged file label (The label for the %4 file)
Here are the values we've come up with for various tools. If you have additions/corrections, please email me: jmanning at microsoft.com. I'm keeping these as separate tables since you typically think about configuring either one or the other at a given time.
Compare tools
Product
Command
Arguments
TFS default
diffmerge.exe
%1 %2 %6 %7 %5 /ignorespace
WinDiff
windiff.exe
%1 %2
DiffDoc (for Word files)
DiffDoc.exe
/M%1 /S%2
WinMerge
winmerge.exe
/ub /dl %6 /dr %7 %1 %2
Beyond Compare
bc2.exe
%1 %2 /title1=%6 /title2=%7
KDiff3
kdiff3.exe
%1 --fname %6 %2 --fname %7
Araxis
compare.exe
/wait /2 /title1:%6 /title2:%7 %1 %2
Compare It!
Wincmp3.exe
%1 /=%6 %2 /=%7
SourceGear DiffMerge
DiffMerge.exe
/title1=%6 /title2=%7 %1 %2
Beyond Compare 3
BComp.exe
%1 %2 /title1=%6 /title2=%7
TortoiseMerge
TortoiseMerge.exe
/base:%1 /mine:%2 /basename:%6 /minename:%7
Visual SlickEdit
win\vsdiff.exe
%1 %2
Merge tools
Product
Command
Arguments
TFS default
diffmerge.exe
/merge %1 %2 %3 %4 %6 %7
KDiff3
kdiff3.exe
%3 --fname %8 %2 --fname %7 %1 --fname %6 -o %4
Visual SourceSafe
ssexp.exe
/merge %1 %2 %3 %4 %6 %7
Araxis
compare.exe
/wait /swap /a3 /3 /title1:%6 /title2:%7 /title3:%8 %1 %2 %3 %4
Beyond Compare (2-way merge)
bc2.exe
%1 %2 /savetarget=%4 /title1=%6 /title2=%7
WinMerge (2-way merge)
winmerge.exe
/ub /dl %6 /dr %7 %1 %2 %4
Guiffy
guiffy.exe
-s -h1%6 -h2%7 -hm%9 %1 %2 %3 %4
Ellie Computing
guimerge.exe
--mode=merge3 %3 %1 %2 --to=%4 --title0=%8 --title1=%6 --title2=%7 --to-title=%9
SourceGear DiffMerge
DiffMerge.exe
/title1=%6 /title2=%8 /title3=%7 /result=%4 %1 %3 %2
Beyond Compare 3
BComp.exe
%1 %2 %3 %4 /title1=%6 /title2=%7 /title3=%8 /title4=%9
TortoiseMerge
TortoiseMerge.exe
/base:%3 /mine:%2 /theirs:%1 /basename:%8 /minename:%7 /theirsname:%6 /merged:%4 /mergedname:%9
Visual SlickEdit
win\vsmerge.exe
%3 %1 %2 %4
Published Monday, February 20, 2006 11:49 AM by jmanning 








http://blogs.msdn.com/jmanning/articles/535573.aspx
Using Beyond Compare with Version Control Systems
Beyond Compare can be configured as the external difference utility in many popular VCS applications. The following are configuration instructions for specific products. Let us know if you have one to add to the list.
Beyond Compare v3: These examples are based on Beyond Compare 3
Beyond Compare v2: To use Beyond Compare 2 replace BComp.exe with BC2.exe and change the path to Beyond Compare 2's install folder.
Visual Studio 2008 - Open Visual Studio.
- Select AnkhSVN from the Tools menu.
- Select Edit the AnkhSVN Configuration.
- In the DiffExePath box, enter the following:
"C:\Program Files\Beyond Compare 3\BComp.exe" "%base" "%mine" /fv /title1="%base" /title2="%mine" /leftreadonly
Visual Studio 2005 - Open Visual Studio.
- Select Tools from the Options menu.
- Under Source Control click on Subversion.
- In the External diff path box, enter the following:
"C:\Program Files\Beyond Compare 3\BComp.exe" "%base" "%mine" /fv /title1="%base" /title2="%mine" /leftreadonly
- Open the Workbench.
- Select Options from the Tools menu.
- Switch to the Merge Tool tab in the Options dialog.
- Select "Beyond Compare" in the ToolName drop-down.
- Enter the complete path to your BComp.exe in the Compare, 2-way Merge, and 3-way Merge fields.
Compare
BComp.exe /readonly $(File1) $(File2)
2-way Merge
BComp.exe $(TrunkFile) $(BranchFile) /mergeoutput=$(ResultsFile)
3-way Merge (v3 Pro)
BComp.exe $(TrunkFile) $(BranchFile) $(AncestorFile) $(ResultsFile)
- Go into the "C:\Program Files\Rational\ClearCase\lib\mgrs" folder.
- Create a backup of the file named "map".
- Edit "map" and edit the following lines to point to Beyond Compare:
text_file_delta compare C:\Program Files\Beyond Compare 3\BComp.exe
text_file_delta xcompare C:\Program Files\Beyond Compare 3\BComp.exe
text_file_delta merge C:\Program Files\Beyond Compare 3\BComp.exe
text_file_delta xmerge C:\Program Files\Beyond Compare 3\BComp.exe
Make the same change to lines beginning with _html, _xml, _html2, _xml2 to use Beyond Compare for HTML and XML comparisons.
To use Beyond Compare 2, only change the xcompare line of the map file. Overriding compare, merge, and xmerge is not supported. A helper that improves BC2's support is available here.
Visit Reliable Software for details on using Beyond Compare with Code Co-op. Reliable Software offers a discounted bundle of the two products.
- Choose Settings from the Document Explorer's Project menu.
- Switch to the File Types tab.
- Click the Default button.
- Change the Difference Analysis Tool to "Custom Tool".
- Enter the path to BComp.exe in the Difference Analysis Tool edit.
CVS does not support external diff or merge tools.
BC version 3:
- Navigate to the Dimensions / PVCS install folder and find the file
pvcsmerge.exe and rename it to pvcsmerge.exe.exe. - Copy
bcomp.exe from C:\Program Files\Beyond Compare 3 into the Dimensions folder and rename it to pvcsmerge.exe.
In Dimensions CM 10 you can edit your native.properties file instead. The integration isn't as complete in that case, so file format/rules matching don't work correctly and folder comparisons aren't supported.
BC version 2:
Follow the instructions above, but instead of using BComp.exe use the copy of pvcsmerge.exe in pvcsmergev8.zip for PVCS 6.8, 8.0, and Merant Dimensions 8, or in pvcsmerge75.zip for PVCS 7.5.
Launch Beyond Compare from the
Eclipse IDE using the
Beyond CVS plug-in by Chris Callandar and Nick Boldt.
- Choose Properties in the Project Manager's Options menu.
- Switch to the Compare Tools panel.
- Click the Add Custom button.
- Enter "Beyond Compare" as the new name.
- Click the Edit button.
- Enter the path to BComp.exe in the File compare utility edit.
- Enter %1 %2 in the Command line parameter string edit.
Diff
- Create a shell script file "git-diff-wrapper.sh" with the following content:
#!/bin/sh
# diff is called by git with 7 parameters:
# path old-file old-hex old-mode new-file new-hex new-mode
"<path_to_bc3_executable>" "$2" "$5" | cat
- In a console window enter the command:
$ git config --global diff.external <path_to_wrapper_script>
3-Way Merge (v3 Pro)
In a console window enter the following three commands:
$ git config --global merge.tool bc3
$ git config --global mergetool.bc3.cmd "`which bcompare` '\$LOCAL'
'\$REMOTE' '\$BASE' '\$MERGED'"
$ git config --global mergetool.bc3.trustExitCode true
2-Way Merge (v3 Std, v2)
In a console window enter the following three commands:
$ git config --global merge.tool bc3
$ git config --global mergetool.bc3.cmd "`which bcompare` '\$LOCAL'
'\$REMOTE' -savetarget='\$MERGED'"
$ git config --global mergetool.bc3.trustExitCode true
Diff
- In Visual Studio Choose Options from the File menu.
- Expand Source Control in the treeview.
- Click Visual Studio Team Foundation Server in the treeview.
- Click the Configure User Tools button.
- Click the Add button.
- Enter ".*" in the Extension edit.
- Choose Compare in the Operation combobox.
- Enter the path to BComp.exe in the Command edit.
- In the Arguments edit, use:
%1 %2 /title1=%6 /title2=%7
3-Way Merge (v3 Pro)
- Follow steps 1-6 above.
- Choose Merge in the Operation combobox.
- Enter the path to BComp.exe in the Command edit.
- In the Arguments edit, use:
%1 %2 %3 %4 /title1=%6 /title2=%7 /title3=%8 /title4=%9
2-Way Merge (v3 Std, v2)
Use the same steps as the 3-way merge above, but use the command line:
%1 %2 /savetarget=%4 /title1=%6 /title2=%7
Supported for "Microsoft Visual SourceSafe" plug-in. The "Microsoft Visual SourceSafe (Internet)" plug-in does not support external diff tools.
- Open Visual Studio 2005.
- Select Options from the Tools menu.
- Select Plug-In Settings under the Source Control branch of the left-side tree control.
- Select Visual SourceSafe under Plug-In Settings on the right-hand pane.
- Press the Advanced button.
- Select the Custom Editor tab in the "SourceSafe Options" pane.
- Select File Difference in the Operation drop-down.
- Enter ".*" in the File Extension edit.
- Enter this in the Command Line edit:
"C:\Program Files\Beyond Compare 3\bcomp.exe" %1 %2 - Click the Add button and close all dialog boxes.
Diff
- Start MKS Source Integrity.
- Go to Tools | Preferences | DiffTool.
- Select Custom Command.
- Enter the command:
"C:\Program Files\Beyond Compare 3\BComp.exe" /title1="{1}" /title2="{2}" "{3}" "{4}"
3-Way Merge (v3 Pro)
Use this for the merge tool command line:
"C:\Program Files\Beyond Compare 3\BComp.exe" /title1="{1}" /title2="{2}" /title3="{0}" "{5}" "{6}" "{4}" "{7}" 2-Way Merge (v3 Std, v2)
Use this for the merge tool command line:
"C:\Program Files\Beyond Compare 3\BComp.exe" /title1="{1}" /title2="{2}" "{5}" "{6}" /savetarget="{7}"
P4V (The Perforce Visual Client) - Choose Preferences... from the Edit menu.
- Switch to the Diff tab.
- Change the Default Diff Application option to "Other application".
- Enter the path to BComp.exe in the Location edit.
- Switch to the Merge tab.
- Change the Default merge application to "Other application".
- Enter the path to BComp.exe in the Location edit.
- In the Arguments edit, enter:
%1 %2 %b %r /lefttitle="%T" /righttitle="%Y"
- Choose Preferences from the Admin menu.
- Switch to the Utilities tab.
- Enter the path to BComp.exe in the Visual Compare Utility Command Line edit, followed by "%s" "%s". For example:
C:\Progra~1\Beyond~1\BComp.exe "%s" "%s"
- Go into the "C:\Program Files\RoundTable\rtb\p" folder.
- Create a backup of the file named "Rtb_vcom.p".
- Edit "Rtb_vcom.p" and change the line:
ASSIGN Mexe = SEARCH("visdiff/visdiff.exe").
to:
ASSIGN Mexe = SEARCH("C:\Progra~1\Beyond~1\bcomp.exe").
- Select Tools | Options. Go to the External Programs tab.
- Application for diff/merge:
c:\program files\beyond compare 3\bcomp.exe - Arguments for diff files:
/readonly /title1="%FIRST_LABEL%" /title2="%SECOND_LABEL%" "%FIRST_FILE%" "%SECOND_FILE%" - Arguments for diff folders:
"%FIRST_DIR%" "%SECOND_DIR%" - Arguments for Two-way merge:
/leftreadonly /title1="%FIRST_LABEL%" /title2="%SECOND_LABEL%" "%FIRST_FILE%" "%SECOND_FILE%"
- Choose Options from the Windows Client's Tools menu.
- Switch to the External Programs panel.
- Enter the path to BComp.exe in the Application for comparing files, Application for comparing folders and Application for merging files edits.
Beyond Compare 1.9 is the default external difference utility in SourceOffsite Collaborative Edition. To upgrade to Beyond Compare 3 follow the instructions above.
Diff
- Choose Personal Options from the Tools menu.
- Switch to the Files panel.
- If it's present, click the "Alternate Applications..." button.
- Check the Comparison Utility checkbox.
- Enter the path to BComp.exe in the edit.
- In the Options edit enter:
$file1 $file2
3-Way Merge (v3 Pro)
- Follow steps 1-5 above, but check the Merge Utility checkbox in step 4.
- In the Options edit enter:
$usertip $branchtip $basefile /mergeoutput=$resultfile
2-Way Merge (v3 Std, v2)
Use the same steps as the 3-way merge above, but use the options:
$usertip $branchtip /savetarget=$resultfile
Windows - Go into the Beyond Compare installation folder (eg, C:\Program Files\Beyond Compare 3).
- Create a batch file named "svn.bat" with one line:
"C:\Progra~1\Beyond~1\bcomp.exe" "%6" /title1=%3 "%7" /title2=%5 - Go into Subversion's per-user configuration area, typically C:\Documents and Settings\<username>\Application Data\Subversion.
- Edit "config" and change the following lines:
# [helpers]
# diff-cmd = diff_program (diff, gdiff, etc.)
to:
[helpers]
diff-cmd = C:\Progra~1\Beyond~1\svn.bat
Cygwin (http://www.cygwin.com/) Instead of using a batch file, create a file named "bc.sh" with the following line:
"$(cygpath 'C:\Progra~1\Beyond~1\bcomp.exe')" `cygpath -w "$6"` `cygpath -w "$7"` /title1="$3" /title2="$5" /readonly
Linux
Diff:
Create a file named /usr/bin/bcdiff.sh with the following line:
/usr/bin/bcompare "$6" "$7" -title1="$3" -title2="$5" -readonly
Edit "$HOME/.subversion/config" and add the line "diff-cmd = /usr/bin/bcdiff.sh".
Merge:
Create a file named /usr/bin/bcmerge.sh with the following line:
/usr/bin/bcompare "$2" "$3" "$1" $4"
Edit "$HOME/.subversion/config" and add the line "merge-tool-cmd = /usr/bin/bcmerge.sh".
- Open User Options.
- Go to the Diff/Merge section.
- Add or edit an entry for File Type "All other text files", with Diff/Merge set to Diff.
- Enter selected application: "c:\program files\beyond compare 3\bcomp.exe" "%1" "%2" and click OK.
- Choose Options from the Tools menu.
- Switch to the Difference Viewers tab.
- Enter the path to BComp.exe in the Application edit.
- Enter /fv "$LF" /title1="$LD" "$RF" /title2="$RD" in the Parameters edit.
- Close CMSynergy application.
- Go into your %userprofile% folder (type %userprofile% in explorer address bar if you are unsure where this is ).
- Create a backup of the file named "ccm.ini".
- Edit "ccm.ini" and change the lines for Compare_cmd and merge_cmd to:
Compare_cmd = C:\Progra~1\Beyond~1\bcomp.exe %file1 %file2 /lefttitle=%file1_label /righttitle=%file2_label
merge_cmd = C:\Program~1\Beyond~1\bcomp.exe %file1 %file2 %ancestor /mergeoutput=%outfile /lefttitle=%file1_label /righttitle=%file2_label
- Start Preferences application.
- Switch to the Tools tab.
- Enter the path to BComp.exe in the External diff application edit.
- Check the External diff application supports Unicode checkbox.
To configure TortoiseHg you need to edit the file %USERPROFILE%\Mercurial.ini. Add the following lines, using existing INI sections if they already exist: Diff
[extdiff]
cmd.bcomp = C:\Program Files\Beyond Compare 3\BCompare.exe
opts.bcomp = /ro
[tortoisehg]
vdiff = bcomp
3-Way Merge (v3 Pro)
[merge-tools]
bcomp.executable = C:\Program Files\Beyond Compare 3\BComp
bcomp.args = $local $other $base $output
bcomp.priority = 1
[ui]
merge = bcomp
Diff
- Select Settings from Explorer's TortoiseSVN submenu.
- Switch to the Diff Viewer tab.
- Change the radio buttons from TortoiseMerge to External.
- In the path edits, enter:
"C:\Program Files\Beyond Compare 3\BComp.exe" %base %mine /title1=%bname /title2=%yname /leftreadonly
To use Beyond Compare for image comparisons either replace the file C:\Program Files\TortoiseSVN\bin\TortoiseIDiff.exe with a copy of BComp.exe, or click the Advanced... button on the Diff Viewer tab and add each image type's extension with the same command line as above.
3-Way Merge (v3 Pro)
- Select Settings from Explorer's TortoisSVN submenu.
- Switch to the Merge Tool tab.
- Change the radio buttons from TortoiseMerge to External.
- In the path edits, enter:
"C:\Program Files\Beyond Compare 3\BComp.exe" %mine %theirs %base %merged /title1=%yname /title2=%tname /title3=%bname /title4=%mname
2-Way Merge (v3 Std, v2)
Use the same steps as above, but use the command line:
"C:\Program Files\Beyond Compare 3\BComp.exe" %mine %theirs /mergeoutput=%merged
Diff
- Choose Options from the Tools menu.
- Select Diff / Merge.
- Under Diff, enter the path to BComp.exe for the Program setting.
- In the Arguments edit, enter:
"%LEFT_PATH%" "%RIGHT_PATH%" /ro /title1="%LEFT_LABEL%" /title2="%RIGHT_LABEL%"
3-Way Merge (v3 Pro)
- Choose Options from the Tools menu.
- Select Diff / Merge.
- Under Merge, enter the path to BComp.exe for the Program setting.
- In the Arguments edit, enter:
"%WORKING_PATH%" "%OTHER_PATH%" "%BASELINE_PATH%" "%DEST_PATH%" /title1="%WORKING_LABEL%" /title2="%OTHER_LABEL%" /title4="%DEST_LABEL%"
2-Way Merge (v3 Std, v2)
Use the same steps as above, but set the Arguments setting to:
"%WORKING_PATH%" "%OTHER_PATH%" /title1="%WORKING_LABEL%" /title2="%OTHER_LABEL%" /savetarget="%DEST_PATH%"
- Choose User Specific Options from the Tools | Options submenu.
- Switch to the Visual Differencing tab.
- Change the radio button to Use Custom Visual Differencer.
- Enter the path to BComp.exe in the edit.
Diff
- Open the Visual SourceSafe Explorer.
- Select Options from the Tools menu.
- Switch to the Custom Editors tab in the SourceSafe Options dialog.
- Select File Difference in the Operation drop-down.
- Enter ".*" in the File Extension edit.
- Enter this in the Command Line: edit:
"C:\Program Files\Beyond Compare 3\bcomp.exe" %1 %2 - Click the Add button.
Merge
- Open the Visual SourceSafe Explorer.
- Select Options from the Tools menu.
- Switch to the Custom Editors tab in the SourceSafe Options dialog.
- Select File Merge in the Operation drop-down.
- Enter ".*" in the File Extension edit.
- Enter this in the Command Line edit:
"C:\Program Files\Beyond Compare 3\bcomp.exe" %1 %2 /savetarget=%4 - Click the Add button.
Visual SourceSafe 6.0 and earlier do not support external difference utilities. SourceOffsite and VersionMaster can both use Beyond Compare in combination with SourceSafe.
- Choose Preferences from the Admin menu.
- Switch to the WinCVS tab.
- Check the External diff checkbox.
- Enter the path to BComp.exe in the External diff edit.
Source Link:http://www.scootersoftware.com/download.php?c=kb_vcs