[m-rev.] for review: cvdd

Zoltan Somogyi zs at cs.mu.OZ.AU
Fri Apr 27 16:05:45 AEST 2001


For review by anyone. Also, if anyone who wants to extend the script to handle
other subdirectories (e.g. bindist) is welcome to do so.

The references to the deep subdirectory will be committed on the main branch
only after deep profiling itself is committed.

tools/cvdd:
	A script for performing a diff between the main directories of
	two Mercury workspaces. It is meant to be useful if you are not
	connected to a network and therefore unable to "cvs add" files;
	in such circumstances, doing a "cvdd clean_ws work_ws" can be
	a sufficiently good substitute for a "cvd diff work_ws".

Zoltan.

#!/bin/sh
if test $# -ne 2
then
	echo "usage: cvdd dir1 dir2"
	exit 1
fi

rawdiff=".tmpa_$$"
script=".tmpb_$$"
newfilelist=".tmpc_$$"
excludefile=".tmpd_$$"
trap "/bin/rm -f $rawdiff $script $newfilelist $excludefile > /dev/null 2>&1" 0 1 2 3 15

exclude_all="
CVS
CVU
INSTALL
README
REDUNDANT_FILES
Log*
errs
tags
.*
"

exclude_m="
bindist.build.vars
configure
make_all.log
Mmake.*params*
Mmake.common
*.c
*.h
*.d*
*.err
*.int*
*.*opt*
*.*date*
[A-Z]*.m
[A-Z]*.h
"

exclude_c="
bindist.build.vars
configure
make_all.log
Mmake.params
Mmake.stage.params
Mmake.params.runtime
Mmake.params.trace
Mmake.common
mercury_conf.h
[A-Z]*.c
[A-Z]*.h
"

exclude_doc="
library-menu*
library-chapters*
mercury_library.info*
*.html
*.1
*.aux
*.toc
*.log
*.info
*.info-8
"

for d in browser compiler deep doc library runtime scripts trace tools util
do
	case $d in
	browser|compiler|deep|library)
		echo "$exclude_all $exclude_m" | sed -e '/^ *$/d' > $excludefile
		kind="m" ;;
	runtime|trace|util)
		echo "$exclude_all $exclude_c" | sed -e '/^ *$/d' > $excludefile
		kind="c" ;;
	doc)
		echo "$exclude_all $exclude_doc" | sed -e '/^ *$/d' > $excludefile
		kind="d" ;;
	*)
		echo "$exclude_all" | sed -e '/^ *$/d' > $excludefile
		kind="o" ;;
	esac

	if test -r $1/$d/.exclude
	then
		cat $1/$d/.exclude >> $excludefile
	fi
	if test -r $2/$d/.exclude
	then
		cat $2/$d/.exclude >> $excludefile
	fi

	exclude_opt="--exclude-from=$excludefile"
	diff -rubB $exclude_opt "$1"/$d "$2"/$d | egrep -v '^Binary' > $rawdiff
	cat > $script << EOF
BEGIN		{ kind = "$kind"; }
\$1 == "Only"	{
			if (\$4 ~ /^\./ || \$4 ~ /^[xyz]/) {
				next;
			}

			if (\$4 == "rl_file.m" || \$4 == "rl_out.m") {
				next;
			}

			len = length(\$4);
			suffix = substr(\$4, len-1, 2);
			if (kind == "c" && (suffix == ".c" || suffix == ".h"))
			{
				printf "%s\n", \$4;
			}
			else if (kind == "m" && suffix == ".m")
			{
				printf "%s\n", \$4;
			}
		}
EOF

	echo "Diffing $d"
	egrep -v '^Only' $rawdiff | egrep -v '^diff'
	awk -f $script < $rawdiff > $newfilelist
	if test -s $newfilelist
	then
		for f in `cat $newfilelist`
		do
			echo new file $f
			more "$2/$d/$f"
		done
	fi
done
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list