Sync usage with man page.
[netbsd-mini2440.git] / external / gpl2 / xcvs / dist / contrib / rcs2sccs.sh
blob535ebd0be572830a5d948276f3b4259beb35e409
1 #! /bin/sh
3 # Copyright (C) 1995-2005 The Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
16 ############################################################
17 # Error checking
19 if [ ! -d SCCS ] ; then
20 mkdir SCCS
23 logfile=/tmp/rcs2sccs_$$_log
24 rm -f $logfile
25 tmpfile=/tmp/rcs2sccs_$$_tmp
26 rm -f $tmpfile
27 emptyfile=/tmp/rcs2sccs_$$_empty
28 echo -n "" > $emptyfile
29 initialfile=/tmp/rcs2sccs_$$_init
30 echo "Initial revision" > $initialfile
31 sedfile=/tmp/rcs2sccs_$$_sed
32 rm -f $sedfile
33 revfile=/tmp/rcs2sccs_$$_rev
34 rm -f $revfile
35 commentfile=/tmp/rcs2sccs_$$_comment
36 rm -f $commentfile
38 # create the sed script
39 cat > $sedfile << EOF
40 s,;Id;,%Z%%M% %I% %E%,g
41 s,;SunId;,%Z%%M% %I% %E%,g
42 s,;RCSfile;,%M%,g
43 s,;Revision;,%I%,g
44 s,;Date;,%E%,g
45 s,;Id:.*;,%Z%%M% %I% %E%,g
46 s,;SunId:.*;,%Z%%M% %I% %E%,g
47 s,;RCSfile:.*;,%M%,g
48 s,;Revision:.*;,%I%,g
49 s,;Date:.*;,%E%,g
50 EOF
51 sed -e 's/;/\\$/g' $sedfile > $tmpfile
52 cp $tmpfile $sedfile
53 ############################################################
54 # Loop over every RCS file in RCS dir
56 if sort -k 1,1 /dev/null 2>/dev/null
57 then sort_each_field='-k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9'
58 else sort_each_field='+0 +1 +2 +3 +4 +5 +6 +7 +8'
60 for vfile in *,v; do
61 # get rid of the ",v" at the end of the name
62 file=`echo $vfile | sed -e 's/,v$//'`
64 # work on each rev of that file in ascending order
65 firsttime=1
66 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
67 for rev in `cat $revfile`; do
68 if [ $? != 0 ]; then
69 echo ERROR - revision
70 exit
72 # get file into current dir and get stats
73 date=`rlog -r$rev $file | grep "^date: " | awk '{print $2; exit}' | sed -e 's/^19\|^20//'`
74 time=`rlog -r$rev $file | grep "^date: " | awk '{print $3; exit}' | sed -e 's/;//'`
75 author=`rlog -r$rev $file | grep "^date: " | awk '{print $5; exit}' | sed -e 's/;//'`
76 date="$date $time"
77 echo ""
78 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
79 echo "==> file $file, rev=$rev, date=$date, author=$author"
80 rm -f $file
81 co -r$rev $file >> $logfile 2>&1
82 if [ $? != 0 ]; then
83 echo ERROR - co
84 exit
86 echo checked out of RCS
88 # add SCCS keywords in place of RCS keywords
89 sed -f $sedfile $file > $tmpfile
90 if [ $? != 0 ]; then
91 echo ERROR - sed
92 exit
94 echo performed keyword substitutions
95 rm -f $file
96 cp $tmpfile $file
98 # check file into SCCS
99 if [ "$firsttime" = "1" ]; then
100 firsttime=0
101 echo about to do sccs admin
102 echo sccs admin -n -i$file $file < $commentfile
103 sccs admin -n -i$file $file < $commentfile >> $logfile 2>&1
104 if [ $? != 0 ]; then
105 echo ERROR - sccs admin
106 exit
108 echo initial rev checked into SCCS
109 else
110 case $rev in
111 *.*.*.*)
112 brev=`echo $rev | sed -e 's/\.[0-9]*$//'`
113 sccs admin -fb $file 2>>$logfile
114 echo sccs get -e -p -r$brev $file
115 sccs get -e -p -r$brev $file >/dev/null 2>>$logfile
118 echo sccs get -e -p $file
119 sccs get -e -p $file >/dev/null 2>> $logfile
121 esac
122 if [ $? != 0 ]; then
123 echo ERROR - sccs get
124 exit
126 sccs delta $file < $commentfile >> $logfile 2>&1
127 if [ $? != 0 ]; then
128 echo ERROR - sccs delta -r$rev $file
129 exit
131 echo checked into SCCS
133 sed -e "s;^\x01d D $rev ../../.. ..:..:.. [^ ][^ ]*;\x01d D $rev $date $author;" SCCS/s.$file > $tmpfile
134 rm -f SCCS/s.$file
135 cp $tmpfile SCCS/s.$file
136 chmod 444 SCCS/s.$file
137 sccs admin -z $file
138 if [ $? != 0 ]; then
139 echo ERROR - sccs admin -z
140 exit
142 done
143 rm -f $file
144 done
147 ############################################################
148 # Clean up
150 echo cleaning up...
151 rm -f $tmpfile $emptyfile $initialfile $sedfile $commentfile
152 echo ===================================================
153 echo " Conversion Completed Successfully"
154 echo ===================================================
156 rm -f *,v