Version Control with Subversion - Using External Differencing Tools - External diff3
Subversion calls external merge programs with parameters
suitable for the GNU diff3 utility, expecting that the
external program return with a successful error code and that
the full file contents which result from the completed merge
operation are printed on the standard output stream (so that
Subversion can redirect them into the appropriate version
controlled file). For most alternative merge programs, only
the ninth, tenth, and eleventh arguments, the paths of the
files which represent the “mine”,
“older”, and “yours” inputs,
respectively, are of interest. Note that because Subversion
depends on the output of your merge program, you wrapper
script must not exit before that output has been delivered to
Subversion. When it finally does exit, it should return an
errorcode of 0 if the merge was successful, or 1 if unresolved
conflicts remain in the output—any other errorcode is
considered a fatal error.
Example 7.4, “diff3wrap.sh”
Example 7.5, “diff3wrap.bat” are
templates for external merge tool wrappers in the Bourne shell
and Windows batch scripting languages, respectively.
Example 7.4. diff3wrap.sh
# Configure your favorite diff3/merge program here.
# Subversion provides the paths we need as the ninth, tenth, and eleventh
# Call the merge command (change the following line to make sense for
# your merge program).
$DIFF3 --older $OLDER --mine $MINE --yours $YOURS
# After performing the merge, this script needs to print the contents
# of the merged file to stdout. Do that in whatever way you see fit.
# Return an errorcode of 0 on successful merge, 1 if unresolved conflicts
# remain in the result. Any other errorcode will be treated as fatal.
Example 7.5. diff3wrap.bat
REM Configure your favorite diff3/merge program here.
SET DIFF3="C:\Program Files\Funky Stuff\My Merge Tool.exe"
REM Subversion provides the paths we need as the ninth, tenth, and eleventh
REM parameters. But we only have access to nine parameters at a time, so we
REM shift our nine-parameter window twice to let us get to what we need.
REM Call the merge command (change the following line to make sense for
REM your merge program).
%DIFF3% --older %OLDER% --mine %MINE% --yours %YOURS%
REM After performing the merge, this script needs to print the contents
REM of the merged file to stdout. Do that in whatever way you see fit.
REM Return an errorcode of 0 on successful merge, 1 if unresolved conflicts
REM remain in the result. Any other errorcode will be treated as fatal.
[an error occurred while processing this directive]