-
Notifications
You must be signed in to change notification settings - Fork 3
/
fmresolve.sh
executable file
·76 lines (66 loc) · 1.64 KB
/
fmresolve.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
#
# Wrapper script to use FileMerge to resolve Subversion conflicts
#
FM="/Xcode4/Applications/Utilities/FileMerge.app/Contents/MacOS/FileMerge"
FMDIFF="$(basename $0)"
GN="/usr/local/bin/growlnotify"
function lookup {
local info=$1
local wantedkey=$2
local key
local value
# Split lines in info through word splitting
local IFS=$'\n'
for line in $info; do
key=${line%%: *}
value=${line#*: }
if [ $key == $wantedkey ]; then
RETVAL=$value
return 0
fi
done
return 1
}
while [ $# != 0 ]; do
case $1 in
-*)
echo "Unknown option: $1" 1>&2
exit 2
;;
*)
if [ -z "$conflictfile" ]; then
conflictfile=$1
else
echo "Too many files to resolve" 1>&2
exit 2
fi
esac
shift
done
if [ -z "$conflictfile" ]; then
echo "Usage: $FMDIFF [options] conflictfile" 1>&2
exit 2
fi
filedir=`dirname "$conflictfile"`
info=`svn info "$conflictfile"`
lookup "$info" "Conflict Current Base File" && leftfile=$RETVAL
lookup "$info" "Conflict Previous Working File" && rightfile=$RETVAL
lookup "$info" "Conflict Previous Base File" && ancestorfile=$RETVAL
mergefile=`basename "$conflictfile"`
if [ -z "$leftfile" ] || [ -z "$rightfile" ] || [ -z "$ancestorfile" ]; then
echo "Can't obtain conflict info for $conflictfile" 1>&2
exit 2
fi
function labels {
echo Ancestor: $ancestorfile
echo Left: $leftfile
echo Right: $rightfile
}
echo Starting FileMerge... 1>&2
labels 1>&2
if [ -x "$GN" ]; then
labels | "$GN" -a FileMerge -n "$FMDIFF" "Starting FileMerge"
fi
exec "$FM" -left "${filedir}/${leftfile}" -right "${filedir}/${rightfile}" \
-ancestor "${filedir}/${ancestorfile}" -merge "${filedir}/${mergefile}"