[m-dev.] for review: add cvdr to tools.

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Jan 19 18:38:06 AEDT 2001


On 19-Jan-2001, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> Index: tools/cvdr
> ===================================================================
> RCS file: cvdr
> diff -N cvdr
> --- /dev/null	Tue Nov 21 11:53:28 2000
> +++ cvdr	Fri Jan 19 16:50:39 2001
> @@ -0,0 +1,55 @@
> +#!/bin/sh
> +# cvdr - show the most recent changes to a file stored with CVS
> +#
> +# Starting from the most recent version of the currently checked out
> +# branch, cvdr will display the log message and diff of each change made
> +# to the file, down to the initial version.  Each file on the command
> +# line is processed in turn.
> +#
> +# Originally written by Fergus Henderson <fjh at cs.mu.oz.au>
> +# Hacked to support branches by Tyson Dowd <trd at cs.mu.oz.au>
> +#
> +# Known bugs: doesn't handle the case where the initial version is on a
> +# branch -- in other words this script assumes the initial version is 1.1
> +# Fixing this is a bit tricky.
> +
> +options=
> +while true; do
> +	case "$1" in
> +		-*)	options="$options $1"
> +			shift
> +			;;
> +		*)	break
> +			;;
> +	esac
> +done
> +
> +for file in "$@"; do
> +{
> +topversion="`cvs status $file 2>/dev/null | awk '
> +	/  Repository revision:/ 		{ print $3; exit; }	
> +'`"
> +
> +branch=`expr match $topversion '\(\([0-9]*\.\)*[0-9]*\)\.[0-9]*'`
> +N=`expr match $topversion "$branch\.\([0-9]*\)"` 
> +
> +echo "Revision $branch.$N"
> +
> +while [ "$branch" != "" ]; do
> +	while [ $N -gt 1 ]; do
> +		N1=`expr $N - 1`
> +		echo cvs log -r$branch.$N $options "$file"
> +		cvs -n log -N -r$branch.$N $options "$file"
> +		echo cvs diff -u -r$branch.$N1 -r$branch.$N $options "$file"
> +		cvs -n diff -u -r$branch.$N1 -r$branch.$N $options "$file"
> +		N=$N1
> +		echo "Revision $branch.$N"
> +	done 
> +	newbranch=`expr match $branch '\(\([0-9]*\.\)*[0-9]*\)\.[0-9]*\.[0-9]*'`
> +	N=`expr match $branch "$newbranch\.\([0-9]*\)"` 
> +	branch=$newbranch
> +done
> +
> +cvs checkout -p -r1.1 `sed "s^.*/imp/^^" CVS/Repository`/"$file" 2>&1
> +} | ${PAGER:-more}
> +done

My version has several improvements on that.  Maybe I made those
improvements after you copied the version in ~fjh/bin/scripts.

First, I pipe the output of `cvs log' through `sed'
to delete the initial junk that is the same for every revision:

    instead of
	cvs -n log -N -r$branch.$N $options "$file"
    use
	cvs -n log -N -r$branch.$N $options "$file" | sed '1,/^-------/d'
						    ^^^^^^^^^^^^^^^^^^^^^
Second, when printing out the initial revision, my version
also prints out the log message for it:

    add
	echo cvs log -N -r1.1 $options "$file"
	cvs log -N -r1.1 $options "$file" | sed '1,/^-------/d'
    before
	cvs checkout -p -r1.1 ...

Third, the "/imp/" bit assumes that your repository name ends in "/imp".
My version use $CVSROOT instead:

    instead of
	cvs checkout -p -r1.1 `sed "s^.*/imp/^^" CVS/Repository`/"$file" 2>&1
    use
	cvs checkout -p -r1.1 `sed "s^$CVSROOT/^^" CVS/Repository`/"$file" 2>&1
-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list