MFC corrected printing of the slice number when adding a GPT partition.
[dragonfly.git] / contrib / cvs-1.12 / contrib / rcs-to-cvs.sh
blob4db2578466857fed981f8ec31faacab25d055fee
1 #! /bin/sh
3 # Copyright (c) 1989-2005 The Free Software Foundation, Inc.
4 # Portions Copyright (c) 1989, Brian Berliner
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
9 # any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # Based on the CVS 1.0 checkin csh script.
17 # Contributed by Per Cederqvist <ceder@signum.se>.
18 # Rewritten in sh by David MacKenzie <djm@cygnus.com>.
20 #############################################################################
22 # Check in sources that previously were under RCS or no source control system.
24 # The repository is the directory where the sources should be deposited.
26 # Traverses the current directory, ensuring that an
27 # identical directory structure exists in the repository directory. It
28 # then checks the files in in the following manner:
30 # 1) If the file doesn't yet exist, check it in as revision 1.1
32 # The script also is somewhat verbose in letting the user know what is
33 # going on. It prints a diagnostic when it creates a new file, or updates
34 # a file that has been modified on the trunk.
36 # Bugs: doesn't put the files in branch 1.1.1
37 # doesn't put in release and vendor tags
39 #############################################################################
41 usage="Usage: rcs-to-cvs [-v] [-m message] [-f message_file] repository"
42 vbose=0
43 message=""
44 if [ -d /var/tmp ]; then message_file=/var/tmp/checkin.$$; else message_file=/usr/tmp/checkin.$$; fi
45 got_one=0
47 if [ $# -lt 1 ]; then
48 echo "$usage" >&2
49 exit 1
52 while [ $# -ne 0 ]; do
53 case "$1" in
54 -v)
55 vbose=1
57 -m)
58 shift
59 echo $1 > $message_file
60 got_one=1
62 -f)
63 shift
64 message_file=$1
65 got_one=2
68 break
69 esac
70 shift
71 done
73 if [ $# -lt 1 ]; then
74 echo "$usage" >&2
75 exit 1
78 repository=$1
79 shift
81 if [ -z "$CVSROOT" ]; then
82 echo "Please the environmental variable CVSROOT to the root" >&2
83 echo " of the tree you wish to update" >&2
84 exit 1
87 if [ $got_one -eq 0 ]; then
88 echo "Please Edit this file to contain the RCS log information" >$message_file
89 echo "to be associated with this directory (please remove these lines)">>$message_file
90 ${EDITOR-vi} $message_file
91 got_one=1
94 # Ya gotta share.
95 umask 0
97 update_dir=${CVSROOT}/${repository}
98 [ ! -d ${update_dir} ] && mkdir $update_dir
100 if [ -d SCCS ]; then
101 echo SCCS files detected! >&2
102 exit 1
104 if [ -d RCS ]; then
105 co RCS/*
108 for name in * .[a-zA-Z0-9]*
110 case "$name" in
111 RCS | *~ | \* | .\[a-zA-Z0-9\]\* ) continue ;;
112 esac
113 echo $name
114 if [ $vbose -ne 0 ]; then
115 echo "Updating ${repository}/${name}"
117 if [ -d "$name" ]; then
118 if [ ! -d "${update_dir}/${name}" ]; then
119 echo "WARNING: Creating new directory ${repository}/${name}"
120 mkdir "${update_dir}/${name}"
121 if [ $? -ne 0 ]; then
122 echo "ERROR: mkdir failed - aborting" >&2
123 exit 1
126 cd "$name"
127 if [ $? -ne 0 ]; then
128 echo "ERROR: Couldn\'t cd to $name - aborting" >&2
129 exit 1
131 if [ $vbose -ne 0 ]; then
132 $0 -v -f $message_file "${repository}/${name}"
133 else
134 $0 -f $message_file "${repository}/${name}"
136 if [ $? -ne 0 ]; then
137 exit 1
139 cd ..
140 else # if not directory
141 if [ ! -f "$name" ]; then
142 echo "WARNING: $name is neither a regular file"
143 echo " nor a directory - ignored"
144 continue
146 file="${update_dir}/${name},v"
147 comment=""
148 if grep -s '\$Log.*\$' "${name}"; then # If $Log keyword
149 myext=`echo $name | sed 's,.*\.,,'`
150 [ "$myext" = "$name" ] && myext=
151 case "$myext" in
152 c | csh | e | f | h | l | mac | me | mm | ms | p | r | red | s | sh | sl | cl | ml | el | tex | y | ye | yr | "" )
156 echo "For file ${file}:"
157 grep '\$Log.*\$' "${name}"
158 echo -n "Please insert a comment leader for file ${name} > "
159 read comment
161 esac
163 if [ ! -f "$file" ]; then # If not exists in repository
164 if [ ! -f "${update_dir}/Attic/${name},v" ]; then
165 echo "WARNING: Creating new file ${repository}/${name}"
166 if [ -f RCS/"${name}",v ]; then
167 echo "MSG: Copying old rcs file."
168 cp RCS/"${name}",v "$file"
169 else
170 if [ -n "${comment}" ]; then
171 rcs -q -i -c"${comment}" -t${message_file} -m'.' "$file"
173 ci -q -u1.1 -t${message_file} -m'.' "$file"
174 if [ $? -ne 0 ]; then
175 echo "ERROR: Initial check-in of $file failed - aborting" >&2
176 exit 1
179 else
180 file="${update_dir}/Attic/${name},v"
181 echo "WARNING: IGNORED: ${repository}/Attic/${name}"
182 continue
184 else # File existed
185 echo "ERROR: File exists in repository: Ignored: $file"
186 continue
189 done
191 [ $got_one -eq 1 ] && rm -f $message_file
193 exit 0