#!/bin/sh ######################################################################## # 1999/12/08 CG # # A little utility for providing information on the files in a package # for a particular tag, and for giving details of differences for a # particular package between one tag and another. Relies on the output # of ``cvs status'', and the presence of such UNIX utilities as awk, sed # and wc. Currently one must have the package checked out into a local # area and either be in that area or specify it on the command line. # # Note that if the -t argument is not specified, one is assumed to be # working with the head (referred to in output as "HEAD"). # # Usage examples: # # *) To count and print out the names and revisions of all files currently # on the head for package G4Geometry: # # tagfind $PROJECT_DIR/G4Geometry; or # # cd $PROJECT_DIR/G4Geometry; tagfind # # *) To count and print out the names and revisions of all files tagged as # "V00-00-03" in package G4Geometry: # # tagfind -t V00-00-03 $PROJECT_DIR/G4Geometry # # *) To count and print out the names of all files which have appeared # in G4Geometry since tag V00-00-05: # # tagfind -p V00-00-05 -n $PROJECT_DIR/G4Geometry # # *) To count and print out the names of all files which have been updated # in G4Geometry since tag V00-00-05, including revision info: # # tagfind -p V00-00-05 -c $PROJECT_DIR/G4Geometry # # *) To count and print out the names of all files which have disappeared # in G4Geometry since tag V00-00-05: # # tagfind -p V00-00-05 -d $PROJECT_DIR/G4Geometry # # *) To count and print out the names of all files which have appeared # in G4Geometry between tags V00-00-03 and V00-00-05: # # tagfind -p V00-00-03 -t V00-00-05 -n $PROJECT_DIR/G4Geometry # # ... and various combinations of the above functionality. # ######################################################################## tmp=/tmp/tagfind.$$ trap "rm $tmp* 2>/dev/null" 0 setMode() { if [ $# -lt 1 ] ; then return 1; fi if [ -n "$mode" ] ; then echo "Options -n, -d and -c are mutually exclusive! Using originally requested " echo "mode $mode."; else mode="$1" fi } findTagIn() { if [ $# -lt 2 ] ; then return 1; fi if [ -n "$3" ] ; then output="> $3"; else output=""; fi eval "awk '{for (i=1; i> $tmp.awk fi if [ -n "$tdir" ] ; then package="$tdir" else package=`basename \`pwd\`` fi cat >> $tmp.awk <<\EOF /Examining/ { if (TDIR!="") { if ($4==".") { DIR=TDIR"/" } else { DIR=TDIR"/"$4"/" } } else { if ($4==".") { DIR="" } else { DIR=$4"/" } }; next; } /File:/ {printf "File " DIR $2 " tags "; next} /Repository revision/ {head=$3; next;} /Existing Tags/ {TAGS=1; printf "HEAD (rev " head ") "; next} NF==0 || /\=\=\=\=\=\=\=\=\=\=\=\=\=/ {if (TAGS) {print ""}; TAGS=0; next} TAGS==1 && $1 {printf $1 " (rev " $3 " "} END {print ""} EOF cvs status -v 2>&1 | awk -f $tmp.awk | sort > $tmp.out if [ -z "$tag" ] ; then tag="HEAD"; fi if [ -z "$prev" ]; then findTagIn $tag $tmp.out $tmp.out.1 chars=`cat $tmp.out.1 | wc -c | tr -d ' '` lines=`cat $tmp.out.1 | wc -l | tr -d ' '` if [ $chars -gt 1 ] ; then if [ $lines -gt 1 ] ; then plural="s"; fi echo "$lines file$plural in package $package with tag $tag:" cat $tmp.out.1 else echo "0 files in package $package with tag $tag!" fi else findTagIn $prev $tmp.out $tmp.out.1 findTagIn $tag $tmp.out $tmp.out.2 cat > $tmp.awk <> $tmp.awk <<\EOF NF==0 {next;} { prev=$1; prevrev=$2 " " $3; while (cur < prev) { if (cur && mode == "n") print " " cur; if (getline < F2) { cur=$1; currev=$2 " " $3; } else { cur=""; if (mode == "d") print " " prev; break; } } if (cur > prev) { if (mode == "d") print " " prev; next; } if (cur == prev) { if (prevrev != currev) { if (mode == "c") print " " prev,prevrev,"->",currev; } if (getline < F2) { cur=$1; currev=$2 " " $3; } else { cur=""; } next; } } END { if (mode == "n") { if (cur>prev) print " " cur; while (getline < F2) print " " $1; } close(F2); } EOF awk -f $tmp.awk $tmp.out.1 > $tmp.out.3 chars=`cat $tmp.out.3 | wc -c | tr -d ' '` lines=`cat $tmp.out.3 | wc -l | tr -d ' '` case $mode in "n") word="added" ;; "d") word="removed" ;; "c") word="updated" ;; esac if [ $chars -gt 1 ] ; then if [ $lines -gt 1 ] ; then plural="s"; fi echo "$lines file$plural from package $package were $word between tags $prev and $tag:" unset plural cat $tmp.out.3 else echo "0 files from package $package were $word between tags $prev and $tag." fi fi exit 0