Skip to content

Instantly share code, notes, and snippets.

@gsmithufl
Last active October 11, 2017 20:17
Show Gist options
  • Save gsmithufl/762ca97355a32a38c4929ee760dd5db5 to your computer and use it in GitHub Desktop.
Save gsmithufl/762ca97355a32a38c4929ee760dd5db5 to your computer and use it in GitHub Desktop.
Use meld tool with cmd line svn diff
##### svn command to modify externals with gui at the base directory #####
svn propedit svn:externals .
############################################
##### command to use meld for svn diff #####
svn -diff --diff-cmd='meld' [filepath] -r [revision]
##### alternatively modify the ~/.subversion/config file to point to the scripts below to use the regular command #####
##### script for setting svn diff program #####
#!/bin/sh
# Configure your favorite diff program here.
DIFF="/usr/bin/meld"
# Subversion provides the paths we need as the sixth and seventh
# parameters.
LEFT="$6"
RIGHT="$7"
# Call the diff command (change the following line to make sense for
# your merge program).
"$DIFF" "$LEFT" "$RIGHT"
# Return an errorcode of 0 if no differences were detected, 1 if some were.
# Any other errorcode will be treated as fatal.
##### script for setting svn merge program #####
#!/bin/bash
base=${1?1st argument is 'base' file}
theirs=${2?2nd argument is 'theirs' file}
mine=${3?3rd argument is 'mine' file}
merged=${4?4th argument is 'merged' file}
version=$(meld --version | perl -pe '($_)=/([0-9]+([.][0-9]+)+)/' )
if [[ "$version" < 1.7 ]]
then
#old meld version 1.6.* = three input files
cat "$mine" > "$merged"
meld --label="Base=${base##*/}" "$base" \
--label="Mine->Merged=${merged##*/}" "$merged" \
--label="Theirs=${theirs##*/}" "$theirs"
else
# recent meld versions 1.7.* and above = four input files
meld --label="Base=${base##*/}" "$base" \
--label="Mine=${mine##*/}" "$mine" \
--label="Merged=${merged##*/}" "$merged" \
--label="Theirs=${theirs##*/}" "$theirs"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment