Path: utzoo!attcan!uunet!ksr!occam!johnm
From: johnm@occam.ksr.com (John Martin)
Newsgroups: comp.software-eng
Subject: Re: Does anyone have tools for use with RCS that they can share?
Keywords: RCS report of files not under source control
Message-ID: <549@ksr.UUCP>
Date: 11 Aug 89 00:06:44 GMT
References: <342@capmkt.COM> <49@array.UUCP>
Sender: nobody@ksr.UUCP
Reply-To: johnm@ksr.UUCP (John Martin)
Organization: Kendall Square Research, Cambridge MA
Lines: 135

In article <342@capmkt.COM> brent@capmkt.COM (Brent Chapman) requests:
>
>  + A report of files in a source tree that are currently checked out,
>    by who, and since when.
>
>  + A report of files in a source tree that have not yet been placed
>    under RCS control.
>
>  + Tools for creating, managing, and using "S-lists", or lists of the
>    various components (and the version of each of those components) in
>    a given product.
>

len@array.UUCP (Leonard Vanek) has recently provided a set of scripts
that can be used for the first of these.  Below I provide a UNIX
script that I sometimes use to perform the second.  I've added some
comments to help any non-experts who want to modify it.  It runs for
me on Sun-3's and -4's; I'd expect any BSD4.x-derived *X to do OK on
it, and I think it would work on a SysV system but don't have one
handy to try it out.  With that caveat:

--------------------------- cut here ------------------------------
#! /bin/sh
#
# find .c, .h, and [Mm]akefile without RCS equivalents
# Usage:  norcs [srcdir] [-r rcsdirspec] [-s wildfilespec] [-v]
# Defaults to norcs . -r RCS
#
#
# John Martin, Kendall Square Research Corp., Waltham, MA
#
#
defaults() {
    srcdir="${srcdir:-.}"
    rcsdir="${rcsdir:-RCS}"
    srcspec="${srcpec:-*.[ch] [Mm]akefile}"
}
#
usage() {
    echo "Usage: norcs [srcdirs] [-s srcspec] [-r rcsdirspec ] [-v]"
    echo "Deflt: norcs . -r RCS -s \"*.[ch] [Mm]akefile\""
    echo " You may have multiple -s and -r options; remember to quote srcspecs"
    echo " to avoid immediate filename expansion."
    exit 1
}
#
verbose() { if [ -z "$vbose" ]; then return 1; else return 0; fi }
# 
# parse the args; you can give as many specs as you want for the source
# and for the RCS specs (i.e., you can do something like
# norcs src/* -r RCS -r /usr/local/include/RCS )
#
while [ ! -z "$1" ]; do
    if [ $1 = "-v" ]; then
        vbose=T
	shift
    elif [ $1 = "-s" ]; then
         if [ -z "$2" ]; then usage; fi
	 srcspec="$srcspec $2"
	 shift 2
    elif [ $1 = "-r" ]; then
        if [ -z "$2" ]; then usage; fi
        rcsdir="$rcsdir $2"
	shift 2
    else
        srcdir="$srcdir $1"
	shift
    fi
done
#  load defaults for anything not found above
defaults

if verbose; then
    echo "Source  spec: < $srcspec >"
    echo "Source  dirs: < $srcdir >"
    echo "RCSfile dirs: < $rcsdir >"
    echo ""
fi
origdir=`pwd`
#
for sd in $srcdir; do
#
#  only report nonexistent source dir's if verbose (makes a better filter)
#
    cd $origdir
    if [ ! -d $sd ]; then
        if verbose; then echo "($sd is not a directory)"; fi
        continue
    fi
#
    cd $sd

# The shell's filename expansion will leave things it can't find; "*.c *.h" 
# may expand to "a.c b.c *.h".  Accordingly, first we check that
# "file" is actually a file.  The -f establishes that file isn't too
# weird, like a directory.  However, a symbolic link to a plain file is
# OK with -f, and we're not interested in symbolic links, so we check
# that separately.  Then we see if the RCS file exists somewhere in
# rcsdir (normally the ./RCS directory relative to the source dir, but
# bigger projects may have special tools and rules).

# Some folks might want to test "-w", on the theory that a file that's
# read-only doesn't need to be checked for RCSness.  That can be a
# bad idea in some development environments, so this script checks
# everything.
#

    for file in $srcspec; do
        if [ ! -f "$file" ]; then continue; fi
        if [ -h $file ]; then continue; fi
        for rd in $rcsdir; do
            if [ -d "$rd" ]; then
                if [ -f $rd/$file,v ]; then continue 2; fi
	    else
		if verbose; then echo " ($rd is not a directory for $sd)"; fi
            fi
        done     # rd (RCS directory)
#
# if we didn't "continue 2", we didn't find the RCS file, so say the name.
        echo $sd/$file
#
    done    #  file
#
done     # sd (source directory)
#
# EOF norcs
--------------------------- cut here ------------------------------


John H. Martin					harvard!ksr!johnm
Kendall Square Research Corporation		johnm@ksr.com
170 Tracer Lane
Waltham, MA 02154
"A creative economy is the fuel of magnificence." -- Emerson
Disclaimer:  My only organizationally-endorsed position is prone.