scripts

misc scripts and tools
git clone git://git.2f30.org/scripts
Log | Files | Refs

commit d7ad0e9d8ec388524fd90a99fb4a342d28564f5a
parent a483764c4d5b18c407ecd79d31dafa839f2178d1
Author: lostd <lostd@2f30.org>
Date:   Sat, 23 Nov 2013 16:33:58 +0200

track changes of files in cvs

Diffstat:
Acvspast | 46++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+), 0 deletions(-)

diff --git a/cvspast b/cvspast @@ -0,0 +1,46 @@ +#!/bin/sh + +# prints iterative diffs for a given file in cvs +# unless n is given it defaults to three diffs in the past +# assumes all revision numbers start with '1.' +# needs: cvs + +# which file +if test -z "$1"; then + echo "Usage: $(basename $0) file [-n]" 1>&2 + exit 1 +else + FILE=$1 +fi + +# how many diffs +N=$(echo $2 | sed 's/[^0-9]//g') +test -n "$N" || N=3 + +# escape filename for use in sed +ESC='s/[\/()[]$*.^|]/\\&/g' +F=$(basename $FILE | sed $ESC) +D=$(dirname $FILE) + +# current revision +CUR=$(grep "^/$F/" $D/CVS/Entries \ + | sed "s|^/${F}/1\.\([0-9]\+\)/.*$|\1|") +if test -z "$CUR"; then + echo "File not in CVS!" 1>&2 + exit 2 +fi + +# n is at most as large as the cur revision +test $N -le $CUR || N=$CUR + +echo "HEAD is revision 1.$CUR" +echo "Performing $N diffs" +echo + +# perform diffs in pairs +while test $N -gt 0; do + PREV=$(expr $CUR - 1) + cvs diff -r1.$PREV -r1.$CUR $FILE + CUR=$PREV + N=$(expr $N - 1) +done