/[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 47 by dpavlin, Fri Nov 2 12:11:31 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 105  sub add_dir($$) { Line 104  sub add_dir($$) {
104                  next if in_entries($curr_dir);                  next if in_entries($curr_dir);
105                  next if ( -e "$curr_dir/CVS" );                  next if ( -e "$curr_dir/CVS" );
106    
107                  log_system( "$cvs add '$curr_dir'", "cvs add of $curr_dir failed" );                  log_system( "touch '$curr_dir/.keepme'", "creation of .keepme file (to keep $curr_dir alive in CVS) failed" );
108                    log_system( "$cvs add '$curr_dir' '$curr_dir/.keepme'", "cvs add of $curr_dir failed" );
109          }          }
110  }  }
111    
# Line 146  _NEW_REP_ Line 146  _NEW_REP_
146          log_system( "$cvs -q checkout $CVSREP", "cvs checkout failed" );          log_system( "$cvs -q checkout $CVSREP", "cvs checkout failed" );
147          cd_rep;          cd_rep;
148    
149  }  } else {
 else {  
150    
151          # import into existing module directory in CVS          # import into existing module directory in CVS
152    
# Line 179  _USAGE_ Line 178  _USAGE_
178                  if ( $in !~ /^\d+$/ ) {                  if ( $in !~ /^\d+$/ ) {
179                          print "Aborting: revision not a number\n";                          print "Aborting: revision not a number\n";
180                          exit 1;                          exit 1;
181                  }                  } else {
                 else {  
182                          $rev = $in;                          $rev = $in;
183                          commit_svnrev( $rev, 1 );    # create new                          commit_svnrev( $rev, 1 );    # create new
184                  }                  }
185          }          } else {
         else {  
186                  open( SVNREV, ".svnrev" )                  open( SVNREV, ".svnrev" )
187                          || die "can't open $TMPDIR/$CVSREP/.svnrev: $!";                          || die "can't open $TMPDIR/$CVSREP/.svnrev: $!";
188                  $rev = <SVNREV>;                  $rev = <SVNREV>;
# Line 243  sub entries($) { Line 240  sub entries($) {
240                          warn "#### entries recurse into: $dir/$sub_dir";                          warn "#### entries recurse into: $dir/$sub_dir";
241                          push @entries, map {"$sub_dir/$_"} entries("$dir/$sub_dir");                          push @entries, map {"$sub_dir/$_"} entries("$dir/$sub_dir");
242                          push @entries, $sub_dir;                          push @entries, $sub_dir;
243                  }                  } elsif (m{^/([^/]+)/}) {
                 elsif (m{^/([^/]+)/}) {  
244                          push @entries, $1;                          push @entries, $1;
245                  }                  } elsif ( !m{^D$} ) {
                 elsif ( !m{^D$} ) {  
246                          die "can't decode entries line: $_";                          die "can't decode entries line: $_";
247                  }                  }
248          }          }
# Line 268  sub in_entries($) { Line 263  sub in_entries($) {
263                  open( my $fh, "./$dir/CVS/Entries" )                  open( my $fh, "./$dir/CVS/Entries" )
264                          || return 0;    #die "no entries file: $dir/CVS/Entries";                          || return 0;    #die "no entries file: $dir/CVS/Entries";
265                  while (<$fh>) {                  while (<$fh>) {
266                          return 1 if (m{^/$file/});                          return 1 if (m{^D?/$file/});
267                  }                  }
268                  close($fh);                  close($fh);
269                  return 0;                  return 0;
270          }          } else {
         else {  
271                  die "can't split '$path' to dir and file!";                  die "can't split '$path' to dir and file!";
272          }          }
273  }  }
# Line 297  foreach my $e ( @{ $xml->{'logentry'} } Line 291  foreach my $e ( @{ $xml->{'logentry'} }
291          do {          do {
292                  if ( $tmpsvn =~ s#(/[^/]+)/*$## ) {    # vim fix                  if ( $tmpsvn =~ s#(/[^/]+)/*$## ) {    # vim fix
293                          $SVNREP = $1 . $SVNREP;                          $SVNREP = $1 . $SVNREP;
294                  }                  } elsif ( $e->{'paths'}->{'path'}->[0]->{'copyfrom-path'} ) {
                 elsif ( $e->{'paths'}->{'path'}->[0]->{'copyfrom-path'} ) {  
295                          print                          print
296                                  "NOTICE: copyfrom outside synced repository ignored - skipping\n";                                  "NOTICE: copyfrom outside synced repository ignored - skipping\n";
297                          next;                          next;
298                  }                  } else {
                 else {  
299                          print "NOTICE: can't deduce svn dir from $SVNROOT - skipping\n";                          print "NOTICE: can't deduce svn dir from $SVNROOT - skipping\n";
300                          next;                          next;
301                  }                  }
# Line 362  foreach my $e ( @{ $xml->{'logentry'} } Line 354  foreach my $e ( @{ $xml->{'logentry'} }
354    
355                          if ( -d $path ) {                          if ( -d $path ) {
356                                  add_dir( $path, $msg );                                  add_dir( $path, $msg );
357                          }                          } elsif ( $path =~ m,^(.+)/[^/]+$, && !-e "$1/CVS/Root" ) {
                         elsif ( $path =~ m,^(.+)/[^/]+$, && !-e "$1/CVS/Root" ) {  
358                                  my $dir = $1;                                  my $dir = $1;
359                                  in_entries($dir) || add_dir( $dir, $msg );                                  in_entries($dir) || add_dir( $dir, $msg );
360                                  in_entries($path) || log_system( "$cvs add '$path'",                                  in_entries($path) || log_system( "$cvs add '$path'",
361                                          "cvs add of $path failed" );                                          "cvs add of $path failed" );
362                          }                          } else {
                         else {  
363                                  in_entries($path) || log_system( "$cvs add '$path'",                                  in_entries($path) || log_system( "$cvs add '$path'",
364                                          "cvs add of $path failed" );                                          "cvs add of $path failed" );
365                          }                          }
# Line 378  foreach my $e ( @{ $xml->{'logentry'} } Line 368  foreach my $e ( @{ $xml->{'logentry'} }
368                  if ( $action =~ /M/ ) {                  if ( $action =~ /M/ ) {
369                          if ( in_entries($path) ) {                          if ( in_entries($path) ) {
370                                  print "svn2cvs: modify $path -- nop\n";                                  print "svn2cvs: modify $path -- nop\n";
371                          }                          } else {
                         else {  
372                                  print "WARNING: modify $path which isn't in CVS, adding...\n";                                  print "WARNING: modify $path which isn't in CVS, adding...\n";
373                                  add_path($path);                                  add_path($path);
374                          }                          }
375                  }                  } elsif ( $action =~ /A/ ) {
                 elsif ( $action =~ /A/ ) {  
376                          add_path($path);                          add_path($path);
377                  }                  } elsif ( $action =~ /D/ ) {
                 elsif ( $action =~ /D/ ) {  
378                          if ( -e $path ) {                          if ( -e $path ) {
379                                  if ( -d $path ) {                                  if ( ! in_entries( $path ) ) {
380                                            print "WARNING: $path is not present in CVS, skipping...\n";
381                                            undef $path;
382                                    } elsif ( -d $path ) {
383                                          warn "#### remove directory: $path";                                          warn "#### remove directory: $path";
                                         my @sub_commit;  
384                                          foreach my $f ( entries($path) ) {                                          foreach my $f ( entries($path) ) {
385                                                  $f = "$path/$f";                                                  $f = "$path/$f";
386                                                  if ( -f $f ) {                                                  if ( -f $f ) {
# Line 402  foreach my $e ( @{ $xml->{'logentry'} } Line 391  foreach my $e ( @{ $xml->{'logentry'} }
391                                                  }                                                  }
392                                                  log_system( "$cvs delete '$f'",                                                  log_system( "$cvs delete '$f'",
393                                                          "cvs delete of file $f failed" );                                                          "cvs delete of file $f failed" );
394                                                  push @sub_commit, $f;                                                  cvs_commit( $msg, $f );
395                                          }                                          }
396                                          log_system( "$cvs delete '$path'",                                          log_system( "$cvs delete '$path'",
397                                                  "cvs delete of file $path failed" );                                                  "cvs delete of file $path failed" );
398                                          cvs_commit( $msg, @sub_commit, $path );                                          cvs_commit( $msg, $path );
399                                          log_system(                                          log_system( "$cvs update -dP .",
400                                                  "$cvs update -dP '$path'",                                                  "cvs update -dP . failed" );
                                                 "cvs update -dP $path failed"  
                                         );  
401                                          undef $path;                                          undef $path;
402                                  }                                  } else {
                                 else {  
403                                          warn "#### remove file: $path";                                          warn "#### remove file: $path";
404                                          unlink($path) || die "can't delete $path: $!";                                          unlink($path) || die "can't delete $path: $!";
405                                          log_system( "$cvs delete '$path'",                                          log_system( "$cvs delete '$path'",
406                                                  "cvs delete of dir $path failed" );                                                  "cvs delete of dir $path failed" );
407                                            cvs_commit( $msg, $path );
408                                            undef $path;
409                                  }                                  }
410                          }                          } else {
                         else {  
411                                  print "WARNING: $path is not present, skipping...\n";                                  print "WARNING: $path is not present, skipping...\n";
412                                  undef $path;                                  undef $path;
413                          }                          }
414                  }                  } else {
                 else {  
415                          print                          print
416                                  "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";
417                  }                  }

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

  ViewVC Help
Powered by ViewVC 1.1.26