Integrating Perforce's p4merge with Visual Studio can be a bit tricky, but it doesn't have to be! Using a couple of pre-written batch files and Visual Studio configurations, you'll be up-and-running in no time.
Step 1: Copy the following batch files to your c:\Program Files\Perforce directory.
- p4diff.bat is for diffing files
- p4merge.bat is for merging files
Step 2: In Visual Studio, navigate to the Configure User Tools dialog.
- Launch Visual Studio.
- Go to Tools > Options... > Source Control > Visual Studio Team Foundation Server.
- Click on Configure User Tools.
Step 3: Click Add.
- You'll need to do this Add step twice.
- ...once to configure p4merge for file compare.
- ...and a second time to configure p4merge for file merge.
Step 4: Configure Visual Studio to use p4diff.bat for file compare.
- In the Configure Tool dialog, enter the following details.
- Extension: .*
- Operation: Compare
- Command: C:\Program Files\Perforce\p4diff.bat
- Arguments: %1 %2 "x" "x" "x" %6 %7
Step 5: Configure Visual Studio to use p4merge.bat for file merging.
- In the Configure Tool dialog, enter the following details.
- Extension: .*
- Operation: Merge
- Command: C:\Program Files\Perforce\p4merge.bat
- Arguments: %1 %2 %3 %4 "x" %6 %7 %8 %9
Summary
After saving all your changes, you're all set.
The next time you do a file compare or file merge operation in Visual Studio, p4merge will be launched.
The file merge operation uses 3-way merge. The left-most pane is the file on the server, the middle pane is the version you had before you made any modifications and the right-most pane is your modified version of the file. The bottom pane is the merged result of the 3-way merge.
Comments 4
It looks like that Visual Studio 2015 adds quotes automatically, so they’re no longer needed in the .bat files.
Thanks!
The links to the batch files are dead, could you fix it?
Author
Fixed. Thanks for reporting this.