1#! /bin/sh 2 3# rcsfreeze - assign a symbolic revision number to a configuration of RCS files 4 5# $FreeBSD: src/gnu/usr.bin/rcs/rcsfreeze/rcsfreeze.sh,v 1.8.2.1 2001/03/05 13:08:40 ru Exp $ 6# $DragonFly: src/gnu/usr.bin/rcs/rcsfreeze/rcsfreeze.sh,v 1.3 2008/07/21 23:42:01 swildner Exp $ 7 8# The idea is to run rcsfreeze each time a new version is checked 9# in. A unique symbolic revision number (C_[number], where number 10# is increased each time rcsfreeze is run) is then assigned to the most 11# recent revision of each RCS file of the main trunk. 12# 13# If the command is invoked with an argument, then this 14# argument is used as the symbolic name to freeze a configuration. 15# The unique identifier is still generated 16# and is listed in the log file but it will not appear as 17# part of the symbolic revision name in the actual RCS file. 18# 19# A log message is requested from the user which is saved for future 20# references. 21# 22# The shell script works only on all RCS files at one time. 23# It is important that all changed files are checked in (there are 24# no precautions against any error in this respect). 25# file names: 26# {RCS/}.rcsfreeze.ver version number 27# {RCS/}.rscfreeze.log log messages, most recent first 28 29PATH=/bin:/usr/bin:$PATH 30export PATH 31 32DATE=`LC_ALL=C date` || exit 33# Check whether we have an RCS subdirectory, so we can have the right 34# prefix for our paths. 35if test -d RCS 36then RCSDIR=RCS/ EXT= 37else RCSDIR= EXT=,v 38fi 39 40# Version number stuff, log message file 41VERSIONFILE=${RCSDIR}.rcsfreeze.ver 42LOGFILE=${RCSDIR}.rcsfreeze.log 43# Initialize, rcsfreeze never run before in the current directory 44test -r $VERSIONFILE || { echo 0 >$VERSIONFILE && >>$LOGFILE; } || exit 45 46# Get Version number, increase it, write back to file. 47VERSIONNUMBER=`cat $VERSIONFILE` && 48VERSIONNUMBER=`expr $VERSIONNUMBER + 1` && 49echo $VERSIONNUMBER >$VERSIONFILE || exit 50 51# Symbolic Revision Number 52SYMREV=C_$VERSIONNUMBER 53# Allow the user to give a meaningful symbolic name to the revision. 54SYMREVNAME=${1-$SYMREV} 55echo >&2 "rcsfreeze: symbolic revision number computed: \"${SYMREV}\" 56rcsfreeze: symbolic revision number used: \"${SYMREVNAME}\" 57rcsfreeze: the two differ only when rcsfreeze invoked with argument 58rcsfreeze: give log message, summarizing changes (end with EOF or single '.')" \ 59 || exit 60 61# Stamp the logfile. Because we order the logfile the most recent 62# first we will have to save everything right now in a temporary file. 63TMPLOG=/tmp/rcsfrz$$ 64trap 'rm -f $TMPLOG; exit 1' 1 2 13 15 65# Now ask for a log message, continuously add to the log file 66( 67 echo "Version: $SYMREVNAME($SYMREV), Date: $DATE 68-----------" || exit 69 while read MESS 70 do 71 case $MESS in 72 .) break 73 esac 74 echo " $MESS" || exit 75 done 76 echo "----------- 77" && 78 cat $LOGFILE 79) >$TMPLOG && 80 81# combine old and new logfiles 82cp $TMPLOG $LOGFILE && 83rm -f $TMPLOG && 84 85# Now the real work begins by assigning a symbolic revision number 86# to each rcs file. Take the most recent version on the default branch. 87 88# If there are any .*,v files, throw them in too. 89# But ignore RCS/.* files that do not end in ,v. 90DOTFILES= 91for DOTFILE in ${RCSDIR}.*,v 92do 93 if test -f "$DOTFILE" 94 then 95 DOTFILES="${RCSDIR}.*,v" 96 break 97 fi 98done 99 100exec rcs -q -n$SYMREVNAME: ${RCSDIR}*$EXT $DOTFILES 101