Merge from vendor branch SENDMAIL:
[dragonfly.git] / gnu / usr.bin / rcs / rcsfreeze / rcsfreeze.sh
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.2 2003/06/17 04:25:48 dillon 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
29 PATH=/bin:/usr/bin:$PATH
30 export PATH
31
32 DATE=`LC_ALL=C date` || exit
33 # Check whether we have an RCS subdirectory, so we can have the right
34 # prefix for our paths.
35 if test -d RCS
36 then RCSDIR=RCS/ EXT=
37 else RCSDIR= EXT=,v
38 fi
39
40 # Version number stuff, log message file
41 VERSIONFILE=${RCSDIR}.rcsfreeze.ver
42 LOGFILE=${RCSDIR}.rcsfreeze.log
43 # Initialize, rcsfreeze never run before in the current directory
44 test -r $VERSIONFILE || { echo 0 >$VERSIONFILE && >>$LOGFILE; } || exit
45
46 # Get Version number, increase it, write back to file.
47 VERSIONNUMBER=`cat $VERSIONFILE` &&
48 VERSIONNUMBER=`expr $VERSIONNUMBER + 1` &&
49 echo $VERSIONNUMBER >$VERSIONFILE || exit
50
51 # Symbolic Revision Number
52 SYMREV=C_$VERSIONNUMBER
53 # Allow the user to give a meaningful symbolic name to the revision.
54 SYMREVNAME=${1-$SYMREV}
55 echo >&2 "rcsfreeze: symbolic revision number computed: \"${SYMREV}\"
56 rcsfreeze: symbolic revision number used:     \"${SYMREVNAME}\"
57 rcsfreeze: the two differ only when rcsfreeze invoked with argument
58 rcsfreeze: 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.
63 TMPLOG=/tmp/rcsfrz$$
64 trap 'rm -f $TMPLOG; exit 1' 1 2 13 15
65 # Now ask for a log message, continously 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
82 cp $TMPLOG $LOGFILE &&
83 rm -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.
90 DOTFILES=
91 for DOTFILE in ${RCSDIR}.*,v
92 do
93         if test -f "$DOTFILE"
94         then
95                 DOTFILES="${RCSDIR}.*,v"
96                 break
97         fi
98 done
99
100 exec rcs -q -n$SYMREVNAME: ${RCSDIR}*$EXT $DOTFILES