[m-rev.] update cvdd
Zoltan Somogyi
zs at cs.mu.OZ.AU
Mon Nov 5 17:10:04 AEDT 2001
A new, more accurate version of cvdd.
tools/cvsfiles:
Cvsfiles is a new script. It takes a directory name as its argument,
and outputs the ordinary files in that directory under CVS control.
tools/cvsdirs:
Cvsdirs is a new script. It takes a directory name as its argument,
and outputs the subdirectories in that directory under CVS control.
tools/cvdd:
This new version of cvdd uses cvsfiles and cvsdirs, instead of guesses
based on the directory name, to decide what files to compare in each
subdirectory of the two workspaces being compared. It also allows
one to record, in files named NEWFILES and NEWDIRS, new files and/or
directories one has added that have not yet been put under CVS control
(for use when disconnected).
Zoltan.
cvs diff: Diffing .
Index: cvdd
===================================================================
RCS file: /home/mercury1/repository/mercury/tools/cvdd,v
retrieving revision 1.3
diff -u -b -r1.3 cvdd
--- cvdd 2001/08/08 03:28:30 1.3
+++ cvdd 2001/10/28 11:04:31
@@ -7,10 +7,15 @@
# "cvd diff work_ws". It is not intended to be a full replacement, e.g.
# it doesn't do anything meaningful if you add an entire new directory.
+pathname="."
diffopts=""
while test $# -gt 0
do
case "$1" in
+ -p)
+ pathname="$2"
+ shift ; shift
+ ;;
-*)
diffopts="$diffopts $1"
shift
@@ -32,144 +37,86 @@
exit 1
fi
-rawdiff="/tmp/.tmpa_$$"
-script="/tmp/.tmpb_$$"
-newfilelist="/tmp/.tmpc_$$"
-excludefile="/tmp/.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*
-rl_file.m
-rl_out.m
-maybe_mlds_to_gcc.m
-"
-
-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
-"
-
-exclude_doc="
-library-menu*
-library-chapters*
-mercury_library.info*
-*.html
-*.1
-*.aux
-*.toc
-*.log
-*.dvi_log
-*.info
-*.info-*
-"
-
-exclude_other="
-bindist.build_vars
-"
+case "$pathname" in
+./*)
+ pathname=`expr $pathname : '\./\(.*\)'`
+ ;;
+esac
-root=`/bin/pwd`
-cd $1
+echo "Diffing $pathname"
-dirs=""
-for d in *
-do
- if test -d $d -a -r $d/CVS/Entries
+filelist="/tmp/cvdd_files$$"
+dirlist="/tmp/cvdd_dirs$$"
+trap "/bin/rm -f $filelist $dirlist > /dev/null 2>&1" 0 1 2 3 15
+
+(
+ cvsfiles $1
+ cvsfiles $2
+ if test -f $1/NEWFILES
then
- dirs="$dirs $d"
+ cat $1/NEWFILES
fi
-done
-cd $root
-
-for d in $dirs
-do
- case $d in
- browser|compiler|deep|library|extras|samples)
- echo "$exclude_all $exclude_m" | sed -e '/^ *$/d' > $excludefile
- kind="mercury" ;;
- runtime|trace|util|bytecode|robdd)
- echo "$exclude_all $exclude_c" | sed -e '/^ *$/d' > $excludefile
- kind="c" ;;
- doc)
- echo "$exclude_all $exclude_doc" | sed -e '/^ *$/d' > $excludefile
- kind="doc" ;;
- *)
- echo "$exclude_all $exclude_other" | sed -e '/^ *$/d' > $excludefile
- kind="other" ;;
- esac
-
- if test -r $HOME/.cvdd_exclude
+ if test -f $2/NEWFILES
then
- cat $HOME/.cvdd_exclude >> $excludefile
+ cat $2/NEWFILES
fi
+) | sort -u > $filelist
- if test -r $1/$d/.exclude
+(
+ cvsdirs $1
+ cvsdirs $2
+ if test -f $1/NEWDIRS
then
- cat $1/$d/.exclude >> $excludefile
+ cat $1/NEWDIRS
fi
-
- if test -r $2/$d/.exclude
+ if test -f $2/NEWDIRS
then
- cat $2/$d/.exclude >> $excludefile
+ cat $2/NEWDIRS
fi
+) | sort -u > $dirlist
- exclude_opt="--exclude-from=$excludefile"
- diff -r $diffopts $exclude_opt "$1"/$d "$2"/$d | egrep -v '^Binary' > $rawdiff
- cat > $script << EOF
-BEGIN { kind = "$kind"; }
-\$1 == "Only" {
- len = length(\$4);
- suffix = substr(\$4, len-1, 2);
- if (kind == "c" && (suffix == ".c" || suffix == ".h"))
- {
- printf "%s\n", \$4;
- }
- else if (kind == "mercury" && suffix == ".m")
- {
- printf "%s\n", \$4;
- }
- }
-EOF
+for file in `cat $filelist`
+do
+ if test -f "$1/$file" -a -f "$2/$file"
+ then
+ diff $diffopts "$1/$file" "$2/$file"
+ elif test -f "$1/$file"
+ then
+ echo "old file $1/$file"
+ cat "$1/$file"
+ elif test -f "$2/$file"
+ then
+ echo "new file $2/$file"
+ cat "$2/$file"
+ else
+ echo "neither $1/$file nor $2/$file exist"
+ fi
+done
- echo "Diffing $d"
- egrep -v '^Only' $rawdiff | egrep -v '^diff'
- awk -f $script < $rawdiff > $newfilelist
- if test -s $newfilelist
+for dir in `cat $dirlist`
+do
+ if test -d "$1/$dir/CVS" -a -d "$2/$dir/CVS"
+ then
+ cvdd -p "$pathname/$dir" $diffopts "$1/$dir" "$2/$dir"
+ elif test -d "$1/$dir/CVS"
then
- for f in `cat $newfilelist`
- do
- echo new file $f
- more "$2/$d/$f"
- done
+ echo "old dir $1/$dir"
+ if test -f "$1/$dir/NEWDIRFILES"
+ then
+ more `cat $1/$dir/NEWDIRFILES`
+ else
+ more $1/$dir/*
+ fi
+ elif test -d "$2/$dir/CVS"
+ then
+ echo "new dir $2/$dir"
+ if test -f "$2/$dir/NEWDIRFILES"
+ then
+ more `cat $2/$dir/NEWDIRFILES`
+ else
+ more $2/$dir/*
+ fi
+ else
+ echo "neither $1/$dir nor $2/$dir exist"
fi
done
Index: cvsdirs
===================================================================
RCS file: cvsdirs
diff -N cvsdirs
--- /dev/null Fri Dec 1 02:25:58 2000
+++ cvsdirs Sun Oct 28 21:32:40 2001
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+if test $# = 0
+then
+ prefix=""
+elif test $# = 1 -a -d $1
+then
+ prefix="$1/"
+else
+ echo "usage: cvsfiles [dirname]"
+ exit 1
+fi
+
+tmpfile=/tmp/cvsfiles$$
+trap "/bin/rm -f $tmpfile" 0 1 2 3 15
+cat > $tmpfile << 'EOF'
+BEGIN { FS = "/"; }
+/^D\// {
+ printf "%s\n", $2;
+ }
+EOF
+awk -f $tmpfile ${prefix}CVS/Entries
Index: cvsfiles
===================================================================
RCS file: cvsfiles
diff -N cvsfiles
--- /dev/null Fri Dec 1 02:25:58 2000
+++ cvsfiles Sun Oct 28 21:32:37 2001
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+if test $# = 0
+then
+ prefix=""
+elif test $# = 1 -a -d $1
+then
+ prefix="$1/"
+else
+ echo "usage: cvsfiles [dirname]"
+ exit 1
+fi
+
+tmpfile=/tmp/cvsfiles$$
+trap "/bin/rm -f $tmpfile" 0 1 2 3 15
+cat > $tmpfile << 'EOF'
+BEGIN { FS = "/"; }
+/^\// {
+ printf "%s\n", $2;
+ }
+EOF
+awk -f $tmpfile ${prefix}CVS/Entries
--------------------------------------------------------------------------
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