v15i022: sccs2rcs
Kenstir
kenc at Viewlogic.COM
Sat Oct 6 10:19:41 AEST 1990
Posting-number: Volume 15, Issue 22
Submitted-by: kenc at Viewlogic.COM (Kenstir)
Archive-name: sccs2rcs_kc/part01
Here is a script file which I spent a lot of time perfecting. It
converts an existing SCCS history (s-file) into the identical RCS
history (RCS-file).
It has been tested under SunOS 3.5, 4.0.3, 4.1; Ultrix 2.0, 3.1
Be sure to look at the README file before using!
--
Kenneth H. Cox
Viewlogic Systems, Inc.
kenstir at viewlogic.com
...!harvard!cg-atla!viewlog!kenstir
-----------------------------------------------------------------------
#! /bin/sh
# This is a shell archive. Remove anything before this line, then
unpack
# it by saving it into a file and typing "sh file". To overwrite
existing
# files, type "sh file -c". You can also feed this as standard input
via
# unshar, or by typing "sh <file", e.g.. If this archive is complete,
you
# will see the following message at the end:
# "End of shell archive."
# Contents: sccs2rcs README
# Wrapped by kenc at madmax on Thu Oct 4 20:58:43 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f sccs2rcs -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"sccs2rcs\"
else
echo shar: Extracting \"sccs2rcs\" \(7364 characters\)
sed "s/^X//" >sccs2rcs <<'END_OF_sccs2rcs'
X#!/bin/csh -f
X#
X# Sccs2rcs is a script to convert an existing SCCS
X# history into an RCS history without losing any of
X# the information contained therein.
X# It has been tested under the following OS's:
X# SunOS 3.5, 4.0.3, 4.1
X# Ultrix-32 2.0, 3.1
X#
X# Things to note:
X# + It will NOT delete or alter your ./SCCS history under any
circumstances.
X#
X# + Run in a directory where ./SCCS exists and where you can
X# create ./RCS
X#
X# + /usr/local/bin is put in front of the default path.
X# (SCCS under Ultrix is set-uid sccs, bad bad bad, so
X# /usr/local/bin/sccs here fixes that)
X#
X# + Date, time, author, comments, branches, are all preserved.
X#
X# + If a command fails somewhere in the middle, it bombs with
X# a message -- remove what it's done so far and try again.
X# "rm -rf RCS; sccs unedit `sccs tell`; sccs clean"
X# There is no recovery and exit is far from graceful.
X# If a particular module is hanging you up, consider
X# doing it separately; move it from the current area so that
X# the next run will have a better chance or working.
X# Also (for the brave only) you might consider hacking
X# the s-file for simpler problems: I've successfully changed
X# the date of a delta to be in sync, then run "sccs admin -z"
X# on the thing.
X#
X# + After everything finishes, ./SCCS will be moved to ./old-SCCS.
X#
X# This file may be copied, processed, hacked, mutilated, and
X# even destroyed as long as you don't tell anyone you wrote it.
X#
X# Ken Cox
X# Viewlogic Systems, Inc.
X# kenstir at viewlogic.com
X# ...!harvard!cg-atla!viewlog!kenstir
X#
X# $Id: sccs2rcs,v 1.12 90/10/04 20:52:23 kenc Exp $
X
X
X#we'll assume the user set up the path correctly
X# for the Pmax, /usr/ucb/sccs is suid sccs, what a pain
X# /usr/local/bin/sccs should override /usr/ucb/sccs there
Xset path = (/usr/local/bin $path)
X
X
X############################################################
X# Error checking
X#
Xif (! -w .) then
X echo "Error: ./ not writeable by you."
X exit 1
Xendif
Xif (! -d SCCS) then
X echo "Error: ./SCCS directory not found."
X exit 1
Xendif
Xset edits = (`sccs tell`)
Xif ($#edits) then
X echo "Error: $#edits file(s) out for edit...clean up before
converting."
X exit 1
Xendif
Xif (-d RCS) then
X echo "Warning: RCS directory exists"
X if (`ls -a RCS | wc -l` > 2) then
X echo "Error: RCS directory not empty
X exit 1
X endif
Xelse
X mkdir RCS
Xendif
X
Xsccs clean
X
Xset logfile = /tmp/sccs2rcs_$$_log
Xrm -f $logfile
Xset tmpfile = /tmp/sccs2rcs_$$_tmp
Xrm -f $tmpfile
Xset emptyfile = /tmp/sccs2rcs_$$_empty
Xecho -n "" > $emptyfile
Xset initialfile = /tmp/sccs2rcs_$$_init
Xecho "Initial revision" > $initialfile
Xset sedfile = /tmp/sccs2rcs_$$_sed
Xrm -f $sedfile
X
X# the quotes surround the dollar signs to fool RCS when I check in this
script
Xset sccs_keywords = (\
X '%W%[ ]*%G%'\
X '%W%[ ]*%E%'\
X '%W%'\
X '%M%[ ]*%I%[ ]*%G%'\
X '%M%[ ]*%I%[ ]*%E%'\
X '%M%'\
X '%I%'\
X '%G%'\
X '%E%'\
X '%U%')
Xset rcs_keywords = (\
X '$'Id'$'\
X '$'Id'$'\
X '$'Id'$'\
X '$'Id'$'\
X '$'Id'$'\
X '$'RCSfile'$'\
X '$'Revision'$'\
X '$'Date'$'\
X '$'Date'$'\
X '')
X
X
X############################################################
X# Get some answers from user
X#
Xecho ""
Xecho "Do you want to be prompted for a description of each"
Xecho "file as it is checked in to RCS initially?"
Xecho -n "(y=prompt for description, n=null description) [y] ?"
Xset ans = $<
Xif ((_$ans == _) || (_$ans == _y) || (_$ans == _Y)) then
X set nodesc = 0
Xelse
X set nodesc = 1
Xendif
Xecho ""
Xecho "The default keyword substitutions are as follows and are"
Xecho "applied in the order specified:"
Xset i = 1
Xwhile ($i <= $#sccs_keywords)
X# echo ' '\"$sccs_keywords[$i]\"' ==> '\"$rcs_keywords[$i]\"
X echo " $sccs_keywords[$i] ==> $rcs_keywords[$i]"
X @ i = $i + 1
Xend
Xecho ""
Xecho -n "Do you want to change them [n] ?"
Xset ans = $<
Xif ((_$ans != _) && (_$ans != _n) && (_$ans != _N)) then
X echo "You can't always get what you want."
X echo "Edit this script file and change the variables:"
X echo ' $sccs_keywords'
X echo ' $rcs_keywords'
Xelse
X echo "good idea."
Xendif
X
X# create the sed script
Xset i = 1
Xwhile ($i <= $#sccs_keywords)
X echo "s,$sccs_keywords[$i],$rcs_keywords[$i],g" >> $sedfile
X @ i = $i + 1
Xend
X
X
X############################################################
X# Loop over every s-file in SCCS dir
X#
Xforeach sfile (SCCS/s.*)
X # get rid of the "s." at the beginning of the name
X set file = `echo $sfile:t | sed -e "s/^..//"`
X
X # work on each rev of that file in ascending order
X set firsttime = 1
X foreach rev (`sccs prs $file | grep "^D " | awk '{print $2}' | tail
-r`)
X if ($status != 0) goto ERROR
X
X # get file into current dir and get stats
X set date = `sccs prs -r$rev $file | grep "^D " | awk '{print
$3, $4}'`
X set author = `sccs prs -r$rev $file | grep "^D " | awk '{print
$5}'`
X echo ""
X echo "==> file $file, rev=$rev, date=$date, author=$author"
X sccs edit -r$rev $file >>& $logfile
X if ($status != 0) goto ERROR
X echo checked out of SCCS
X
X # add RCS keywords in place of SCCS keywords
X sed -f $sedfile $file > $tmpfile
X if ($status != 0) goto ERROR
X echo performed keyword substitutions
X cp $tmpfile $file
X
X # check file into RCS
X if ($firsttime) then
X set firsttime = 0
X if ($nodesc) then
X ci -f -r$rev -d"$date" -w$author -t$emptyfile $file <
$initialfile >>& $logfile
X if ($status != 0) goto ERROR
X echo initial rev checked into RCS without description
X else
X echo ""
X echo Enter a brief description of the file $file \(end
w/ Ctrl-D\):
X cat > $tmpfile
X ci -f -r$rev -d"$date" -w$author -t$tmpfile $file <
$initialfile >>& $logfile
X if ($status != 0) goto ERROR
X echo initial rev checked into RCS
X endif
X else
X # get RCS lock
X rcs -l $file >>& $logfile
X if ($status != 0) goto ERROR
X echo got lock
X sccs prs -r$rev $file | grep "." > $tmpfile
X # it's OK if grep fails here and gives status == 1
X # put the delta message in $tmpfile
X ed $tmpfile >>& $logfile <<EOF
X/COMMENTS
X1,.d
Xw
Xq
XEOF
X ci -f -r$rev -d"$date" -w$author $file < $tmpfile >>&
$logfile
X if ($status != 0) goto ERROR
X echo checked into RCS
X endif
X sccs unedit $file >>& $logfile
X if ($status != 0) goto ERROR
X end
X rm -f $file
Xend
X
X
X############################################################
X# Clean up
X#
Xecho cleaning up...
Xmv SCCS old-SCCS
Xrm -f $tmpfile $emptyfile $initialfile $sedfile
Xecho ===================================================
Xecho " Conversion Completed Successfully"
Xecho ""
Xecho " SCCS history now in old-SCCS/"
Xecho ===================================================
Xexit 0
X
XERROR:
Xforeach f (`sccs tell`)
X sccs unedit $f
Xend
Xecho ""
Xecho ""
Xecho Danger\! Danger\!
Xecho Some command exited with a non-zero exit status.
Xecho Log file exists in $logfile.
Xecho ""
Xecho Incomplete history in ./RCS -- remove it
Xecho Original unchanged history in ./SCCS
Xexit 1
END_OF_sccs2rcs
echo shar: 3 control characters may be missing from \"sccs2rcs\"
if test 7364 -ne `wc -c <sccs2rcs`; then
echo shar: \"sccs2rcs\" unpacked with wrong size!
fi
chmod +x sccs2rcs
# end of overwriting check
fi
if test -f README -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"README\"
else
echo shar: Extracting \"README\" \(1516 characters\)
sed "s/^X//" >README <<'END_OF_README'
XSccs2rcs is a script to convert an existing SCCS
Xhistory into an RCS history without losing any of
Xthe information contained therein.
XIt has been tested under the following OS's:
X SunOS 3.5, 4.0.3, 4.1
X Ultrix-32 2.0, 3.1
X
XThings to note:
X + It will NOT delete or alter your ./SCCS history under any
circumstances.
X
X + Run in a directory where ./SCCS exists and where you can
X create ./RCS
X
X + /usr/local/bin is put in front of the default path.
X (SCCS under Ultrix is set-uid sccs, bad bad bad, so
X /usr/local/bin/sccs here fixes that)
X
X + Date, time, author, comments, branches, are all preserved.
X
X + If a command fails somewhere in the middle, it bombs with
X a message -- remove what it's done so far and try again.
X "rm -rf RCS; sccs unedit `sccs tell`; sccs clean"
X There is no recovery and exit is far from graceful.
X If a particular module is hanging you up, consider
X doing it separately; move it from the current area so that
X the next run will have a better chance or working.
X Also (for the brave only) you might consider hacking
X the s-file for simpler problems: I've successfully changed
X the date of a delta to be in sync, then run "sccs admin -z"
X on the thing.
X
X + After everything finishes, ./SCCS will be moved to ./old-SCCS.
X
XThis file may be copied, processed, hacked, mutilated, and
Xeven destroyed as long as you don't tell anyone you wrote it.
X
XKen Cox
XViewlogic Systems, Inc.
Xkenstir at viewlogic.com
X...!harvard!cg-atla!viewlog!kenstir
END_OF_README
if test 1516 -ne `wc -c <README`; then
echo shar: \"README\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of shell archive.
exit 0
More information about the Comp.sources.misc
mailing list