/[svn2cvs]/trunk/svn2cvs.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/svn2cvs.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 35 by dpavlin, Fri Sep 7 16:39:42 2007 UTC revision 38 by dpavlin, Fri Sep 7 17:18:53 2007 UTC
# Line 20  use XML::Simple; Line 20  use XML::Simple;
20  # do we want to sync just part of repository?  # do we want to sync just part of repository?
21  my $partial_import = 1;  my $partial_import = 1;
22    
23    # do we want to add svk-like prefix with original revision, author and date?
24    my $decorate_commit_message = 1;
25    
26  if (@ARGV < 2) {  if (@ARGV < 2) {
27          print "usage: $0 SVN_URL CVSROOT CVSREPOSITORY\n";          print "usage: $0 SVN_URL CVSROOT CVSREPOSITORY\n";
28          exit 1;          exit 1;
# Line 222  if (! $xml->{'logentry'}) { Line 225  if (! $xml->{'logentry'}) {
225          exit 0;          exit 0;
226  }  }
227    
 # 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);  
         }  
 }  
   
228  # return all files in CVS/Entries  # return all files in CVS/Entries
229  sub entries($) {  sub entries($) {
230          my $dir = shift;          my $dir = shift;
231          die "entries expects directory argument!" unless -d $dir;          die "entries expects directory argument!" unless -d $dir;
232          my @entries;          my @entries;
233          open(my $fh, "$dir/CVS/Entries") || return 0;          open(my $fh, "./$dir/CVS/Entries") || return 0;
234          while(<$fh>) {          while(<$fh>) {
235                  if ( m{^D/([^/]+)}, ) {                  if ( m{^D/([^/]+)}, ) {
236                          my $sub_dir = $1;                          my $sub_dir = $1;
# Line 262  sub entries($) { Line 251  sub entries($) {
251  # check if file exists in CVS/Entries  # check if file exists in CVS/Entries
252  sub in_entries($) {  sub in_entries($) {
253          my $path = shift;          my $path = shift;
254          my ($dir,$file) = dir_file($path);          if ($path =~ m,^(.*?/*)([^/]+)$,) {
255          open(E, "$dir/CVS/Entries") || return 0;                  my ($dir,$file) = ($1,$2);
256          while(<E>) {                  if ($dir !~ m,/$, && $dir ne "") {
257                  return(1) if (m,^/$file/,);                          $dir .= "/";
258                    }
259    
260                    open(my $fh, "./$dir/CVS/Entries") || return 0; #die "no entries file: $dir/CVS/Entries";
261                    while(<$fh>) {
262                            return 1 if (m{^/$file/});
263                    }
264                    close($fh);
265                    return 0;
266            } else {
267                    die "can't split '$path' to dir and file!";
268          }          }
         close(E);  
         return 0;  
269  }  }
270    
271  cd_tmp;  cd_tmp;
# Line 303  foreach my $e (@{$xml->{'logentry'}}) { Line 300  foreach my $e (@{$xml->{'logentry'}}) {
300          my $msg = $e->{'msg'};          my $msg = $e->{'msg'};
301          $msg =~ s/'/'\\''/g;    # quote "          $msg =~ s/'/'\\''/g;    # quote "
302    
303            $msg = 'r' . $rev . ' ' . $e->{author} . ' | ' . $e->{date} . "\n" . $msg if $decorate_commit_message;
304    
305          sub cvs_commit {          sub cvs_commit {
306                  my $msg = shift || die "no msg?";                  my $msg = shift || die "no msg?";
307                  if ( ! @_ ) {                  if ( ! @_ ) {

Legend:
Removed from v.35  
changed lines
  Added in v.38

  ViewVC Help
Powered by ViewVC 1.1.26