rcsvimdiff or vimrcsdiff
29 Nov 2006 RCS is nice to keep a history of how files changes over time. "rcsdiff" then is a tool that can generate a diff-file between 2 versions of the same file.However, the diff is shown in standard "diff" output format. I prefer the "vimdiff" program (which comes with vim in Debian).
The vimdiff command takes 2 files and shows them side by side in vim, using syntax coloring and such. But vimdiff can't work with RCS...
So I created this script which I'll call rcsvimdiff. It combines both functionalities in one.
#!/bin/bash
ver1=$1
ver2=$2
file=$3
if [ "x$file" = "x" ];
then
echo "Usage: rcsvimdiff -rREV1 -rREV2 filename"
exit 0
fi
if [ ! -f $file ];
then
echo "File $file doesn't exist."
exit 1
fi
if [ ! -f $file,v -a ! -f `dirname $file`/RCS/`basename $file`,v ];
then
echo "File $file has no RCS history"
exit 1
fi
basefile=`basename $file`
TMPDIR=/tmp/rcsvimdiff.$RANDOM$RANDOM$RANDOM
for v in $ver1 $ver2;
do
mkdir -p $TMPDIR$v || exit 1
cp -f $file $TMPDIR$v/
cp -f `dirname $file`/RCS/`basename $file`,v $TMPDIR$v/
cp -f $file,v $TMPDIR$v/
co -f $v $TMPDIR$v/$basefile
done
vimdiff $TMPDIR$ver1/$basefile $TMPDIR$ver2/$basefile
for v in $ver1 $ver2;
do
rm -rf $TMPDIR$v
done
Usage: rcsvimdiff <-rREV1> <-rREV2>
For example: rcsvimdiff -r1.1 -r1.3 /etc/motd