O'Reilly logo

Version Control with Subversion, 2nd Edition by Brian W. Fitzpatrick, Ben Collins-Sussman, C. Michael Pilato

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

External diff3

Subversion calls external merge programs with parameters suitable for the GNU diff3 utility, expecting that the external program will return with a successful error code and that the full file contents that 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 9th, 10th, and 11th 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, your wrapper script must not exit before that output has been delivered to Subversion. When it finally does exit, it should return an error code of 0 if the merge was successful or 1 if unresolved conflicts remain in the output—any other error code is considered a fatal error.

Examples 7-4 and 7-5 are templates for external merge tool wrappers in the Python and Windows batch scripting languages, respectively.

Example 7-4. diff3wrap.py
#!/usr/bin/env python import sys import os # Configure your favorite diff program here. DIFF3 = "/usr/local/bin/my-merge-tool" # Subversion provides the paths we need as the last three parameters. MINE = sys.argv[-3] OLDER = sys.argv[-2] YOURS = sys.argv[-1] # Call the merge command (change the following line to make sense for # your merge program). cmd = [DIFF3, '--older', OLDER, '--mine', MINE, '--yours', YOURS] ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required