head     1.1;
access   ;
symbols  ;
locks    ; strict;
comment  @# @;


1.1
date     89.09.21.18.32.32;  author jimm;  state Exp;
branches ;
next     ;


desc
@script file to build RCS change log files
@



1.1
log
@Initial revision
@
text
@#!/bin/csh -f
# cilog -- check in CHANGED and MISSING files from logfile created by 
#	changelog.  May specify RCS directory and Log file on command line,
#	overriding defaults and even environment settings.
#
#  BUGS: should check that lock exists, with override available

	
    set usage = ($0 -d rcsdir -f logfile -m message)

    # uses same argument/environment/default scheme as changelog

    if ($?RCSDIR) then
	set RCSdir = $RCSDIR
    else
	set RCSdir = ./RCS
    endif

    if ($?RCSLOCK) then
	set rcslock = $RCSLOCK
    else
	set rcslock = RCSLock
    endif

    if ($?RCSLOG) then
	set logfile = $RCSLOG
    else
	set logfile = Log
    endif

    set logmessage = ""
    set nolock = 0

    while ($#argv > 0)
	switch ($argv[1])
	case -d:
	    if ($#argv == 1) then
		echo RCS directory specifier missing
		echo usage: $usage
		exit (1)
	    endif
	    set RCSdir = $argv[2]
	    shift
	    breaksw
	case -f:
	    if ($#argv == 1) then
		echo logfile name missing
		echo usage: $usage
		exit (1)
	    endif
	    set logfile = $argv[2]
	    shift
	    breaksw
	case -m:
	    if ($#argv == 1) then
		echo message missing
		echo usage: $usage
		exit (1)
	    endif
	    set logmessage = "-m$argv[2]"
	    shift
	    breaksw
	case -l:
	    if ($#argv == 1) then
		echo lock file name missing
		echo usage: $usage
		exit (1)
	    endif
	    set rcslock = $argv[2]
	    if ($dbug) echo rcslock = $rcslock
	    shift
	    breaksw
	case -u:
	    set nolock = 1
	    breaksw
	default:
	    echo usage: $usage
	endsw
	shift
    end

    set srcdir=$RCSdir/..	# copy changed source to this here

    echo checking in files from log: $logfile
    echo RCS directory: $RCSdir
    if (! $nolock) echo using lock $rcslock
    echo " "

    # FIX: could check that locks match
    if (! $nolock) then
	if (! -f $RCSdir/$rcslock) then
	    echo 'Directory not locked'
	    exit (2)
	endif
    endif

    #set fstr = $RCSdir/%s,v\\n
    set fstr = $RCSdir/%s,v
    set noglob

    #    set  astr = ({print \$1; printf \"$fstr \", \$1})
    #args are like this: file.c /usr/com.../intuition/RCS/file.c,v

    # just the RCS pathnames
    set  astr = ({printf \"$fstr \", \$1})

    # local pathnames
    set  locstr = ({printf \"%s \", \$1 })

    # alternatively, could loop, doing rcsdiff and ci
    set fileargs = `tail +2 $logfile | egrep '(MISSING|CHANGED)' | awk "$astr"`
    set notmissing = `tail +2 $logfile | fgrep 'CHANGED' | awk "$astr"`

    #set locals = `tail +2 $logfile | egrep '(MISSING|CHANGED)' | awk "$locstr"`

    #echo locals: $locals
    #echo fileargs:$fileargs
    #echo notmissing:$notmissing

    co -l -p $notmissing > /dev/null
    if ( $logmessage != "") then
	ci -u -m "$logmessage" $fileargs
    else
	ci -u $fileargs
    endif

    # check out fresh copies in source directory
    pushd $srcdir
    co $fileargs
    popd

    #cp $locals $srcdir
    
    echo " "
    echo now be sure to go update the source directory from
    echo RCS and say make.
    echo " "

    # 'ci -u should be enough' co $fileargs
    # note that you must check-out to get correct version number,
    # and read-only permissions; saving file not good enough

    echo 'remember to lock RCS directory (unlocklog) if done.'
@
