13 |
|
|
14 |
use strict; |
use strict; |
15 |
use File::Temp qw/ tempdir /; |
use File::Temp qw/ tempdir /; |
16 |
|
use File::Path; |
17 |
use Data::Dumper; |
use Data::Dumper; |
18 |
use XML::Simple; |
use XML::Simple; |
19 |
|
|
29 |
exit 1; |
exit 1; |
30 |
} |
} |
31 |
|
|
32 |
|
# Ensure File::Temp::END can clean up: |
33 |
|
$SIG{__DIE__} = sub { chdir("/tmp"); die @_ }; |
34 |
|
|
35 |
my $TMPDIR=tempdir( "/tmp/checkoutXXXXX", CLEANUP => 1 ); |
my $TMPDIR=tempdir( "/tmp/checkoutXXXXX", CLEANUP => 1 ); |
36 |
|
|
37 |
chdir($TMPDIR) || die "can't cd to $TMPDIR: $!"; |
chdir($TMPDIR) || die "can't cd to $TMPDIR: $!"; |
109 |
chdir($TMPDIR) || die "can't cd to $TMPDIR: $!"; |
chdir($TMPDIR) || die "can't cd to $TMPDIR: $!"; |
110 |
rmdir $CVSREP || die "can't remove $CVSREP: $!"; |
rmdir $CVSREP || die "can't remove $CVSREP: $!"; |
111 |
|
|
112 |
# and checkout it |
# and get new changes it |
113 |
log_system("$cvs -q checkout $CVSREP", "cvs checkout failed"); |
log_system("$cvs -q update -d $CVSREP", "cvs update -d failed"); |
114 |
|
|
115 |
chdir($CVSREP) || die "can't cd to $TMPDIR/$CVSREP: $!"; |
chdir($CVSREP) || die "can't cd to $TMPDIR/$CVSREP: $!"; |
116 |
|
|
177 |
} |
} |
178 |
close(LOG); |
close(LOG); |
179 |
|
|
180 |
my $xml = XMLin($log, ForceArray => [ 'logentry', 'path' ]); |
|
181 |
|
my $xml; |
182 |
|
eval { |
183 |
|
$xml = XMLin($log, ForceArray => [ 'logentry', 'path' ]); |
184 |
|
}; |
185 |
|
|
186 |
|
|
187 |
#=begin log_example |
#=begin log_example |
210 |
if ($d !~ m,/$, && $d ne "") { |
if ($d !~ m,/$, && $d ne "") { |
211 |
$d .= "/"; |
$d .= "/"; |
212 |
} |
} |
213 |
open(E, $d."CVS/Entries") || die "can't open ${d}CVS/Entries: $!"; |
open(E, $d."CVS/Entries") || return 0; |
214 |
while(<E>) { |
while(<E>) { |
215 |
return(1) if (m,^/$f/,); |
return(1) if (m,^/$f/,); |
216 |
} |
} |
219 |
} |
} |
220 |
} |
} |
221 |
|
|
222 |
|
chdir("$TMPDIR/$CVSREP") || die "can't cd to $TMPDIR/$CVSREP: $!"; |
223 |
|
|
224 |
foreach my $e (@{$xml->{'logentry'}}) { |
foreach my $e (@{$xml->{'logentry'}}) { |
225 |
die "BUG: revision from .svnrev ($rev) greater than from subversion (".$e->{'revision'}.")" if ($rev > $e->{'revision'}); |
die "BUG: revision from .svnrev ($rev) greater than from subversion (".$e->{'revision'}.")" if ($rev > $e->{'revision'}); |
226 |
$rev = $e->{'revision'}; |
$rev = $e->{'revision'}; |
231 |
my $tmpsvn = $SVNROOT || die "BUG: SVNROOT empty!"; |
my $tmpsvn = $SVNROOT || die "BUG: SVNROOT empty!"; |
232 |
my $tmppath = $e->{'paths'}->{'path'}->[0]->{'content'} || die "BUG: tmppath empty!"; |
my $tmppath = $e->{'paths'}->{'path'}->[0]->{'content'} || die "BUG: tmppath empty!"; |
233 |
do { |
do { |
234 |
if ($tmpsvn =~ s,(/\w+)/*$,,) { |
if ($tmpsvn =~ s#(/[^/]+)/*$##) { |
235 |
$SVNREP .= $1; |
$SVNREP = $1 . $SVNREP; |
236 |
} else { |
} else { |
237 |
print "NOTICE: can't deduce svn dir from $SVNROOT - skipping\n"; |
print "NOTICE: can't deduce svn dir from $SVNROOT - skipping\n"; |
238 |
next; |
next; |
267 |
if (-d $path) { |
if (-d $path) { |
268 |
chdir($path) || die "can't cd into dir $path for import: $!"; |
chdir($path) || die "can't cd into dir $path for import: $!"; |
269 |
log_system("$cvs import -d -m '$msg' $CVSREP/$path svn r$rev", "cvs import of $path failed"); |
log_system("$cvs import -d -m '$msg' $CVSREP/$path svn r$rev", "cvs import of $path failed"); |
270 |
|
chdir("$TMPDIR") || die "can't cd to $TMPDIR/$CVSREP: $!"; |
271 |
if (-d "$CVSREP/$path") { |
if (-d "$CVSREP/$path") { |
272 |
rmdir "$CVSREP/$path" || die "can't remove $CVSREP/$path: $!"; |
rmtree "$CVSREP/$path" || die "can't remove $CVSREP/$path: $!"; |
273 |
} else { |
} else { |
274 |
unlink "$CVSREP/$path" || die "can't remove $CVSREP/$path: $!"; |
unlink "$CVSREP/$path" || die "can't remove $CVSREP/$path: $!"; |
275 |
} |
} |
276 |
chdir("$TMPDIR") || die "can't cd to $TMPDIR/$CVSREP: $!"; |
log_system("$cvs update -d $CVSREP", "cvs update -d of imported dir $path failed"); |
|
log_system("$cvs checkout $CVSREP/$path", "cvs checkout of imported dir $path failed"); |
|
277 |
chdir("$TMPDIR/$CVSREP") || die "can't cd back to $TMPDIR/$CVSREP: $!"; |
chdir("$TMPDIR/$CVSREP") || die "can't cd back to $TMPDIR/$CVSREP: $!"; |
278 |
} elsif ($path =~ m,^(.+)/[^/]+$, && ! -e "$1/CVS/Root") { |
} elsif ($path =~ m,^(.+)/[^/]+$, && ! -e "$1/CVS/Root") { |
279 |
my $dir = $1; |
my $dir = $1; |
303 |
commit_svnrev($rev); |
commit_svnrev($rev); |
304 |
} |
} |
305 |
|
|
306 |
|
# cd out of $CVSREP before File::Temp::END is called |
307 |
|
chdir("/tmp") || die "can't cd to /tmp: $!"; |
308 |
|
|
309 |
__END__ |
__END__ |
310 |
|
|
311 |
=pod |
=pod |
417 |
Group commit operations to save round-trips to CVS server. |
Group commit operations to save round-trips to CVS server. |
418 |
Documentation improvements and other small fixes. |
Documentation improvements and other small fixes. |
419 |
|
|
420 |
|
=item r20 |
421 |
|
|
422 |
|
Fixed path deduction (overlap between Subversion reporistory and CVS checkout). |
423 |
|
|
424 |
|
=item r21 |
425 |
|
|
426 |
|
Use C<update -d> instead of checkout after import. |
427 |
|
Added fixes by Paul Egan <paulegan@mail.com> for XMLin and fixing working |
428 |
|
directory. |
429 |
|
|
430 |
|
|
431 |
=back |
=back |
432 |
|
|