--- trunk/svn2cvs.pl 2004/03/09 22:16:19 6 +++ trunk/svn2cvs.pl 2004/03/09 22:35:55 7 @@ -18,11 +18,13 @@ my $HOME = $ENV{'HOME'} || die "can't get home directory!"; # cvsroot directory -#my $CVSROOT="$HOME/x/cvsroot"; my $CVSROOT=':pserver:dpavlin@cvs.tigris.org:/cvs'; # name of cvs repository to commit to my $CVSREP="svn2cvs/src"; +$CVSROOT="$HOME/x/cvsroot"; +$CVSREP="svn2cvs/src"; + # svnroot directory my $SVNROOT="file://$HOME/private/svn/svn2cvs"; # name of respository @@ -41,7 +43,6 @@ # cvs command with root my $cvs="cvs -d $CVSROOT"; - # # sub to do logging and system calls # @@ -60,30 +61,32 @@ die "commit_svnrev needs revision" if (! defined($rev)); - open(SVNREV,"> $CVSREP/.svnrev") || die "can't open $TMPDIR/$CVSREP/.svnrev: $!"; + open(SVNREV,"> .svnrev") || die "can't open $TMPDIR/$CVSREP/.svnrev: $!"; print SVNREV $rev; close(SVNREV); my $path=".svnrev"; if ($add_new) { - system "$cvs add $CVSREP/$path" || die "cvs add of $path failed: $!"; + system "$cvs add $path" || die "cvs add of $path failed: $!"; } else { my $msg="subversion revision $rev commited to CVS"; print "$msg\n"; - system "$cvs commit -m \"$msg\" $CVSREP/$path" || die "cvs commit of $path failed: $!"; + system "$cvs commit -m \"$msg\" $path" || die "cvs commit of $path failed: $!"; } } - # ok, now do the checkout log_system("$cvs -q checkout $CVSREP","cvs checkout failed"); +chdir($CVSREP) || die "can't cd to $TMPDIR/$CVSREP: $!"; + + my $rev; # check if svnrev exists -if (! -e "$CVSREP/.svnrev") { +if (! -e ".svnrev") { print <<_USAGE_; Your CVS repository doesn't have .svnrev file! @@ -113,7 +116,7 @@ commit_svnrev($rev,1); # create new } } else { - open(SVNREV,"$CVSREP/.svnrev") || die "can't open $TMPDIR/$CVSREP/.svnrev: $!"; + open(SVNREV,".svnrev") || die "can't open $TMPDIR/$CVSREP/.svnrev: $!"; $rev = ; chomp($rev); close(SVNREV); @@ -159,7 +162,7 @@ foreach my $e (@{$xml->{'logentry'}}) { die "BUG: revision from .svnrev ($rev) greater than from subversion (".$e->{'revision'}.")" if ($rev > $e->{'revision'}); $rev = $e->{'revision'}; - log_system("svn export --force -q -r $rev $SVNROOT/$SVNREP $CVSREP", "svn export of revision $rev failed"); + log_system("svn export --force -q -r $rev $SVNROOT/$SVNREP $TMPDIR/$CVSREP", "svn export of revision $rev failed"); printf($fmt, $e->{'revision'}, $e->{'author'}, $e->{'date'}, $e->{'msg'}); foreach my $p (@{$e->{'paths'}->{'path'}}) { @@ -170,21 +173,27 @@ # prepare path and message my $file = $path; $path =~ s,^/$SVNREP/*,, || die "BUG: can't strip SVNREP from path"; + + if (! $path) { + print "NOTICE: skipped this operation. Probably trunk creation\n"; + next; + } + my $msg = $e->{'msg'}; $msg =~ s/"/\\"/g; # quote " if ($action =~ /M/) { print "svn2cvs: modify $path -- nop\n"; } elsif ($action =~ /A/) { - log_system("$cvs add -m \"$msg\" $CVSREP/$path", "cvs add of $path failed"); + log_system("$cvs add -m \"$msg\" $path", "cvs add of $path failed"); } elsif ($action =~ /D/) { - log_system("$cvs delete -m \"$msg\" $CVSREP/$path", "cvs delete of $path failed"); + log_system("$cvs delete -m \"$msg\" $path", "cvs delete of $path failed"); } else { print "WARNING: action $action not implemented on $path. Bug or missing feature of $0\n"; } # now commit changes - log_system("$cvs commit -m \"$msg\" $CVSREP/$path", "cvs commit of $path failed"); + log_system("$cvs commit -m \"$msg\" $path", "cvs commit of $path failed"); }