rcsfreeze.sh revision 73349
1227825Stheraven#! /bin/sh 2227825Stheraven 3227825Stheraven# rcsfreeze - assign a symbolic revision number to a configuration of RCS files 4227825Stheraven 5227825Stheraven# $FreeBSD: head/gnu/usr.bin/rcs/rcsfreeze/rcsfreeze.sh 73349 2001-03-02 16:52:14Z ru $ 6227825Stheraven 7227825Stheraven# The idea is to run rcsfreeze each time a new version is checked 8227825Stheraven# in. A unique symbolic revision number (C_[number], where number 9227825Stheraven# is increased each time rcsfreeze is run) is then assigned to the most 10227825Stheraven# recent revision of each RCS file of the main trunk. 11227825Stheraven# 12227825Stheraven# If the command is invoked with an argument, then this 13227825Stheraven# argument is used as the symbolic name to freeze a configuration. 14227825Stheraven# The unique identifier is still generated 15227825Stheraven# and is listed in the log file but it will not appear as 16227825Stheraven# part of the symbolic revision name in the actual RCS file. 17227825Stheraven# 18227825Stheraven# A log message is requested from the user which is saved for future 19227825Stheraven# references. 20227825Stheraven# 21227825Stheraven# The shell script works only on all RCS files at one time. 22227825Stheraven# It is important that all changed files are checked in (there are 23227825Stheraven# no precautions against any error in this respect). 24227825Stheraven# file names: 25227825Stheraven# {RCS/}.rcsfreeze.ver version number 26227825Stheraven# {RCS/}.rscfreeze.log log messages, most recent first 27227825Stheraven 28227825StheravenPATH=/bin:/usr/bin:$PATH 29227825Stheravenexport PATH 30227825Stheraven 31227825StheravenDATE=`LC_ALL=C date` || exit 32227825Stheraven# Check whether we have an RCS subdirectory, so we can have the right 33227825Stheraven# prefix for our paths. 34227825Stheravenif test -d RCS 35227825Stheraventhen RCSDIR=RCS/ EXT= 36227825Stheravenelse RCSDIR= EXT=,v 37227825Stheravenfi 38227825Stheraven 39227825Stheraven# Version number stuff, log message file 40227825StheravenVERSIONFILE=${RCSDIR}.rcsfreeze.ver 41227825StheravenLOGFILE=${RCSDIR}.rcsfreeze.log 42227825Stheraven# Initialize, rcsfreeze never run before in the current directory 43227825Stheraventest -r $VERSIONFILE || { echo 0 >$VERSIONFILE && >>$LOGFILE; } || exit 44227825Stheraven 45227825Stheraven# Get Version number, increase it, write back to file. 46227825StheravenVERSIONNUMBER=`cat $VERSIONFILE` && 47227825StheravenVERSIONNUMBER=`expr $VERSIONNUMBER + 1` && 48227825Stheravenecho $VERSIONNUMBER >$VERSIONFILE || exit 49227825Stheraven 50227825Stheraven# Symbolic Revision Number 51227825StheravenSYMREV=C_$VERSIONNUMBER 52227825Stheraven# Allow the user to give a meaningful symbolic name to the revision. 53227825StheravenSYMREVNAME=${1-$SYMREV} 54227825Stheravenecho >&2 "rcsfreeze: symbolic revision number computed: \"${SYMREV}\" 55227825Stheravenrcsfreeze: symbolic revision number used: \"${SYMREVNAME}\" 56227825Stheravenrcsfreeze: the two differ only when rcsfreeze invoked with argument 57227825Stheravenrcsfreeze: give log message, summarizing changes (end with EOF or single '.')" \ 58227825Stheraven || exit 59227825Stheraven 60227825Stheraven# Stamp the logfile. Because we order the logfile the most recent 61227825Stheraven# first we will have to save everything right now in a temporary file. 62227825StheravenTMPLOG=/tmp/rcsfrz$$ 63227825Stheraventrap 'rm -f $TMPLOG; exit 1' 1 2 13 15 64227825Stheraven# Now ask for a log message, continously add to the log file 65227825Stheraven( 66227825Stheraven echo "Version: $SYMREVNAME($SYMREV), Date: $DATE 67227825Stheraven-----------" || exit 68227825Stheraven while read MESS 69227825Stheraven do 70227825Stheraven case $MESS in 71227825Stheraven .) break 72227825Stheraven esac 73227825Stheraven echo " $MESS" || exit 74227825Stheraven done 75227825Stheraven echo "----------- 76227825Stheraven" && 77227825Stheraven cat $LOGFILE 78227825Stheraven) >$TMPLOG && 79227825Stheraven 80227825Stheraven# combine old and new logfiles 81cp $TMPLOG $LOGFILE && 82rm -f $TMPLOG && 83 84# Now the real work begins by assigning a symbolic revision number 85# to each rcs file. Take the most recent version on the default branch. 86 87# If there are any .*,v files, throw them in too. 88# But ignore RCS/.* files that do not end in ,v. 89DOTFILES= 90for DOTFILE in ${RCSDIR}.*,v 91do 92 if test -f "$DOTFILE" 93 then 94 DOTFILES="${RCSDIR}.*,v" 95 break 96 fi 97done 98 99exec rcs -q -n$SYMREVNAME: ${RCSDIR}*$EXT $DOTFILES 100