Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command-line access to VS 2012 merge tool

I am investigating using TFS 2012 as the Source Control provider for Matlab, on Windows 7. This requires installing the VS 2012 shell/TFS client, and the 64-bit MSSCCI provider available as free downloads from Microsoft. I've set all this up and it works OK.

However, there is a problem with file differencing and merging. If I view differences from VS 2012 Source Control Explorer, the VS 2012 Diff tool runs correctly. If I try the same operation from within Matlab (using the Source Control menu) I get an error "Cannot Execute the Configured Tool". The same thing happens with the 'merge changes in merge tool' button when resolving conflicts: in VS 2012 it works, from Matlab, it doesn't.

It appears this is a known problem, at least with other tools trying to drive TFS. There is a work-around, which is to configure VS 2012 to use an external differencing utilty. I tried this and it worked. Furthermore, I found that if you configure the external differencing utility to be VS 2012's own 'internal' diff tool, the internal tool will be correctly called from Matlab.

The diff command is:

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe

and the required arguments are:

 /Diff %1 %2 %6 %7

(i.e. original file, modified file, original file label, modified file label). There is documentation on this here.

The merge tool is more problematic. I can't find any specific documentation on its command line. The closest I've got so far is

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\vsDiffMerge.exe

which I'm pretty certain is right, but the arguments I'm using

%1 %2 %1 %2 %3 %4 /m

are not quite right - the file labels are different, and the difference display is formatted differently (from the normal built-in tool). I reverse-engineered this command line from some git-related documentation here but I don't know anything about git, nor do I speak Italian. Can anybody help me find the correct command line options to use, please?

EDIT TO ADD

There is an MSDN Discussion which seems to be related to this problem here. It looks like it happens with other tools and is not limited to Matlab: I've re-tagged this question accordingly

EDIT TO ADD

The preferred command-line for the Diff functionality is:

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\vsDiffMerge.exe

and the command-line arguments are:

/t %1 %2 %6 %7

The equivalent for the Merge functionality does not work: this is an internal bug & Microsoft have acknowledged this.

like image 970
Max Avatar asked Jun 20 '13 11:06

Max


1 Answers

The vsDiffMerge.exe tool appears to work for both diffing and three-way merging. I was successfully able to integrate the VS diff/merge tool with the Perforce client for merging and integrating.

The arguments to be provided to the tool (at least for Perforce) are:


Diff

vsDiffMerge.exe /t %1 %2

Where:

  • /t (open in a temporary tab, leave off to open in permanent tab)
  • %1 (First File)
  • %2 (Second File)

Merge:

vsDiffMerge.exe /m %1 %2 %b %r

Where:

  • /m (merge operation, leave off to do a diff)
  • %1 (Their/Source file)
  • %2 (Your/Target file)
  • %b (Base file)
  • %r (Result file)

Note: The "%" explanations came from Perfore documentation at: http://www.perforce.com/perforce/doc.current/manuals/p4v/Configuring_display_preferences.html#Diff

EDIT: Sorry everyone, I'm not sure how I mixed that one up. Mark Sowul is entirely correct by my testing today. I have fixed my answer. Also, apologies for not getting this corrected as soon as the first comment was posted. I just arrived back home from an overseas trip.

like image 60
olen_garn Avatar answered Sep 29 '22 19:09

olen_garn