scripts

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

cvspast (957B)


      1 #!/bin/sh
      2 
      3 # prints iterative diffs for a given file in cvs
      4 # unless count is given it defaults to three diffs in the past
      5 # assumes all revision numbers start with '1.'
      6 # needs: cvs
      7 
      8 # which file
      9 if test -z "$1"; then
     10     echo "Usage: $(basename $0) file [-count]" 1>&2
     11     exit 1
     12 else
     13     FILE=$1
     14 fi
     15 
     16 # how many diffs
     17 N=$(echo $2 | sed 's/[^0-9]//g')
     18 test -n "$N" || N=3
     19 
     20 # escape filename for use in grep/sed
     21 ESC='s/[\/()[]$*.^|]/\\&/g'
     22 F=$(basename $FILE | sed $ESC)
     23 D=$(dirname $FILE)
     24 
     25 # current revision
     26 CUR=$(grep "^/$F/" $D/CVS/Entries \
     27     | sed "s|^/$F/1\.\([0-9]*\)/.*$|\1|")
     28 if test -z "$CUR"; then
     29     echo "File not in CVS!" 1>&2
     30     exit 2
     31 fi
     32 
     33 # count is at most as large as the cur revision
     34 test $N -le $CUR || N=$CUR
     35 
     36 echo "HEAD is revision 1.$CUR"
     37 echo "Performing $N diffs"
     38 
     39 # perform diffs in pairs
     40 while test $N -gt 0; do
     41     PREV=$(expr $CUR - 1)
     42     echo
     43     cvs diff -r1.$PREV -r1.$CUR $FILE
     44     CUR=$PREV
     45     N=$(expr $N - 1)
     46 done