-
Notifications
You must be signed in to change notification settings - Fork 1
/
fmdiff3
executable file
·95 lines (85 loc) · 1.82 KB
/
fmdiff3
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/sh
#
# Wrapper script to use FileMerge as a diff3-cmd in Subversion
#
FM="$(which filemerge)"
FMDIFF="$(basename $0)"
GN="/usr/local/bin/growlnotify"
# Resolve symlinks leading to FileMerge
while [ -L "$FM" ]; do
FM_DIR="$(dirname "$FM")"
FM="$(readlink "$FM")"
[[ $FM == /* ]] || FM="$FM_DIR/$FM"
done
while [ $# != 0 ]; do
case $1 in
-m)
merged=1
;;
-E)
notall=1
;;
-L)
shift
if [ -z "$rightlabel" ]; then
rightlabel=$1
elif [ -z "$ancestorlabel" ]; then
ancestorlabel=$1
elif [ -z "$leftlabel" ]; then
leftlabel=$1
else
echo "Too many labels" 1>&2
exit 2
fi
;;
-*)
echo "Unknown option: $1" 1>&2
exit 1
;;
*)
if [ -z "$rightfile" ]; then
rightfile=$1
elif [ -z "$ancestorfile" ]; then
ancestorfile=$1
elif [ -z "$leftfile" ]; then
leftfile=$1
else
echo "Too many files to diff" 1>&2
exit 2
fi
esac
shift
done
if [ -z "$rightfile" ] || [ -z "$ancestorfile" ] || [ -z "$leftfile" ]; then
echo "Usage: $FMDIFF [options] myfile oldfile yourfile" 1>&2
exit 2
fi
if [ -z "$merged" ]; then
echo "Can only output merged file (need -m option)" 1>&2
exit 2
fi
mergefile=`mktemp -t $FMDIFF`
function labels {
[ -n "$ancestorlabel" ] && echo Ancestor: $ancestorlabel
[ -n "$leftlabel" ] && echo Left: $leftlabel
[ -n "$rightlabel" ] && echo Right: $rightlabel
}
echo Starting FileMerge... 1>&2
labels 1>&2
if [ -x "$GN" ]; then
labels | "$GN" -a FileMerge -n "$FMDIFF" "Starting FileMerge"
fi
[[ "$mergefile" == */* ]] || mergefile="./$mergefile"
tempfile=`mktemp -t $FMDIFF`
"$FM" -left "$leftfile" -right "$rightfile" \
-ancestor "$ancestorfile" -merge "$mergefile"
if [ "$mergefile" -nt "$tempfile" ]; then
rm "$tempfile"
cat "$mergefile"
rm "$mergefile"
exit 0
else
rm "$tempfile"
rm "$mergefile"
exit 1
fi