186d7f5d3SJohn Marino#! /bin/sh 286d7f5d3SJohn Marino 386d7f5d3SJohn Marino# rcsfreeze - assign a symbolic revision number to a configuration of RCS files 486d7f5d3SJohn Marino 586d7f5d3SJohn Marino# $FreeBSD: src/gnu/usr.bin/rcs/rcsfreeze/rcsfreeze.sh,v 1.8.2.1 2001/03/05 13:08:40 ru Exp $ 686d7f5d3SJohn Marino# $DragonFly: src/gnu/usr.bin/rcs/rcsfreeze/rcsfreeze.sh,v 1.3 2008/07/21 23:42:01 swildner Exp $ 786d7f5d3SJohn Marino 886d7f5d3SJohn Marino# The idea is to run rcsfreeze each time a new version is checked 986d7f5d3SJohn Marino# in. A unique symbolic revision number (C_[number], where number 1086d7f5d3SJohn Marino# is increased each time rcsfreeze is run) is then assigned to the most 1186d7f5d3SJohn Marino# recent revision of each RCS file of the main trunk. 1286d7f5d3SJohn Marino# 1386d7f5d3SJohn Marino# If the command is invoked with an argument, then this 1486d7f5d3SJohn Marino# argument is used as the symbolic name to freeze a configuration. 1586d7f5d3SJohn Marino# The unique identifier is still generated 1686d7f5d3SJohn Marino# and is listed in the log file but it will not appear as 1786d7f5d3SJohn Marino# part of the symbolic revision name in the actual RCS file. 1886d7f5d3SJohn Marino# 1986d7f5d3SJohn Marino# A log message is requested from the user which is saved for future 2086d7f5d3SJohn Marino# references. 2186d7f5d3SJohn Marino# 2286d7f5d3SJohn Marino# The shell script works only on all RCS files at one time. 2386d7f5d3SJohn Marino# It is important that all changed files are checked in (there are 2486d7f5d3SJohn Marino# no precautions against any error in this respect). 2586d7f5d3SJohn Marino# file names: 2686d7f5d3SJohn Marino# {RCS/}.rcsfreeze.ver version number 2786d7f5d3SJohn Marino# {RCS/}.rscfreeze.log log messages, most recent first 2886d7f5d3SJohn Marino 2986d7f5d3SJohn MarinoPATH=/bin:/usr/bin:$PATH 3086d7f5d3SJohn Marinoexport PATH 3186d7f5d3SJohn Marino 3286d7f5d3SJohn MarinoDATE=`LC_ALL=C date` || exit 3386d7f5d3SJohn Marino# Check whether we have an RCS subdirectory, so we can have the right 3486d7f5d3SJohn Marino# prefix for our paths. 3586d7f5d3SJohn Marinoif test -d RCS 3686d7f5d3SJohn Marinothen RCSDIR=RCS/ EXT= 3786d7f5d3SJohn Marinoelse RCSDIR= EXT=,v 3886d7f5d3SJohn Marinofi 3986d7f5d3SJohn Marino 4086d7f5d3SJohn Marino# Version number stuff, log message file 4186d7f5d3SJohn MarinoVERSIONFILE=${RCSDIR}.rcsfreeze.ver 4286d7f5d3SJohn MarinoLOGFILE=${RCSDIR}.rcsfreeze.log 4386d7f5d3SJohn Marino# Initialize, rcsfreeze never run before in the current directory 4486d7f5d3SJohn Marinotest -r $VERSIONFILE || { echo 0 >$VERSIONFILE && >>$LOGFILE; } || exit 4586d7f5d3SJohn Marino 4686d7f5d3SJohn Marino# Get Version number, increase it, write back to file. 4786d7f5d3SJohn MarinoVERSIONNUMBER=`cat $VERSIONFILE` && 4886d7f5d3SJohn MarinoVERSIONNUMBER=`expr $VERSIONNUMBER + 1` && 4986d7f5d3SJohn Marinoecho $VERSIONNUMBER >$VERSIONFILE || exit 5086d7f5d3SJohn Marino 5186d7f5d3SJohn Marino# Symbolic Revision Number 5286d7f5d3SJohn MarinoSYMREV=C_$VERSIONNUMBER 5386d7f5d3SJohn Marino# Allow the user to give a meaningful symbolic name to the revision. 5486d7f5d3SJohn MarinoSYMREVNAME=${1-$SYMREV} 5586d7f5d3SJohn Marinoecho >&2 "rcsfreeze: symbolic revision number computed: \"${SYMREV}\" 5686d7f5d3SJohn Marinorcsfreeze: symbolic revision number used: \"${SYMREVNAME}\" 5786d7f5d3SJohn Marinorcsfreeze: the two differ only when rcsfreeze invoked with argument 5886d7f5d3SJohn Marinorcsfreeze: give log message, summarizing changes (end with EOF or single '.')" \ 5986d7f5d3SJohn Marino || exit 6086d7f5d3SJohn Marino 6186d7f5d3SJohn Marino# Stamp the logfile. Because we order the logfile the most recent 6286d7f5d3SJohn Marino# first we will have to save everything right now in a temporary file. 6386d7f5d3SJohn MarinoTMPLOG=/tmp/rcsfrz$$ 6486d7f5d3SJohn Marinotrap 'rm -f $TMPLOG; exit 1' 1 2 13 15 6586d7f5d3SJohn Marino# Now ask for a log message, continuously add to the log file 6686d7f5d3SJohn Marino( 6786d7f5d3SJohn Marino echo "Version: $SYMREVNAME($SYMREV), Date: $DATE 6886d7f5d3SJohn Marino-----------" || exit 6986d7f5d3SJohn Marino while read MESS 7086d7f5d3SJohn Marino do 7186d7f5d3SJohn Marino case $MESS in 7286d7f5d3SJohn Marino .) break 7386d7f5d3SJohn Marino esac 7486d7f5d3SJohn Marino echo " $MESS" || exit 7586d7f5d3SJohn Marino done 7686d7f5d3SJohn Marino echo "----------- 7786d7f5d3SJohn Marino" && 7886d7f5d3SJohn Marino cat $LOGFILE 7986d7f5d3SJohn Marino) >$TMPLOG && 8086d7f5d3SJohn Marino 8186d7f5d3SJohn Marino# combine old and new logfiles 8286d7f5d3SJohn Marinocp $TMPLOG $LOGFILE && 8386d7f5d3SJohn Marinorm -f $TMPLOG && 8486d7f5d3SJohn Marino 8586d7f5d3SJohn Marino# Now the real work begins by assigning a symbolic revision number 8686d7f5d3SJohn Marino# to each rcs file. Take the most recent version on the default branch. 8786d7f5d3SJohn Marino 8886d7f5d3SJohn Marino# If there are any .*,v files, throw them in too. 8986d7f5d3SJohn Marino# But ignore RCS/.* files that do not end in ,v. 9086d7f5d3SJohn MarinoDOTFILES= 9186d7f5d3SJohn Marinofor DOTFILE in ${RCSDIR}.*,v 9286d7f5d3SJohn Marinodo 9386d7f5d3SJohn Marino if test -f "$DOTFILE" 9486d7f5d3SJohn Marino then 9586d7f5d3SJohn Marino DOTFILES="${RCSDIR}.*,v" 9686d7f5d3SJohn Marino break 9786d7f5d3SJohn Marino fi 9886d7f5d3SJohn Marinodone 9986d7f5d3SJohn Marino 10086d7f5d3SJohn Marinoexec rcs -q -n$SYMREVNAME: ${RCSDIR}*$EXT $DOTFILES 101