File: gtkdiff-rcs.in

package info (click to toggle)
gtkdiff 1.8.0-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,736 kB
  • ctags: 1,654
  • sloc: ansic: 15,829; sh: 763; makefile: 320; sed: 93
file content (178 lines) | stat: -rw-r--r-- 3,669 bytes parent folder | download
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/bin/sh

progname=$0
version=1.1.0
usage="\
Usage: $progname file
A simple shell script launches gtkdiff(1) for RCS(1) files.
This intends to be compatible with rcsdiff(1).
  -r N, --revision N         specifies revision numbers.
                             space between -r and N can be omitted.
                             The meaning follows rcsdiff(1).
  -3, --diff3                Use diff3(1).						 
  -h, --help                 print this help and exit
  -v, --version              print version information and exit

Example:
	\$ gtkdiff-rcs GnewsAlert.c
	( diff with latest ) 

	\$ gtkdiff-rcs -r1.1 GnewsAlert.c
	( diff with revision 1.1 )

	\$ gtkdiff-rcs -r1.1 -r1.2 GnewsAlert.c
	( diff between revisions 1.1 and 1.2 )

	\$ gtkdiff-rcs -3 -r1.1 GnewsAlert.c
	( diff3 among current, latest and revision 1.1 )

	\$ gtkdiff-rcs -3 -r1.1 -r1.2 GnewsAlert.c
	( diff3 among current, and revisions 1.1 and 1.2 )
	
	\$ gtkdiff-rcs -r1.1 -r1.2 -r1.3 GnewsAlert.c
	( diff3 among revisions 1.1, 1.2 and 1.3 )
"

# Command path
CO=@CO@
RM=@RM@
GTKDIFF=@prefix@/bin/gtkdiff

# Temporary files information
: ${TMPDIR=/tmp}
TMP_SUFFIX=@gtkdiff$$
TMP_REV1_FILE=
TMP_REV2_FILE=
TMP_REV3_FILE=

# variables
rev1=
rev2=
rev3=
use_diff3=0

rm_tmpfiles () {
	[ -n "$TMP_REV1_FILE" -a -f $TMP_REV1_FILE ] && $RM -f $TMP_REV1_FILE
	[ -n "$TMP_REV2_FILE" -a -f $TMP_REV2_FILE ] && $RM -f $TMP_REV2_FILE
	[ -n "$TMP_REV3_FILE" -a -f $TMP_REV3_FILE ] && $RM -f $TMP_REV3_FILE
}

finalize () {
	rm_tmpfiles
	exit 1
}
trap finalize INT QUIT HUP TERM

#
# Option processing
#
while [ "$1" != "" ]
do
	case "$1" in
	-r | --revision)
		shift
		test $# -eq 0 && { echo "$usage"; exit 0; }
		[ -z "$rev1" ] && { rev1="$1"; shift; continue; }
		[ -z "$rev2" ] && { rev2="$1"; shift; continue; }
		[ -z "$rev3" ] && rev3="$1";;
	-r*)
		[ -z "$rev1" ] && { rev1=`expr $1 : '-r\(.*\)'`; shift; continue; }
		[ -z "$rev2" ] && { rev2=`expr $1 : '-r\(.*\)'`; shift; continue; }
		[ -z "$rev3" ] && rev3=`expr $1 : '-r\(.*\)'`;;
	-3 | --diff3)
		use_diff3=1;;
	-h | --help) 
		echo "$usage"; exit 0;;
	-v | --version | --v*)
		echo "$progname $version"; exit 0;;
	--) # Stop option processing.
		shift; break ;;
	*)
		break ;;
	esac
	shift
done

if [ -z "$1" ]
then
	echo "$usage"
	exit 1
fi

#
# Check necessary files
#
if [ ! -x "$GTKDIFF" ]
then
	echo "Warning:"
	echo "You can't execute $GTKDIFF."
	echo "Are you sure you have GtkDiff installed ?"
	exit 0
fi

if [ ! -x "$CO" ]
then
	echo "Warning:"
	echo "You can't execute $CO."
	echo "Are you sure you have RCS installed ?"
	exit 0
fi

if [ ! -f "$1" ]
then
	echo "Warning:"
	echo "$1 not found"
	exit 0
fi

#
# Create temporary revision files
#
TMP_REV1_FILE=$TMPDIR/`basename ${1}`"("${rev1}")"${TMP_SUFFIX}
TMP_REV2_FILE=$TMPDIR/`basename ${1}`"("${rev2}")"${TMP_SUFFIX}
TMP_REV3_FILE=$TMPDIR/`basename ${1}`"("${rev3}")"${TMP_SUFFIX}

if [ -n "$rev1" ]
then
	$CO -p$rev1 $1 > $TMP_REV1_FILE
else
	TMP_REV1_FILE=$TMPDIR/`basename ${1}`"("latest")"${TMP_SUFFIX}
	$CO -p $1 > $TMP_REV1_FILE
	$GTKDIFF $TMP_REV1_FILE $1
	rm_tmpfiles
	exit 0
fi

if [ -n "$rev2" ]
then
	$CO -p$rev2 $1 > $TMP_REV2_FILE
else
	if [ $use_diff3 -eq 0 ]; then
		$GTKDIFF $TMP_REV1_FILE $1
		rm_tmpfiles
		exit 0
   	else
		TMP_REV2_FILE=$TMPDIR/`basename ${1}`"("latest")"${TMP_SUFFIX}
		$CO -p $1 > $TMP_REV2_FILE
		$GTKDIFF $TMP_REV1_FILE $TMP_REV2_FILE $1
		rm_tmpfiles
		exit 0
	fi
fi

if [ -n "$rev3" ]
then
	$CO -p$rev3 $1 > $TMP_REV3_FILE
	$GTKDIFF $TMP_REV1_FILE $TMP_REV2_FILE $TMP_REV3_FILE
else
	if [ $use_diff3 -eq 0 ]; then
		$GTKDIFF $TMP_REV1_FILE $TMP_REV2_FILE
	else
		$GTKDIFF $TMP_REV1_FILE $TMP_REV2_FILE $1
	fi
fi

rm_tmpfiles
exit 0