How to use TortoiseMerge from Perforce P4V?

2019-08-05 15:25发布

问题:

How can I configure Perforce to use the tool TortoiseMerge for diff and merging?


I tried arguments

/base:%1 /mine:%2

following http://tortoisesvn.net/docs/release/TortoiseMerge_en/tme-automation.html and http://www.perforce.com/perforce/doc.current/manuals/p4v/Configuring_display_preferences.html#Diff . The Perforce docs say

Specify arguments for third-party diff applications in the Arguments field: Enter %1 for the name of the first file and %2 for the name of the second file. P4V replaces these placeholders with the actual filenames when calling the diff application.

Yet when I try it, TortoiseMerge errors "Can't open file %1" suggesting P4V didn't replace the arguments and left %1 as is

回答1:

You can do this by creating a bat file. In the bat file you can call the merge program with the correct arguments. This is the content of my bat file:

TortoiseMerge.exe /base:%1 /theirs:%2 /mine:%3 /merged:%4

The settings in p4 %b %1 %2 %r :

As you can see I called my bat file "p4Helper.bat"



回答2:

Sadly P4V's argument replacement is broken. You can use TortoiseMerge for diffing, but not merging.

To set up TortoiseMerge for diffing, use the argument string %1 %2

The correct arguments for merging would be

/base:%b /theirs:%1 /mine:%2 /merged:%r

However it gives this error

Presumably what's happening is that P4V fails to replace the '%b' in /base:%b with the appropriate file path.



回答3:

There is an existing enhancement request because P4V does not substitute values for %b, %1, %2, and %r if these arguments are not by themselves. For example, P4V does not substitute:

 /base:%b /theirs:%1 /mine:%2 /merged:%r

which are needed by TortoiseMerge.

However, one user reported that the command worked once he added the quotes around the pathname due to the spaces in it. For example:

start /WAIT "C:/Program Files/Beyond Compare 3/BComp.exe" %1 %2 %3 /mergeoutput=%4

Thus as a workaround, you can augment the %b %1 %2 %r arguments in a script that calls TortoiseMerge. In TortoiseMerge's case, you would have a line like this:

 c:"\the_path_to_TortoiseMerge" /base:%1 /theirs:%2 /mine:%3 /merged:%4