3 # Sccs2rcs is a script to convert an existing SCCS
4 # history into an RCS history without losing any of
5 # the information contained therein.
6 # It has been tested under the following OS's:
7 # SunOS 3.5, 4.0.3, 4.1
11 # + It will NOT delete or alter your ./SCCS history under any circumstances.
13 # + Run in a directory where ./SCCS exists and where you can
16 # + /usr/local/bin is put in front of the default path.
17 # (SCCS under Ultrix is set-uid sccs, bad bad bad, so
18 # /usr/local/bin/sccs here fixes that)
20 # + Date, time, author, comments, branches, are all preserved.
22 # + If a command fails somewhere in the middle, it bombs with
23 # a message -- remove what it's done so far and try again.
24 # "rm -rf RCS; sccs unedit `sccs tell`; sccs clean"
25 # There is no recovery and exit is far from graceful.
26 # If a particular module is hanging you up, consider
27 # doing it separately; move it from the current area so that
28 # the next run will have a better chance or working.
29 # Also (for the brave only) you might consider hacking
30 # the s-file for simpler problems: I've successfully changed
31 # the date of a delta to be in sync, then run "sccs admin -z"
34 # + After everything finishes, ./SCCS will be moved to ./old-SCCS.
36 # This file may be copied, processed, hacked, mutilated, and
37 # even destroyed as long as you don't tell anyone you wrote it.
40 # Viewlogic Systems, Inc.
41 # kenstir@viewlogic.com
42 # ...!harvard!cg-atla!viewlog!kenstir
44 # Various hacks made by Brian Berliner before inclusion in CVS contrib area.
47 #we'll assume the user set up the path correctly
48 # for the Pmax, /usr/ucb/sccs is suid sccs, what a pain
49 # /usr/local/bin/sccs should override /usr/ucb/sccs there
50 set path = (/usr/local/bin $path)
53 ############################################################
57 echo "Error: ./ not writeable by you."
61 echo "Error: ./SCCS directory not found."
64 set edits = (`sccs tell`)
66 echo "Error: $#edits file(s) out for edit...clean up before converting."
70 echo "Warning: RCS directory exists"
71 if (`ls -a RCS | wc -l` > 2) then
72 echo "Error: RCS directory not empty
81 set logfile = /tmp/sccs2rcs_$$_log
83 set tmpfile = /tmp/sccs2rcs_$$_tmp
85 set emptyfile = /tmp/sccs2rcs_$$_empty
86 echo -n "" > $emptyfile
87 set initialfile = /tmp/sccs2rcs_$$_init
88 echo "Initial revision" > $initialfile
89 set sedfile = /tmp/sccs2rcs_$$_sed
91 set revfile = /tmp/sccs2rcs_$$_rev
94 # the quotes surround the dollar signs to fool RCS when I check in this script
95 set sccs_keywords = (\
99 '%Z%%M%[ ]*%I%[ ]*%G%'\
100 '%Z%%M%[ ]*%I%[ ]*%E%'\
108 set rcs_keywords = (\
123 ############################################################
124 # Get some answers from user
127 echo "Do you want to be prompted for a description of each"
128 echo "file as it is checked in to RCS initially?"
129 echo -n "(y=prompt for description, n=null description) [y] ?"
131 if ((_$ans == _) || (_$ans == _y) || (_$ans == _Y)) then
137 echo "The default keyword substitutions are as follows and are"
138 echo "applied in the order specified:"
140 while ($i <= $#sccs_keywords)
141 # echo ' '\"$sccs_keywords[$i]\"' ==> '\"$rcs_keywords[$i]\"
142 echo " $sccs_keywords[$i] ==> $rcs_keywords[$i]"
146 echo -n "Do you want to change them [n] ?"
148 if ((_$ans != _) && (_$ans != _n) && (_$ans != _N)) then
149 echo "You can't always get what you want."
150 echo "Edit this script file and change the variables:"
151 echo ' $sccs_keywords'
152 echo ' $rcs_keywords'
157 # create the sed script
159 while ($i <= $#sccs_keywords)
160 echo "s,$sccs_keywords[$i],$rcs_keywords[$i],g" >> $sedfile
166 ############################################################
167 # Loop over every s-file in SCCS dir
169 foreach sfile (SCCS/s.*)
170 # get rid of the "s." at the beginning of the name
171 set file = `echo $sfile:t | sed -e "s/^..//"`
173 # work on each rev of that file in ascending order
175 sccs prs $file | grep "^D " | awk '{print $2}' | sed -e 's/\./ /g' | sort -n -u +0 +1 +2 +3 +4 +5 +6 +7 +8 | sed -e 's/ /./g' > $revfile
176 foreach rev (`cat $revfile`)
177 if ($status != 0) goto ERROR
179 # get file into current dir and get stats
180 set year = `echo $date | cut -c3-4`
182 # Y2K Bug, change century to 20
183 set date = `echo $date | sed -e s/19/20/`
185 set date = `sccs prs -r$rev $file | grep "^D " | awk '{printf("19%s %s", $3, $4); exit}'`
186 set author = `sccs prs -r$rev $file | grep "^D " | awk '{print $5; exit}'`
188 echo "==> file $file, rev=$rev, date=$date, author=$author"
189 sccs edit -r$rev $file >>& $logfile
190 if ($status != 0) goto ERROR
191 echo checked out of SCCS
193 # add RCS keywords in place of SCCS keywords
194 sed -f $sedfile $file > $tmpfile
195 if ($status != 0) goto ERROR
196 echo performed keyword substitutions
199 # check file into RCS
204 echo ci -f -r$rev -d"$date" -w$author -t$emptyfile $file
205 ci -f -r$rev -d"$date" -w$author -t$emptyfile $file < $initialfile >>& $logfile
206 if ($status != 0) goto ERROR
207 echo initial rev checked into RCS without description
210 echo Enter a brief description of the file $file \(end w/ Ctrl-D\):
212 ci -f -r$rev -d"$date" -w$author -t$tmpfile $file < $initialfile >>& $logfile
213 if ($status != 0) goto ERROR
214 echo initial rev checked into RCS
218 set lckrev = `echo $rev | sed -e 's/\.[0-9]*$//'`
219 if ("$lckrev" =~ [0-9]*.*) then
220 # need to lock the brach -- it is OK if the lock fails
221 rcs -l$lckrev $file >>& $logfile
223 # need to lock the trunk -- must succeed
224 rcs -l $file >>& $logfile
225 if ($status != 0) goto ERROR
228 sccs prs -r$rev $file | grep "." > $tmpfile
229 # it's OK if grep fails here and gives status == 1
230 # put the delta message in $tmpfile
231 ed $tmpfile >>& $logfile <<EOF
237 ci -f -r$rev -d"$date" -w$author $file < $tmpfile >>& $logfile
238 if ($status != 0) goto ERROR
239 echo checked into RCS
241 sccs unedit $file >>& $logfile
242 if ($status != 0) goto ERROR
248 ############################################################
253 rm -f $tmpfile $emptyfile $initialfile $sedfile
254 echo ===================================================
255 echo " Conversion Completed Successfully"
257 echo " SCCS history now in old-SCCS/"
258 echo ===================================================
263 foreach f (`sccs tell`)
268 echo Danger\! Danger\!
269 echo Some command exited with a non-zero exit status.
270 echo Log file exists in $logfile.
272 echo Incomplete history in ./RCS -- remove it
273 echo Original unchanged history in ./SCCS
278 rm -f $tmpfile $emptyfile $initialfile $sedfile $revfile