8 |
# http://raw.no/personal/blog |
# http://raw.no/personal/blog |
9 |
# |
# |
10 |
# 2004-03-09 Dobrica Pavlinusic <dpavlin@rot13.org> |
# 2004-03-09 Dobrica Pavlinusic <dpavlin@rot13.org> |
11 |
|
# |
12 |
|
# documentation is after __END__ |
13 |
|
|
14 |
use strict; |
use strict; |
15 |
use File::Temp qw/ tempdir /; |
use File::Temp qw/ tempdir /; |
83 |
|
|
84 |
Your CVS repository doesn't have .svnrev file! |
Your CVS repository doesn't have .svnrev file! |
85 |
|
|
86 |
This file is used to keep CVS repository and SubVersion in sync, so |
This file is used to keep CVS repository and Subversion in sync, so |
87 |
that only newer changes will be commited. |
that only newer changes will be commited. |
88 |
|
|
89 |
It's quote possible that this is first svn2cvs run for this repository. |
It's quote possible that this is first svn2cvs run for this repository. |
92 |
been checkouted. |
been checkouted. |
93 |
|
|
94 |
If you migrated your cvs repository to svn using cvs2svn, this will be |
If you migrated your cvs repository to svn using cvs2svn, this will be |
95 |
last SubVersion revision. If this is initial run of conversion of |
last Subversion revision. If this is initial run of conversion of |
96 |
SubVersion repository to CVS, correct revision is 0. |
Subversion repository to CVS, correct revision is 0. |
97 |
|
|
98 |
_USAGE_ |
_USAGE_ |
99 |
|
|
135 |
my $xml = XMLin($log, ForceArray => [ 'logentry', 'path' ]); |
my $xml = XMLin($log, ForceArray => [ 'logentry', 'path' ]); |
136 |
|
|
137 |
|
|
138 |
=begin log_example |
#=begin log_example |
139 |
|
# |
140 |
------------------------------------------------------------------------ |
#------------------------------------------------------------------------ |
141 |
r256 | dpavlin | 2004-03-09 13:18:17 +0100 (Tue, 09 Mar 2004) | 2 lines |
#r256 | dpavlin | 2004-03-09 13:18:17 +0100 (Tue, 09 Mar 2004) | 2 lines |
142 |
|
# |
143 |
ported r254 from hidra branch |
#ported r254 from hidra branch |
144 |
|
# |
145 |
=cut |
#=cut |
146 |
|
|
147 |
my $fmt = "\n" . "-" x 79 . "\nr%5s| %8s | %s\n\n%s\n"; |
my $fmt = "\n" . "-" x 79 . "\nr%5s| %8s | %s\n\n%s\n"; |
148 |
|
|
149 |
if (! $xml->{'logentry'}) { |
if (! $xml->{'logentry'}) { |
150 |
print "no newer log entries in SubVersion repostory. CVS is current\n"; |
print "no newer log entries in Subversion repostory. CVS is current\n"; |
151 |
exit 0; |
exit 0; |
152 |
} |
} |
153 |
|
|
214 |
|
|
215 |
commit_svnrev($rev); |
commit_svnrev($rev); |
216 |
} |
} |
217 |
|
|
218 |
|
__END__ |
219 |
|
|
220 |
|
=pod |
221 |
|
|
222 |
|
=head1 NAME |
223 |
|
|
224 |
|
svn2cvs - save subversion commits to (read-only) cvs repository |
225 |
|
|
226 |
|
=head1 SYNOPSIS |
227 |
|
|
228 |
|
./svn2cvs.pl SVN_URL CVSROOT CVSREPOSITORY |
229 |
|
|
230 |
|
Usage example (used to self-host this script): |
231 |
|
|
232 |
|
./svn2cvs.pl file:///home/dpavlin/private/svn/svn2cvs/trunk/ \ |
233 |
|
:pserver:dpavlin@cvs.tigris.org:/cvs svn2cvs/src |
234 |
|
|
235 |
|
=head1 DESCRIPTION |
236 |
|
|
237 |
|
This script will allow you to commit changes made to Subversion repository also to (read-only) CVS repository manually or from Subversion's C<post-commit> hook. |
238 |
|
|
239 |
|
It's using F<.svnrev> file (which will be created on first run) in |
240 |
|
B<CVSROOT/CVSREPOSITORY> to store last Subversion revision which was |
241 |
|
committed into CVS. |
242 |
|
|
243 |
|
One run will do following things: |
244 |
|
|
245 |
|
=over 4 |
246 |
|
|
247 |
|
=item * |
248 |
|
checkout B<CVSREPOSITORY> from B<CVSROOT> to temporary directory |
249 |
|
|
250 |
|
=item * |
251 |
|
check if F<.svnrev> file exists and create it if it doesn't |
252 |
|
|
253 |
|
=item * |
254 |
|
loop through all revisions from current in B<CVSROOT/CVSREPOSITORY> (using |
255 |
|
F<.svnrev>) up to B<HEAD> (current one) |
256 |
|
|
257 |
|
=over 5 |
258 |
|
|
259 |
|
=item * |
260 |
|
checkout next Subversion revision from B<SVN_URL> over CVS checkout |
261 |
|
temporary directory |
262 |
|
|
263 |
|
=item * |
264 |
|
make modification (add and/or delete) done in that revision |
265 |
|
|
266 |
|
=item * |
267 |
|
commit modification (added, deleted or modified files/dirs) while |
268 |
|
preserving original message from CVS |
269 |
|
|
270 |
|
=item * |
271 |
|
update F<.svnrev> to match current revision |
272 |
|
|
273 |
|
=back |
274 |
|
|
275 |
|
=item * |
276 |
|
cleanup temporary directory |
277 |
|
|
278 |
|
=back |
279 |
|
|
280 |
|
If checkout fails for some reason (e.g. flaky ssh connection), you will |
281 |
|
still have valid CVS repository, so all you have to do is run B<svn2cvs.pl> |
282 |
|
again. |
283 |
|
|
284 |
|
=head1 WARNINGS |
285 |
|
|
286 |
|
"Cheap" copy operations in Subversion are not at all cheap in CVS. They will |
287 |
|
create multiple copies of files in CVS repository! |
288 |
|
|
289 |
|
=head1 RELATED PROJECTS |
290 |
|
|
291 |
|
B<Subversion> L<http://subversion.tigris.org/> version control system that is a |
292 |
|
compelling replacement for CVS in the open source community. |
293 |
|
|
294 |
|
B<cvs2svn> L<http://cvs2svn.tigris.org/> converts a CVS repository to a |
295 |
|
Subversion repository. It is designed for one-time conversions, not for |
296 |
|
repeated synchronizations between CVS and Subversion. |
297 |
|
|
298 |
|
=head1 AUTHOR |
299 |
|
|
300 |
|
Dobrica Pavlinusic <dpavlin@rot13.org> |
301 |
|
|
302 |
|
L<http://www.rot13.org/~dpavlin/> |
303 |
|
|
304 |
|
=head1 LICENSE |
305 |
|
|
306 |
|
This product is licensed under GNU Public License (GPL) v2 or later. |
307 |
|
|
308 |
|
=cut |
309 |
|
|