Subversion Diff/Merge integration

Subversion supports external diff/merge tools. Refer to the Subversion Book for how to setup external diff and merge tools.

Subversion executes the external program you specify instead of diff or diff3 to do compares or merges. Scripts are required to transform diff/diff3 parameters into Guiffy command line interface parameters. See Guiffy's Command Line interface.

Vivek Devshwar, a Guiffy customer, developed the following scripts for integrating Guiffy with SVN on Linux.

To do a SVN diff of modified files using Guiffy, the commmand would be:
svn diff --diff-cmd <path to Guiffy SVN diff script> <path or file name>

Following script can be plugged in above which converts the parameters given by svn to those expected by Guiffy.

#!/bin/bash

# Configure path to guiffy here
GUIFFY=~/guiffy

# Subversion provides the paths we need as the sixth and seventh parameters.
# The left file will actually get expanded to the local pristine file stored
# by svn. The right file is the locally modified copy. Interchange these if
# you want to view it the other way in guiffy.
LEFT=${6}
RIGHT=${7}

# Call guiffy to open its diff window to view diff and review changes
$GUIFFY $LEFT $RIGHT

# Now, svn expects to be returned an errorcode of 0 if no differences were
# detected, 1 if some were. Any other errorcode will be treated as fatal.
# Note: whether differences were found, or not found -- guiffy always
# returns 0, so we will return 0 to svn and end at that. Returning anything
# apart from 0 or 1 tells svn something fatal happened so it will stop
# invoking guiffy after first file.
exit 0


When svn diff is used in above fashion for multiple files, it will open up Guiffy for each file one by one.

To use Guiffy to do visual merge and 3 way merge while doing update, the following command and script can be used as plugin to svn.
svn update --diff3-cmd <path to Guiffy SVN merge script> <path or file name>

Following script can be plugged in above which converts the parameters given by svn to those expected by Guiffy.

#!/bin/bash

# Configure path to guiffy here
GUIFFY=~/guiffy

# Subversion provides the paths we need as the ninth, tenth, and eleventh
# parameters.
MINE=${9}
OLDER=${10}
YOURS=${11}

sureMergeFile=${MINE}.guiffysmerge
# Call the guiffy suremerge command between locally modified, checked in
# version, and parent of checked in version. Save merge output into
# sureMergeFile. Do save merge output in guiffy before exiting; to do
# that:click on menu Merge->Save Merged File, Press F2, OR click on Save
# button on toolbar with an 'M'.
$GUIFFY -s $MINE $YOURS $OLDER $sureMergeFile

# After performing the merge, this script needs to print the contents of the
# merged file to stdout. Note: If this is not done, svn will overwrite the
# file as empty since nothing was sent to it. This output to stdout is picked
# by svn which writes it onto locally modified file.
cat $sureMergeFile

# clean up the temp sure merge file now that svn has saved our merge changes
# onto the locally modified copy
rm $sureMergeFile

# Now, svn expects to be returned an errorcode of 0 if no differences were
# detected, 1 if some were. Any other errorcode will be treated as fatal and
# svn will stop at that file. We simply return 0 since guiffy always returns
# that.
exit 0


The above script is somewhat more complex and demands that the script must output the merge file to stdout, because the same output is read by svn and written into the working copy.

In case of multiple files which are updated, the Guiffy tool will get invoked for the conflict case only, and when user reviews and merges the changes, and then saves and exits, the control shifts back to svn. Svn command will then proceed to the next files in its list.

Use Guiffy standalone --- Then, put your saved merge results

Many SVN users find Guiffy's integrated Folder Compare features a handy way to synchronize projects. From the Folder Compare Tree view, files can be compared and merged. 3-way SureMerges can also be performed from the Tree view's rightclick popup menu.

Documentation by Guiffy Software, Inc. 2014