NetBSD/gnu/usr.bin/rcs/rcsfreeze/rcsfreeze.sh

102 lines
3.2 KiB
Bash
Raw Normal View History

1993-07-09 05:56:50 +04:00
#! /bin/sh
# rcsfreeze - assign a symbolic revision number to a configuration of RCS files
# $NetBSD: rcsfreeze.sh,v 1.4 1998/09/12 21:02:50 frueauf Exp $
1996-10-15 10:59:14 +04:00
#
# Id: rcsfreeze.sh,v 4.6 1993/11/03 17:42:27 eggert Exp
1993-07-09 05:56:50 +04:00
# The idea is to run rcsfreeze each time a new version is checked
# in. A unique symbolic revision number (C_[number], where number
# is increased each time rcsfreeze is run) is then assigned to the most
# recent revision of each RCS file of the main trunk.
#
# If the command is invoked with an argument, then this
# argument is used as the symbolic name to freeze a configuration.
# The unique identifier is still generated
# and is listed in the log file but it will not appear as
# part of the symbolic revision name in the actual RCS file.
#
# A log message is requested from the user which is saved for future
# references.
#
# The shell script works only on all RCS files at one time.
# It is important that all changed files are checked in (there are
# no precautions against any error in this respect).
# file names:
# {RCS/}.rcsfreeze.ver version number
# {RCS/}.rscfreeze.log log messages, most recent first
PATH=/bin:/usr/bin:$PATH
1993-07-09 05:56:50 +04:00
export PATH
DATE=`date` || exit
# Check whether we have an RCS subdirectory, so we can have the right
# prefix for our paths.
1995-02-24 05:24:53 +03:00
if test -d RCS
then RCSDIR=RCS/ EXT=
else RCSDIR= EXT=,v
1993-07-09 05:56:50 +04:00
fi
# Version number stuff, log message file
VERSIONFILE=${RCSDIR}.rcsfreeze.ver
LOGFILE=${RCSDIR}.rcsfreeze.log
# Initialize, rcsfreeze never run before in the current directory
1995-02-24 05:24:53 +03:00
test -r $VERSIONFILE || { echo 0 >$VERSIONFILE && >>$LOGFILE; } || exit
1993-07-09 05:56:50 +04:00
# Get Version number, increase it, write back to file.
VERSIONNUMBER=`cat $VERSIONFILE` &&
VERSIONNUMBER=`expr $VERSIONNUMBER + 1` &&
echo $VERSIONNUMBER >$VERSIONFILE || exit
# Symbolic Revision Number
SYMREV=C_$VERSIONNUMBER
# Allow the user to give a meaningful symbolic name to the revision.
SYMREVNAME=${1-$SYMREV}
echo >&2 "rcsfreeze: symbolic revision number computed: \"${SYMREV}\"
rcsfreeze: symbolic revision number used: \"${SYMREVNAME}\"
rcsfreeze: the two differ only when rcsfreeze invoked with argument
rcsfreeze: give log message, summarizing changes (end with EOF or single '.')" \
|| exit
# Stamp the logfile. Because we order the logfile the most recent
# first we will have to save everything right now in a temporary file.
TMPLOG=/tmp/rcsfrz$$
trap 'rm -f $TMPLOG; exit 1' 1 2 13 15
# Now ask for a log message, continously add to the log file
(
echo "Version: $SYMREVNAME($SYMREV), Date: $DATE
-----------" || exit
while read MESS
do
case $MESS in
.) break
esac
echo " $MESS" || exit
done
echo "-----------
" &&
cat $LOGFILE
) >$TMPLOG &&
# combine old and new logfiles
cp $TMPLOG $LOGFILE &&
1995-02-24 05:24:53 +03:00
rm -f $TMPLOG &&
1993-07-09 05:56:50 +04:00
# Now the real work begins by assigning a symbolic revision number
1995-02-24 05:24:53 +03:00
# to each rcs file. Take the most recent version on the default branch.
1993-07-09 05:56:50 +04:00
1995-02-24 05:24:53 +03:00
# If there are any .*,v files, throw them in too.
# But ignore RCS/.* files that do not end in ,v.
DOTFILES=
for DOTFILE in ${RCSDIR}.*,v
1993-07-09 05:56:50 +04:00
do
1995-02-24 05:24:53 +03:00
if test -f "$DOTFILE"
then
DOTFILES="${RCSDIR}.*,v"
break
fi
1993-07-09 05:56:50 +04:00
done
1995-02-24 05:24:53 +03:00
exec rcs -q -n$SYMREVNAME: ${RCSDIR}*$EXT $DOTFILES