Configure TortoiseMerge as an external merge tool for SVN?

Is it possible to configure TortoiseMerge (supplied with TortoiseSVN) as an external merge tool that appears when you encounter a merge conflict using the svn merge command line? I tried to set my SVN_MERGE environment variable to point to TortoiseMerge.exe, but that doesn't seem to be enough. TortoiseMerge just appears when I select "l" (to run an external tool), asking which files I want to merge. I want this information to be automatically inserted into the tool.

Any ideas?

+4
source share
2 answers

I do not know which version of Subversion you are using, so I will try to access the information in the latest version of Subversion Documentation , for 1.6. (They add on this page that β€œif you bookmark or link to specific sections, these links may be invalid while continuing to develop.” But there is no stable version for 1.6.)

First, the bad news :

To use the merge tool, you need to either set the SVN_MERGE environment variable or define the merge-tool-cmd in your Subversion configuration file (see the "Configuration Options" section for more details). Subversion will pass four arguments to the merge tool: BASIC file revision, revision of the file received from the server as part of the update, a copy of the file containing your local editing and a merged copy of the file (which contains conflict markers). If your merge tool expects arguments in a different order or format, you will need to write a shell script for Subversion to invoke.

Somewhat better news is that Subversion anticipated your question. See the section Using External Diversity and Merge Tools ; There are external wrapper patterns for merge tools.

In your particular case, the TortoiseMerge Documentation has an application explaining how to use it from the command line. The essential switches are /base , /mine and /theirs , but you can use more (in the end, you write your own shell script). TortoiseMerge also allows a "simplified form" command:

 TortoiseMerge BaseFilePath MyFilePath TheirFilePath 

The way to transfer merge results back to Subversion is to write the merged file to standard output and return the corresponding value. This information is provided in wrapper templates in the Subversion manual.

+3
source

Create a bat script that looks like this:

 "c:\Program Files\TortoiseSVN\bin\TortoiseMerge.exe" /base:"%1" /theirs:"%2" /mine:"%3" /merged:"%4" 

Then set the environment variable SVN_MERGE with this bit of script:

 set SVN_MERGE=c:\bin\svnmerge.bat 
+3
source

Source: https://habr.com/ru/post/1302615/


All Articles