]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/cvs/contrib/rcs2sccs.sh
This commit was generated by cvs2svn to compensate for changes in r171577,
[FreeBSD/FreeBSD.git] / contrib / cvs / contrib / rcs2sccs.sh
1 #! /bin/sh
2 #
3 #
4
5 ############################################################
6 # Error checking
7 #
8 if [ ! -d SCCS ] ; then
9     mkdir SCCS
10 fi
11
12 logfile=/tmp/rcs2sccs_$$_log
13 rm -f $logfile
14 tmpfile=/tmp/rcs2sccs_$$_tmp
15 rm -f $tmpfile
16 emptyfile=/tmp/rcs2sccs_$$_empty
17 echo -n "" > $emptyfile
18 initialfile=/tmp/rcs2sccs_$$_init
19 echo "Initial revision" > $initialfile
20 sedfile=/tmp/rcs2sccs_$$_sed
21 rm -f $sedfile
22 revfile=/tmp/rcs2sccs_$$_rev
23 rm -f $revfile
24 commentfile=/tmp/rcs2sccs_$$_comment
25 rm -f $commentfile
26
27 # create the sed script
28 cat > $sedfile << EOF
29 s,;Id;,%Z%%M% %I% %E%,g
30 s,;SunId;,%Z%%M% %I% %E%,g
31 s,;RCSfile;,%M%,g
32 s,;Revision;,%I%,g
33 s,;Date;,%E%,g
34 s,;Id:.*;,%Z%%M% %I% %E%,g
35 s,;SunId:.*;,%Z%%M% %I% %E%,g
36 s,;RCSfile:.*;,%M%,g
37 s,;Revision:.*;,%I%,g
38 s,;Date:.*;,%E%,g
39 EOF
40 sed -e 's/;/\\$/g' $sedfile > $tmpfile
41 cp $tmpfile $sedfile
42 ############################################################
43 # Loop over every RCS file in RCS dir
44 #
45 if sort -k 1,1 /dev/null 2>/dev/null
46 then sort_each_field='-k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9'
47 else sort_each_field='+0 +1 +2 +3 +4 +5 +6 +7 +8'
48 fi
49 for vfile in *,v; do
50     # get rid of the ",v" at the end of the name
51     file=`echo $vfile | sed -e 's/,v$//'`
52
53     # work on each rev of that file in ascending order
54     firsttime=1
55     rlog $file | grep "^revision [0-9][0-9]*\." | awk '{print $2}' | sed -e 's/\./ /g' | sort -n -u $sort_each_field | sed -e 's/ /./g' > $revfile
56     for rev in `cat $revfile`; do
57         if [ $? != 0 ]; then
58                 echo ERROR - revision
59                 exit
60         fi
61         # get file into current dir and get stats
62         date=`rlog -r$rev $file | grep "^date: " | awk '{print $2; exit}' | sed -e 's/^19\|^20//'`
63         time=`rlog -r$rev $file | grep "^date: " | awk '{print $3; exit}' | sed -e 's/;//'`
64         author=`rlog -r$rev $file | grep "^date: " | awk '{print $5; exit}' | sed -e 's/;//'`
65         date="$date $time"
66         echo ""
67         rlog -r$rev $file | sed -e '/^branches: /d' -e '1,/^date: /d' -e '/^===========/d' -e 's/$/\\/' | awk '{if ((total += length($0) + 1) < 510) print $0}' > $commentfile
68         echo "==> file $file, rev=$rev, date=$date, author=$author"
69         rm -f $file
70         co -r$rev $file >> $logfile  2>&1
71         if [ $? != 0 ]; then
72                 echo ERROR - co
73                 exit
74         fi
75         echo checked out of RCS
76
77         # add SCCS keywords in place of RCS keywords
78         sed -f $sedfile $file > $tmpfile
79         if [ $? != 0 ]; then
80                 echo ERROR - sed
81                 exit
82         fi
83         echo performed keyword substitutions
84         rm -f $file
85         cp $tmpfile $file
86
87         # check file into SCCS
88         if [ "$firsttime" = "1" ]; then
89             firsttime=0
90             echo about to do sccs admin
91             echo sccs admin -n -i$file $file < $commentfile
92             sccs admin -n -i$file $file < $commentfile >> $logfile 2>&1
93             if [ $? != 0 ]; then
94                     echo ERROR - sccs admin
95                     exit
96             fi
97             echo initial rev checked into SCCS
98         else
99             case $rev in
100             *.*.*.*)
101                 brev=`echo $rev | sed -e 's/\.[0-9]*$//'`
102                 sccs admin -fb $file 2>>$logfile
103                 echo sccs get -e -p -r$brev $file
104                 sccs get -e -p -r$brev $file >/dev/null 2>>$logfile
105                 ;;
106             *)
107                 echo sccs get -e -p $file
108                 sccs get -e -p $file >/dev/null 2>> $logfile
109                 ;;
110             esac
111             if [ $? != 0 ]; then
112                     echo ERROR - sccs get
113                     exit
114             fi
115             sccs delta $file < $commentfile >> $logfile 2>&1
116             if [ $? != 0 ]; then
117                     echo ERROR - sccs delta -r$rev $file
118                     exit
119             fi
120             echo checked into SCCS
121         fi
122         sed -e "s;^\ 1d D $rev ../../.. ..:..:.. [^ ][^ ]*;\ 1d D $rev $date $author;" SCCS/s.$file > $tmpfile
123         rm -f SCCS/s.$file
124         cp $tmpfile SCCS/s.$file
125         chmod 444 SCCS/s.$file
126         sccs admin -z $file
127         if [ $? != 0 ]; then
128                 echo ERROR - sccs admin -z
129                 exit
130         fi
131     done
132     rm -f $file
133 done
134
135
136 ############################################################
137 # Clean up
138 #
139 echo cleaning up...
140 rm -f $tmpfile $emptyfile $initialfile $sedfile $commentfile
141 echo ===================================================
142 echo "       Conversion Completed Successfully"
143 echo ===================================================
144
145 rm -f *,v