Subversion integration with Guiffy Diff and Merge Tool
Subversion (svn) is a popular version control system, and has been written to provide several improvements over CVS versioning system. It also provides possibilities to integrate with third party applications for common tasks like diff and merge of working copies of files with those in version control. So for example, to do diff of a file, one would enter:
svn diff <filename>
OR
svn diff <path>
Which would provide usual GNU diff format output of the said <filename> or all the files in <path> which have been locally modified.
Also, if one does svn update to get the latest updates from repository, the command would be:
svn update <file>
OR
svn update <path>
In case a file has been locally modified on a previous checked out version, svn will do an automatic merge of the file and if the merge goes through successfully, it would report it with a 'G' flag, else in case of conflicted merge, it would report it with a 'C' flag. The user has to then edit the conflicted file and check for all places where conflicts were found.
We now explore how above tasks can be made simpler by integrating svn with Guiffy, a graphical tool for doing side by side diff, as well as three way merges.
Subversion provides command line option to plug in third party programs for doing diff or merge. So, to do see diff of modified files in Guiffy, the commmand would be:
svn diff --diff-cmd <path to Guify 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 # 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. # Call guiffy to open its diff window to view diff and review changes # 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. |
When svn diff is used in above fashion for multiple files, it will open up Guiffy for each file one by one.
Above script has been based on example found at svn documentation page below:
http://svnbook.red-bean.com/en/1.2/svn.advanced.externaldifftools.html
To use Guiffy to do visual merge and 3 way merge while doing update, following command and script can be used as plugin to svn.
svn update --diff3-cmd <path to Guify merge script> <path or file name>
|
#!/bin/bash
# Configure path to guiffy here # Subversion provides the paths we need as the ninth, tenth, and eleventh parameters. sureMergeFile=${MINE}.guiffysmerge # not tested:Call the guiffy merge command between locally modified and checked in version # 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. # 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. |
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.
In summary, the integration of Guiffy tool, using above scripts, makes for lot more productivity, and makes code reviews and updates from repository less error prone.

Recent comments
1 year 39 weeks ago