--- trunk/svn2cvs.pl 2007/09/07 16:39:42 35 +++ trunk/svn2cvs.pl 2007/09/07 17:18:53 38 @@ -20,6 +20,9 @@ # do we want to sync just part of repository? my $partial_import = 1; +# do we want to add svk-like prefix with original revision, author and date? +my $decorate_commit_message = 1; + if (@ARGV < 2) { print "usage: $0 SVN_URL CVSROOT CVSREPOSITORY\n"; exit 1; @@ -222,26 +225,12 @@ exit 0; } -# my ($dir,$file) = dir_file($path); -sub dir_file($) { - 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 ne "") { - $d .= "/"; - } - return ($d,$f); - } -} - # return all files in CVS/Entries sub entries($) { my $dir = shift; die "entries expects directory argument!" unless -d $dir; my @entries; - open(my $fh, "$dir/CVS/Entries") || return 0; + open(my $fh, "./$dir/CVS/Entries") || return 0; while(<$fh>) { if ( m{^D/([^/]+)}, ) { my $sub_dir = $1; @@ -262,13 +251,21 @@ # check if file exists in CVS/Entries sub in_entries($) { my $path = shift; - my ($dir,$file) = dir_file($path); - open(E, "$dir/CVS/Entries") || return 0; - while() { - return(1) if (m,^/$file/,); + if ($path =~ m,^(.*?/*)([^/]+)$,) { + my ($dir,$file) = ($1,$2); + if ($dir !~ m,/$, && $dir ne "") { + $dir .= "/"; + } + + open(my $fh, "./$dir/CVS/Entries") || return 0; #die "no entries file: $dir/CVS/Entries"; + while(<$fh>) { + return 1 if (m{^/$file/}); + } + close($fh); + return 0; + } else { + die "can't split '$path' to dir and file!"; } - close(E); - return 0; } cd_tmp; @@ -303,6 +300,8 @@ my $msg = $e->{'msg'}; $msg =~ s/'/'\\''/g; # quote " + $msg = 'r' . $rev . ' ' . $e->{author} . ' | ' . $e->{date} . "\n" . $msg if $decorate_commit_message; + sub cvs_commit { my $msg = shift || die "no msg?"; if ( ! @_ ) {