Work around MinGW mangling of "host:/path"
[msysgit/historical-msysgit.git] / lib / cvs / contrib / rcs-to-cvs
blob66a62a9da5e1d4fdd568a7ceec571453675fd492
1 #! /bin/sh
3 # Based on the CVS 1.0 checkin csh script.
4 # Contributed by Per Cederqvist <ceder@signum.se>.
5 # Rewritten in sh by David MacKenzie <djm@cygnus.com>.
7 # Copyright (c) 1989, Brian Berliner
9 # You may distribute under the terms of the GNU General Public License.
11 #############################################################################
13 # Check in sources that previously were under RCS or no source control system.
15 # The repository is the directory where the sources should be deposited.
17 # Traverses the current directory, ensuring that an
18 # identical directory structure exists in the repository directory. It
19 # then checks the files in in the following manner:
21 # 1) If the file doesn't yet exist, check it in as revision 1.1
23 # The script also is somewhat verbose in letting the user know what is
24 # going on. It prints a diagnostic when it creates a new file, or updates
25 # a file that has been modified on the trunk.
27 # Bugs: doesn't put the files in branch 1.1.1
28 # doesn't put in release and vendor tags
30 #############################################################################
32 usage="Usage: rcs-to-cvs [-v] [-m message] [-f message_file] repository"
33 vbose=0
34 message=""
35 if [ -d /var/tmp ]; then message_file=/var/tmp/checkin.$$; else message_file=/usr/tmp/checkin.$$; fi
36 got_one=0
38 if [ $# -lt 1 ]; then
39 echo "$usage" >&2
40 exit 1
43 while [ $# -ne 0 ]; do
44 case "$1" in
45 -v)
46 vbose=1
48 -m)
49 shift
50 echo $1 > $message_file
51 got_one=1
53 -f)
54 shift
55 message_file=$1
56 got_one=2
59 break
60 esac
61 shift
62 done
64 if [ $# -lt 1 ]; then
65 echo "$usage" >&2
66 exit 1
69 repository=$1
70 shift
72 if [ -z "$CVSROOT" ]; then
73 echo "Please the environmental variable CVSROOT to the root" >&2
74 echo " of the tree you wish to update" >&2
75 exit 1
78 if [ $got_one -eq 0 ]; then
79 echo "Please Edit this file to contain the RCS log information" >$message_file
80 echo "to be associated with this directory (please remove these lines)">>$message_file
81 ${EDITOR-vi} $message_file
82 got_one=1
85 # Ya gotta share.
86 umask 0
88 update_dir=${CVSROOT}/${repository}
89 [ ! -d ${update_dir} ] && mkdir $update_dir
91 if [ -d SCCS ]; then
92 echo SCCS files detected! >&2
93 exit 1
95 if [ -d RCS ]; then
96 co RCS/*
99 for name in * .[a-zA-Z0-9]*
101 case "$name" in
102 RCS | *~ | \* | .\[a-zA-Z0-9\]\* ) continue ;;
103 esac
104 echo $name
105 if [ $vbose -ne 0 ]; then
106 echo "Updating ${repository}/${name}"
108 if [ -d "$name" ]; then
109 if [ ! -d "${update_dir}/${name}" ]; then
110 echo "WARNING: Creating new directory ${repository}/${name}"
111 mkdir "${update_dir}/${name}"
112 if [ $? -ne 0 ]; then
113 echo "ERROR: mkdir failed - aborting" >&2
114 exit 1
117 cd "$name"
118 if [ $? -ne 0 ]; then
119 echo "ERROR: Couldn\'t cd to $name - aborting" >&2
120 exit 1
122 if [ $vbose -ne 0 ]; then
123 $0 -v -f $message_file "${repository}/${name}"
124 else
125 $0 -f $message_file "${repository}/${name}"
127 if [ $? -ne 0 ]; then
128 exit 1
130 cd ..
131 else # if not directory
132 if [ ! -f "$name" ]; then
133 echo "WARNING: $name is neither a regular file"
134 echo " nor a directory - ignored"
135 continue
137 file="${update_dir}/${name},v"
138 comment=""
139 if grep -s '\$Log.*\$' "${name}"; then # If $Log keyword
140 myext=`echo $name | sed 's,.*\.,,'`
141 [ "$myext" = "$name" ] && myext=
142 case "$myext" in
143 c | csh | e | f | h | l | mac | me | mm | ms | p | r | red | s | sh | sl | cl | ml | el | tex | y | ye | yr | "" )
147 echo "For file ${file}:"
148 grep '\$Log.*\$' "${name}"
149 echo -n "Please insert a comment leader for file ${name} > "
150 read comment
152 esac
154 if [ ! -f "$file" ]; then # If not exists in repository
155 if [ ! -f "${update_dir}/Attic/${name},v" ]; then
156 echo "WARNING: Creating new file ${repository}/${name}"
157 if [ -f RCS/"${name}",v ]; then
158 echo "MSG: Copying old rcs file."
159 cp RCS/"${name}",v "$file"
160 else
161 if [ -n "${comment}" ]; then
162 rcs -q -i -c"${comment}" -t${message_file} -m'.' "$file"
164 ci -q -u1.1 -t${message_file} -m'.' "$file"
165 if [ $? -ne 0 ]; then
166 echo "ERROR: Initial check-in of $file failed - aborting" >&2
167 exit 1
170 else
171 file="${update_dir}/Attic/${name},v"
172 echo "WARNING: IGNORED: ${repository}/Attic/${name}"
173 continue
175 else # File existed
176 echo "ERROR: File exists in repository: Ignored: $file"
177 continue
180 done
182 [ $got_one -eq 1 ] && rm -f $message_file
184 exit 0