summaryrefslogtreecommitdiff
path: root/rvi
blob: 1ffdc4fc4125ddf0908c66126799323d1214525d (plain)
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
#!/bin/sh

if ! [ -e "$1" ] ; then
	echo "$1 does not exist." >&2
	exit 1
fi

DN=`dirname "$1"`
BN=`basename "$1"`
if ! [ -e "$1,v" ] && ! [ -e "$DN/RCS/$BN,v" ] ; then
	echo "Neither $1,v nor $DN/RCS/$BN,v do not exist." >&2
	exit 1
fi

owner=`stat -c "%u:%g" $1`
rcsdiff -u "$1"
if [ $? -ne 0 ] ; then
	rcsdiff "$1" > "$1.rvi.diff"
	echo
	echo "Differences detected"
	echo "run 'co $1' to overwrite with last committed version"
	echo "or 'co -l $1; patch $1 < $1.rvi.diff; ci -u $1; chown $owner $1' to commit"
	exit 1
fi
rm -f "$1.rvi.diff"

co -l "$1"
if [ $? -ne 0 ] ; then
	echo "Check out failed."
	echo "Maybe someone else is currently editing this file."
	echo "Aborting rvi."
	exit 1
fi
if [ "$(id -u)" = "0" ]; then
    chown "$owner" "$1"
fi
/usr/bin/vim "$1"
ci -u "$1"
if [ "$(id -u)" = "0" ]; then
    chown "$owner" "$1"
fi