--- trunk/svn2cvs.pl 2004/03/13 17:22:53 12 +++ trunk/svn2cvs.pl 2004/03/14 21:49:36 14 @@ -151,6 +151,25 @@ exit 0; } +# check if file exists in CVS/Entries +sub in_entries($) { + my $path = shift; + if ($path !~ m,^(.*?/*)([^/]+)$,) { + die "can't split '$path' to dir and file!"; + } else { + my ($d,$f) = ($1,$2); + if ($d !~ m,/$,) { + $d .= "/"; + } + open(E, $d."CVS/Entries") || die "can't open ${d}CVS/Entries: $!"; + while() { + return(1) if (m,^/$f/,); + } + close(E); + return 0; + } +} + foreach my $e (@{$xml->{'logentry'}}) { die "BUG: revision from .svnrev ($rev) greater than from subversion (".$e->{'revision'}.")" if ($rev > $e->{'revision'}); $rev = $e->{'revision'}; @@ -187,7 +206,7 @@ } my $msg = $e->{'msg'}; - $msg =~ s/'/\\'/g; # quote " + $msg =~ s/'/'\\''/g; # quote " if ($action =~ /M/) { print "svn2cvs: modify $path -- nop\n"; @@ -198,11 +217,16 @@ chdir("$TMPDIR") || die "can't cd to $TMPDIR/$CVSREP: $!"; log_system("$cvs checkout $CVSREP/$path", "cvs checkout of imported dir $path failed"); chdir("$TMPDIR/$CVSREP") || die "can't cd back to $TMPDIR/$CVSREP: $!"; + } elsif ($path =~ m,^(.+)/[^/]+$, && ! -e "$1/CVS/Root") { + my $dir = $1; + in_entries($dir) || log_system("$cvs add $dir", "cvs add of dir $dir failed"); + in_entries($path) || log_system("$cvs add $path", "cvs add of $path failed"); } else { - log_system("$cvs add -m '$msg' $path", "cvs add of $path failed"); + in_entries($path) || log_system("$cvs add $path", "cvs add of $path failed"); } } elsif ($action =~ /D/) { - log_system("$cvs delete -m '$msg' $path", "cvs delete of $path failed"); + unlink $path || die "can't delete $path: $!"; + log_system("$cvs delete $path", "cvs delete of $path failed"); } else { print "WARNING: action $action not implemented on $path. Bug or missing feature of $0\n"; }