[mod.sources] checkin: editor interface for RCS logs

sources-request@genrad.UUCP (05/14/85)

From: fosterm@ogcvax.UUCP

This tool provides 
	-- an editor interface for creating RCS log messages.
	-- automatic RCS checkin using just-created logs.

If you are a user of RCS, and find yourself frequently using `rcsdiff`
to create a log messages, `checkin` may be useful.  Additionally, checkin
retains a log message, once created, if, for some reason the RCS checkin 
procedure `ci` fails.

The man page and csh script, in shar format, are included below.

`checkin` has been in use by several users on our Vaxen for a few months.
We are running 4.2bsd.

--
Mark Foster
Oregon Graduate Center

usenet: {allegra,tektronix,reed}!ogcvax!fosterm
csnet:  fosterm @ oregon-grad

=======cut here======
# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by ogcvax!fosterm on Sat May 11 17:54:33 PDT 1985
# Contents:  checkin.1 checkin.csh
 
echo x - checkin.1
sed 's/^@//' > "checkin.1" <<'@//E*O*F checkin.1//'
@.TH checkin 1L "OGC 3/11/85"
@.SH NAME
checkin \- editor interface to rcs `ci`
@.SH SYNOPSIS
@.B checkin
@.I "[file1 file2 ...]"
@.SH DESCRIPTION
@.LP
\fBcheckin\fR provides for the creation of rcs logs to be used
in rcs ci(1) procedures.
For each file specified, \fBcheckin\fR does an rcsdiff(1) on the
file and the latest checked-in version of that file.
If a difference exists, EDITOR is invoked on a temporary file
containing the diff.
The user creates a log based on the diff, saves the temporary file,
and exits the editor.
The query:
@.IP 
\fLWant to checkin "file" with log? (y)\fR
@.LP
Allows the user to verify the checkin with the just-created log.
If checkin is to proceed, reply with one of \fI<CR>, y, yes\fR.
If a checkin with the just-created log is not desired, reply with \fIn\fR.
@.LP
The actual `ci` process for the verified logs starts once all logs
for all files have been created.
@.LP
checkin examines the environment variables EDITOR and CHECKIN.
If EDITOR is set, it specifies the editor to invoke on the temporary
file; `vi` is used by default.
If CHECKIN is set, it specifies the `ci` options to use during
the checkin; "-l" (the letter ell) is used by default, this
checks the file back out locked.
@.SH FILES
/tmp/CI.*.$$  -- temporary files, removed on completion 
@.br
_log.*.$$ -- saved log files if `ci` error.
@.SH AUTHOR
Mark Foster (Oregon Graduate Center, Beaverton, OR)
.br
usenet: {allegra,tektronix,reed}!ogcvax!fosterm
.br
csnet:  fosterm @ oregon-grad
@.SH "SEE ALSO"
ci(1), rcsdiff(1), csh(1)
@.SH DIAGNOSTICS
@.LP
If there is an error on the rcsdiff of a file (i.e.,  the file has
not been checked in before, so this is the initial version), the
error message is used for the edit buffer, rather than the diff.
@.LP
If the `ci` for a file fails, the log is saved in a "unique" file
in the current directory, using the source filename as part of the log 
filename. 
@.SH BUGS
@.LP
This process relies on a fast-starting, fast-exiting editor to be 
interactively useful.
@.SH NOTES
@.LP
Users of vi(1) may find a macro "kill to end of buffer" useful to
delete the diff once the log is created.  Include in ~/.exrc the line
@.IP
map K :+1,$ d ^V^M
@//E*O*F checkin.1//
chmod u=rw,g=r,o=r checkin.1
 
echo x - checkin.csh
sed 's/^@//' > "checkin.csh" <<'@//E*O*F checkin.csh//'
#! /bin/csh -f
# checkin  -- prompt user to create log files, then do `ci -l` for the
#	      files that have a log.
#
# 03/85 mhfoster, ogc
#
# usage:
#	checkin [file1 file2 ...]
#
# For each file specified on the command line:
#
# If there was a difference in the checked-out version
# and the latest checked-in version OR the rcsdiff failed,
# put the user into their editor, editing the diff (or fail 
# message).  This allows a user to peruse the diff, and create 
# a comment based on such.  (Alternatively, a separate message 
# could be defined and included while in the editor.)
#
# Once a group of log files has been created, the source files are
# checked-in using the defined log files.
#
# Notes:
#  If environment variable CHECKIN is set, it specifies `ci` options;
#  default is -l for "check back out locked".
#  If environment variable EDITOR is set, it specifies the editor to use;
#  default is `vi`.
#
onintr quiter

set cmd = $0
set cmd = $cmd:t
if ($#argv < 1) then
	echo "usage: $cmd file1 file2 ..."
	exit
endif

set cilist = ""
set tmpdir = "/tmp"
set versfile = $tmpdir/CI.v.$$
set diffile = $tmpdir/CI.d.$$
if ($?EDITOR) then
	set editor = $EDITOR
else
	set editor = "vi"
endif
if ($?CHECKIN) then
	set ciopts = "$CHECKIN"
else
	set ciopts = "-l"
endif

foreach f ($*)
	if (-d "$f") then
		echo "Cannot checkin: $f  is a directory"
	else
		echo "Checking for differences in $f"
		set tmplogf = $tmpdir/CI.d.${f:t}.$$
		set loclogf = _log.${f:t}.$$
		(rcsdiff $f > $diffile) |& tee $versfile

		set diffstat = "$status"
		if ( !(-z $diffile) || ($diffstat)) then
			cat $versfile $diffile > $tmplogf
			if ($diffstat) then
echo "Enter Description (this is NOT the log message)" >> $tmplogf
			endif
			$editor $tmplogf
			echo -n "Want to checkin $f with the log? (y) "
			set r = "$<"
			if (($r =~ "") || ($r =~ y*)) then
				mv $tmplogf $loclogf
				set cilist = "$cilist $f"
			endif
		endif
	endif
end
if ($cilist != "") then
	echo " "
	echo "Performing checkin of:"
	echo "$cilist"
	echo " "
endif
# this portion is separated from the above loop so the user doesn't have
# to interactively wait for the actual rcs checkin (ci) process to finish
foreach f ($cilist)
	set loclogf = _log.${f:t}.$$
	if (! (-z $f)) then
		ci $ciopts $f < $loclogf
		if (! $status) then
			rm $loclogf
		else
			"$cmd, ci error, log saved: $loclogf"
		endif
	else
		"$cmd error: $f does not exist (cannot checkin)"
	endif
end
rm $tmpdir/CI*.$$
exit

quiter:
echo "$cmd, Abort."
rm $tmpdir/CI*.$$
exit
@//E*O*F checkin.csh//
chmod u=rwx,g=rx,o=rx checkin.csh
 
echo Inspecting for damage in transit...
temp=/tmp/shar$$; dtemp=/tmp/.shar$$
trap "rm -f $temp $dtemp; exit" 0 1 2 3 15
cat > $temp <<\!!!
      60     367    2067 checkin.1
     104     442    2511 checkin.csh
     164     809    4578 total
!!!
wc  checkin.1 checkin.csh | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp
if [ -s $dtemp ]
then echo "Ouch [diff of wc output]:" ; cat $dtemp
else echo "No problems found."
fi
exit 0