We'd like to make cvs's diff output colorful.
If you're vim people, you could do it in 2 ways.
- Redirect cvs diff to vim by "| vim -".
Then change highlight settings in .vimrc as follows:
- hi diffAdded ctermfg=Yellow ctermbg=DarkGray guifg=Yellow
- hi diffRemoved ctermfg=Red ctermbg=DarkGray guifg=Red
- Or, you could use vimdiff by running the script(cvsvimdiff.sh) in the end.
This script let you enjoy vimdiff's block diff with cvs.
Usage: "cvsvimdiff -r version1 -r version2 filename"
Besides, you should change color scheme to make a comfortable displays of vimdiff.
- hi DiffAdd term=reverse cterm=bold ctermbg=green ctermfg=white
- hi DiffChange term=reverse cterm=bold ctermbg=cyan ctermfg=black
- hi DiffText term=reverse cterm=bold ctermbg=gray ctermfg=black
- hi DiffDelete term=reverse cterm=bold ctermbg=red ctermfg=black
#!/bin/bash
#
# Copyright (C) 2005-2006,
# Stefano Zacchiroli
# Enrico Tassi
#
# This is free software, you can redistribute it and/or modify it under the
# terms of the GNU General Public License version 2 as published by the Free
# Software Foundation.
#
vimdiff="vimdiff"
suffix="vimcvsdiff"
rev1="HEAD"
if [ "$1" == "-g" ] ; then
vimdiff="gvimdiff -f"
shift 1
fi
if [ "$1" == "-r" ]; then
rev1="$2"
shift 2
fi
if [ "$1" == "-r" ]; then
rev2="$2"
shift 2
fi
files="$1"
if [ -z "$files" ]; then
files=$(cvs -n update -r HEAD 2> /dev/null | grep -e "^[MU]" | cut -c 3-)
fi
for f in $files; do
if ! [ -f $f ]; then break; fi
patch=`mktemp $prefix.XXXXXX`
orig=`mktemp $prefix.XXXXXX`
trap "rm -f $patch $orig" EXIT
if ! [ -z "$rev2" ]; then
tmp1=$f.$rev1
tmp2=$f.$rev2
cvs up -p -r $rev1 $f > $tmp1
cvs up -p -r $rev2 $f > $tmp2
$vimdiff $tmp1 $tmp2
rm -f $tmp1 $tmp2
else
cp "$f" $orig
cut -d '/' -f 2 < CVS/Entries | grep "^$f\$" > /dev/null || break
cvs diff -r $rev1 -u "$f" > $patch
if ! [ $? -eq 1 ]; then break; fi
cp "$f" $orig
patch -R -p0 $orig $patch
$vimdiff $orig $f
fi
done
沒有留言:
張貼留言