/[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 26 by dpavlin, Sun Jul 30 18:45:51 2006 UTC revision 30 by dpavlin, Mon Aug 20 08:37:22 2007 UTC
# Line 17  use File::Path; Line 17  use File::Path;
17  use Data::Dumper;  use Data::Dumper;
18  use XML::Simple;  use XML::Simple;
19    
20    # do we want to sync just part of repository?
21    my $partial_import = 1;
22    
23  if (@ARGV < 2) {  if (@ARGV < 2) {
24          print "usage: $0 SVN_URL CVSROOT CVSREPOSITORY\n";          print "usage: $0 SVN_URL CVSROOT CVSREPOSITORY\n";
25          exit 1;          exit 1;
# Line 45  sub cd_rep { Line 48  sub cd_rep {
48  print "## using TMPDIR $TMPDIR\n";  print "## using TMPDIR $TMPDIR\n";
49    
50  # cvs command with root  # cvs command with root
51  my $cvs="cvs -d $CVSROOT";  my $cvs="cvs -f -d $CVSROOT";
52    
53  # current revision in CVS  # current revision in CVS
54  my $rev;  my $rev;
# Line 75  sub commit_svnrev { Line 78  sub commit_svnrev {
78          my $path=".svnrev";          my $path=".svnrev";
79    
80          if ($add_new) {          if ($add_new) {
81                  system "$cvs add $path" || die "cvs add of $path failed: $!";                  system "$cvs add '$path'" || die "cvs add of $path failed: $!";
82          } else {          } else {
83                  my $msg="subversion revision $rev commited to CVS";                  my $msg="subversion revision $rev commited to CVS";
84                  print "$msg\n";                  print "$msg\n";
85                  system "$cvs commit -m '$msg' $path" || die "cvs commit of $path failed: $!";                  system "$cvs commit -m '$msg' '$path'" || die "cvs commit of $path failed: $!";
86          }          }
87  }  }
88    
# Line 96  sub add_dir($$) { Line 99  sub add_dir($$) {
99                  next if in_entries($curr_dir);                  next if in_entries($curr_dir);
100                  next if (-e "$curr_dir/CVS");                  next if (-e "$curr_dir/CVS");
101    
102                  log_system("$cvs add $curr_dir", "cvs add of $curr_dir failed");                  log_system("$cvs add '$curr_dir'", "cvs add of $curr_dir failed");
103          }          }
104  }  }
105    
# Line 276  foreach my $e (@{$xml->{'logentry'}}) { Line 279  foreach my $e (@{$xml->{'logentry'}}) {
279    
280                  # prepare path and message                  # prepare path and message
281                  my $file = $path;                  my $file = $path;
282                  $path =~ s#^\Q$SVNREP\E/*## || die "BUG: can't strip SVNREP '$SVNREP' from path";                  if ( $path !~ s#^\Q$SVNREP\E/*## ) {
283                            print "NOTICE: skipping '$path' which isn't under repository root '$SVNREP'\n";
284                            die unless $partial_import;
285                            next;
286                    }
287    
288                  if (! $path) {                  if (! $path) {
289                          print "NOTICE: skipped this operation. Probably trunk creation\n";                          print "NOTICE: skipped this operation. Probably trunk creation\n";
# Line 287  foreach my $e (@{$xml->{'logentry'}}) { Line 294  foreach my $e (@{$xml->{'logentry'}}) {
294                  $msg =~ s/'/'\\''/g;    # quote "                  $msg =~ s/'/'\\''/g;    # quote "
295    
296                  if ($action =~ /M/) {                  if ($action =~ /M/) {
297                          print "svn2cvs: modify $path -- nop\n";                          if ( in_entries( $path ) ) {
298                                    print "svn2cvs: modify $path -- nop\n";
299                            } else {
300                                    print "WARNING: modify $path which isn't in CVS, adding...\n";
301                                    log_system("$cvs add '$path'", "cvs add of $path failed");
302                            }
303                  } elsif ($action =~ /A/) {                  } elsif ($action =~ /A/) {
304                          if (-d $path) {                          if (-d $path) {
305                                  add_dir($path, $msg);                                  add_dir($path, $msg);
306                          } elsif ($path =~ m,^(.+)/[^/]+$, && ! -e "$1/CVS/Root") {                          } elsif ($path =~ m,^(.+)/[^/]+$, && ! -e "$1/CVS/Root") {
307                                  my $dir = $1;                                  my $dir = $1;
308                                  in_entries($dir) || add_dir($dir, $msg);                                  in_entries($dir) || add_dir($dir, $msg);
309                                  in_entries($path) || log_system("$cvs add $path", "cvs add of $path failed");                                  in_entries($path) || log_system("$cvs add '$path'", "cvs add of $path failed");
310                          } else {                          } else {
311                                  in_entries($path) || log_system("$cvs add $path", "cvs add of $path failed");                                  in_entries($path) || log_system("$cvs add '$path'", "cvs add of $path failed");
312                          }                          }
313                  } elsif ($action =~ /D/) {                  } elsif ($action =~ /D/) {
314                          if (-e $path) {                          if (-e $path) {
315                                  unlink $path || die "can't delete $path: $!";                                  unlink $path || die "can't delete $path: $!";
316                                  log_system("$cvs delete $path", "cvs delete of $path failed");                                  log_system("$cvs delete '$path'", "cvs delete of $path failed");
317                          } else {                          } else {
318                                  print "WARNING: $path is not present, skipping...\n";                                  print "WARNING: $path is not present, skipping...\n";
319                                  undef $path;                                  undef $path;
# Line 319  foreach my $e (@{$xml->{'logentry'}}) { Line 331  foreach my $e (@{$xml->{'logentry'}}) {
331          $msg =~ s/'/'\\''/g;    # quote "          $msg =~ s/'/'\\''/g;    # quote "
332    
333          # now commit changes          # now commit changes
334          log_system("$cvs commit -m '$msg' ".join(" ",@commit), "cvs commit of ".join(",",@commit)." failed");          log_system("$cvs commit -m '$msg' '".join("' '",@commit)."'", "cvs commit of ".join(",",@commit)." failed");
335    
336          commit_svnrev($rev);          commit_svnrev($rev);
337  }  }

Legend:
Removed from v.26  
changed lines
  Added in v.30

  ViewVC Help
Powered by ViewVC 1.1.26