rcsfreeze.sh revision 73349
1145516Sdarrenr#! /bin/sh 2145516Sdarrenr 3145516Sdarrenr# rcsfreeze - assign a symbolic revision number to a configuration of RCS files 4145516Sdarrenr 5145516Sdarrenr# $FreeBSD: head/gnu/usr.bin/rcs/rcsfreeze/rcsfreeze.sh 73349 2001-03-02 16:52:14Z ru $ 6145516Sdarrenr 7161351Sguido# The idea is to run rcsfreeze each time a new version is checked 8145516Sdarrenr# in. A unique symbolic revision number (C_[number], where number 9145516Sdarrenr# is increased each time rcsfreeze is run) is then assigned to the most 10145516Sdarrenr# recent revision of each RCS file of the main trunk. 11145516Sdarrenr# 12145516Sdarrenr# If the command is invoked with an argument, then this 13145516Sdarrenr# argument is used as the symbolic name to freeze a configuration. 14145516Sdarrenr# The unique identifier is still generated 15145516Sdarrenr# and is listed in the log file but it will not appear as 16145516Sdarrenr# part of the symbolic revision name in the actual RCS file. 17145516Sdarrenr# 18145516Sdarrenr# A log message is requested from the user which is saved for future 19145516Sdarrenr# references. 20145516Sdarrenr# 21145516Sdarrenr# The shell script works only on all RCS files at one time. 22145516Sdarrenr# It is important that all changed files are checked in (there are 23145516Sdarrenr# no precautions against any error in this respect). 24145516Sdarrenr# file names: 25145516Sdarrenr# {RCS/}.rcsfreeze.ver version number 26145516Sdarrenr# {RCS/}.rscfreeze.log log messages, most recent first 27145516Sdarrenr 28145516SdarrenrPATH=/bin:/usr/bin:$PATH 29145516Sdarrenrexport PATH 30145516Sdarrenr 31145516SdarrenrDATE=`LC_ALL=C date` || exit 32145516Sdarrenr# Check whether we have an RCS subdirectory, so we can have the right 33145516Sdarrenr# prefix for our paths. 34145516Sdarrenrif test -d RCS 35145516Sdarrenrthen RCSDIR=RCS/ EXT= 36145516Sdarrenrelse RCSDIR= EXT=,v 37145516Sdarrenrfi 38145516Sdarrenr 39145516Sdarrenr# Version number stuff, log message file 40145516SdarrenrVERSIONFILE=${RCSDIR}.rcsfreeze.ver 41145516SdarrenrLOGFILE=${RCSDIR}.rcsfreeze.log 42145516Sdarrenr# Initialize, rcsfreeze never run before in the current directory 43145516Sdarrenrtest -r $VERSIONFILE || { echo 0 >$VERSIONFILE && >>$LOGFILE; } || exit 44145516Sdarrenr 45145516Sdarrenr# Get Version number, increase it, write back to file. 46145516SdarrenrVERSIONNUMBER=`cat $VERSIONFILE` && 47145516SdarrenrVERSIONNUMBER=`expr $VERSIONNUMBER + 1` && 48145516Sdarrenrecho $VERSIONNUMBER >$VERSIONFILE || exit 49145516Sdarrenr 50145516Sdarrenr# Symbolic Revision Number 51145516SdarrenrSYMREV=C_$VERSIONNUMBER 52145516Sdarrenr# Allow the user to give a meaningful symbolic name to the revision. 53145516SdarrenrSYMREVNAME=${1-$SYMREV} 54145516Sdarrenrecho >&2 "rcsfreeze: symbolic revision number computed: \"${SYMREV}\" 55145516Sdarrenrrcsfreeze: symbolic revision number used: \"${SYMREVNAME}\" 56145516Sdarrenrrcsfreeze: the two differ only when rcsfreeze invoked with argument 57145516Sdarrenrrcsfreeze: give log message, summarizing changes (end with EOF or single '.')" \ 58145516Sdarrenr || exit 59145516Sdarrenr 60145516Sdarrenr# Stamp the logfile. Because we order the logfile the most recent 61145516Sdarrenr# first we will have to save everything right now in a temporary file. 62145516SdarrenrTMPLOG=/tmp/rcsfrz$$ 63145516Sdarrenrtrap 'rm -f $TMPLOG; exit 1' 1 2 13 15 64145516Sdarrenr# Now ask for a log message, continously add to the log file 65145516Sdarrenr( 66145516Sdarrenr echo "Version: $SYMREVNAME($SYMREV), Date: $DATE 67145516Sdarrenr-----------" || exit 68145516Sdarrenr while read MESS 69145516Sdarrenr do 70145516Sdarrenr case $MESS in 71145516Sdarrenr .) break 72145516Sdarrenr esac 73145516Sdarrenr echo " $MESS" || exit 74145516Sdarrenr done 75145516Sdarrenr echo "----------- 76145516Sdarrenr" && 77145516Sdarrenr cat $LOGFILE 78145516Sdarrenr) >$TMPLOG && 79145516Sdarrenr 80145516Sdarrenr# combine old and new logfiles 81145516Sdarrenrcp $TMPLOG $LOGFILE && 82145516Sdarrenrrm -f $TMPLOG && 83145516Sdarrenr 84145516Sdarrenr# Now the real work begins by assigning a symbolic revision number 85145516Sdarrenr# to each rcs file. Take the most recent version on the default branch. 86145516Sdarrenr 87145516Sdarrenr# If there are any .*,v files, throw them in too. 88145516Sdarrenr# But ignore RCS/.* files that do not end in ,v. 89145516SdarrenrDOTFILES= 90145516Sdarrenrfor DOTFILE in ${RCSDIR}.*,v 91145516Sdarrenrdo 92145516Sdarrenr if test -f "$DOTFILE" 93145516Sdarrenr then 94145516Sdarrenr DOTFILES="${RCSDIR}.*,v" 95145516Sdarrenr break 96161351Sguido fi 97161351Sguidodone 98145516Sdarrenr 99145516Sdarrenrexec rcs -q -n$SYMREVNAME: ${RCSDIR}*$EXT $DOTFILES 100145516Sdarrenr