/[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 41 by dpavlin, Sat Sep 22 13:52:30 2007 UTC revision 42 by dpavlin, Sat Sep 22 13:57:28 2007 UTC
# Line 83  sub commit_svnrev { Line 83  sub commit_svnrev {
83    
84          if ($add_new) {          if ($add_new) {
85                  system "$cvs add '$path'" || die "cvs add of $path failed: $!";                  system "$cvs add '$path'" || die "cvs add of $path failed: $!";
86          }          } else {
         else {  
87                  my $msg = "subversion revision $rev commited to CVS";                  my $msg = "subversion revision $rev commited to CVS";
88                  print "$msg\n";                  print "$msg\n";
89                  system "$cvs commit -m '$msg' '$path'"                  system "$cvs commit -m '$msg' '$path'"
# Line 146  _NEW_REP_ Line 145  _NEW_REP_
145          log_system( "$cvs -q checkout $CVSREP", "cvs checkout failed" );          log_system( "$cvs -q checkout $CVSREP", "cvs checkout failed" );
146          cd_rep;          cd_rep;
147    
148  }  } else {
 else {  
149    
150          # import into existing module directory in CVS          # import into existing module directory in CVS
151    
# Line 179  _USAGE_ Line 177  _USAGE_
177                  if ( $in !~ /^\d+$/ ) {                  if ( $in !~ /^\d+$/ ) {
178                          print "Aborting: revision not a number\n";                          print "Aborting: revision not a number\n";
179                          exit 1;                          exit 1;
180                  }                  } else {
                 else {  
181                          $rev = $in;                          $rev = $in;
182                          commit_svnrev( $rev, 1 );    # create new                          commit_svnrev( $rev, 1 );    # create new
183                  }                  }
184          }          } else {
         else {  
185                  open( SVNREV, ".svnrev" )                  open( SVNREV, ".svnrev" )
186                          || die "can't open $TMPDIR/$CVSREP/.svnrev: $!";                          || die "can't open $TMPDIR/$CVSREP/.svnrev: $!";
187                  $rev = <SVNREV>;                  $rev = <SVNREV>;
# Line 243  sub entries($) { Line 239  sub entries($) {
239                          warn "#### entries recurse into: $dir/$sub_dir";                          warn "#### entries recurse into: $dir/$sub_dir";
240                          push @entries, map {"$sub_dir/$_"} entries("$dir/$sub_dir");                          push @entries, map {"$sub_dir/$_"} entries("$dir/$sub_dir");
241                          push @entries, $sub_dir;                          push @entries, $sub_dir;
242                  }                  } elsif (m{^/([^/]+)/}) {
                 elsif (m{^/([^/]+)/}) {  
243                          push @entries, $1;                          push @entries, $1;
244                  }                  } elsif ( !m{^D$} ) {
                 elsif ( !m{^D$} ) {  
245                          die "can't decode entries line: $_";                          die "can't decode entries line: $_";
246                  }                  }
247          }          }
# Line 272  sub in_entries($) { Line 266  sub in_entries($) {
266                  }                  }
267                  close($fh);                  close($fh);
268                  return 0;                  return 0;
269          }          } else {
         else {  
270                  die "can't split '$path' to dir and file!";                  die "can't split '$path' to dir and file!";
271          }          }
272  }  }
# Line 297  foreach my $e ( @{ $xml->{'logentry'} } Line 290  foreach my $e ( @{ $xml->{'logentry'} }
290          do {          do {
291                  if ( $tmpsvn =~ s#(/[^/]+)/*$## ) {    # vim fix                  if ( $tmpsvn =~ s#(/[^/]+)/*$## ) {    # vim fix
292                          $SVNREP = $1 . $SVNREP;                          $SVNREP = $1 . $SVNREP;
293                  }                  } elsif ( $e->{'paths'}->{'path'}->[0]->{'copyfrom-path'} ) {
                 elsif ( $e->{'paths'}->{'path'}->[0]->{'copyfrom-path'} ) {  
294                          print                          print
295                                  "NOTICE: copyfrom outside synced repository ignored - skipping\n";                                  "NOTICE: copyfrom outside synced repository ignored - skipping\n";
296                          next;                          next;
297                  }                  } else {
                 else {  
298                          print "NOTICE: can't deduce svn dir from $SVNROOT - skipping\n";                          print "NOTICE: can't deduce svn dir from $SVNROOT - skipping\n";
299                          next;                          next;
300                  }                  }
# Line 362  foreach my $e ( @{ $xml->{'logentry'} } Line 353  foreach my $e ( @{ $xml->{'logentry'} }
353    
354                          if ( -d $path ) {                          if ( -d $path ) {
355                                  add_dir( $path, $msg );                                  add_dir( $path, $msg );
356                          }                          } elsif ( $path =~ m,^(.+)/[^/]+$, && !-e "$1/CVS/Root" ) {
                         elsif ( $path =~ m,^(.+)/[^/]+$, && !-e "$1/CVS/Root" ) {  
357                                  my $dir = $1;                                  my $dir = $1;
358                                  in_entries($dir) || add_dir( $dir, $msg );                                  in_entries($dir) || add_dir( $dir, $msg );
359                                  in_entries($path) || log_system( "$cvs add '$path'",                                  in_entries($path) || log_system( "$cvs add '$path'",
360                                          "cvs add of $path failed" );                                          "cvs add of $path failed" );
361                          }                          } else {
                         else {  
362                                  in_entries($path) || log_system( "$cvs add '$path'",                                  in_entries($path) || log_system( "$cvs add '$path'",
363                                          "cvs add of $path failed" );                                          "cvs add of $path failed" );
364                          }                          }
# Line 378  foreach my $e ( @{ $xml->{'logentry'} } Line 367  foreach my $e ( @{ $xml->{'logentry'} }
367                  if ( $action =~ /M/ ) {                  if ( $action =~ /M/ ) {
368                          if ( in_entries($path) ) {                          if ( in_entries($path) ) {
369                                  print "svn2cvs: modify $path -- nop\n";                                  print "svn2cvs: modify $path -- nop\n";
370                          }                          } else {
                         else {  
371                                  print "WARNING: modify $path which isn't in CVS, adding...\n";                                  print "WARNING: modify $path which isn't in CVS, adding...\n";
372                                  add_path($path);                                  add_path($path);
373                          }                          }
374                  }                  } elsif ( $action =~ /A/ ) {
                 elsif ( $action =~ /A/ ) {  
375                          add_path($path);                          add_path($path);
376                  }                  } elsif ( $action =~ /D/ ) {
                 elsif ( $action =~ /D/ ) {  
377                          if ( -e $path ) {                          if ( -e $path ) {
378                                  if ( -d $path ) {                                  if ( -d $path ) {
379                                          warn "#### remove directory: $path";                                          warn "#### remove directory: $path";
# Line 412  foreach my $e ( @{ $xml->{'logentry'} } Line 398  foreach my $e ( @{ $xml->{'logentry'} }
398                                                  "cvs update -dP $path failed"                                                  "cvs update -dP $path failed"
399                                          );                                          );
400                                          undef $path;                                          undef $path;
401                                  }                                  } else {
                                 else {  
402                                          warn "#### remove file: $path";                                          warn "#### remove file: $path";
403                                          unlink($path) || die "can't delete $path: $!";                                          unlink($path) || die "can't delete $path: $!";
404                                          log_system( "$cvs delete '$path'",                                          log_system( "$cvs delete '$path'",
405                                                  "cvs delete of dir $path failed" );                                                  "cvs delete of dir $path failed" );
406                                  }                                  }
407                          }                          } else {
                         else {  
408                                  print "WARNING: $path is not present, skipping...\n";                                  print "WARNING: $path is not present, skipping...\n";
409                                  undef $path;                                  undef $path;
410                          }                          }
411                  }                  } else {
                 else {  
412                          print                          print
413                                  "WARNING: action $action not implemented on $path. Bug or missing feature of $0\n";                                  "WARNING: action $action not implemented on $path. Bug or missing feature of $0\n";
414                  }                  }

Legend:
Removed from v.41  
changed lines
  Added in v.42

  ViewVC Help
Powered by ViewVC 1.1.26