/[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 20 by dpavlin, Mon Apr 18 16:43:08 2005 UTC revision 21 by dpavlin, Fri Jul 1 19:07:10 2005 UTC
# Line 13  Line 13 
13    
14  use strict;  use strict;
15  use File::Temp qw/ tempdir /;  use File::Temp qw/ tempdir /;
16    use File::Path;
17  use Data::Dumper;  use Data::Dumper;
18  use XML::Simple;  use XML::Simple;
19    
# Line 28  if ($SVNROOT !~ m,^[\w+]+:///*\w+,) { Line 29  if ($SVNROOT !~ m,^[\w+]+:///*\w+,) {
29          exit 1;          exit 1;
30  }  }
31    
32    # Ensure File::Temp::END can clean up:
33    $SIG{__DIE__} = sub { chdir("/tmp"); die @_ };
34    
35  my $TMPDIR=tempdir( "/tmp/checkoutXXXXX", CLEANUP => 1 );  my $TMPDIR=tempdir( "/tmp/checkoutXXXXX", CLEANUP => 1 );
36    
37  chdir($TMPDIR) || die "can't cd to $TMPDIR: $!";  chdir($TMPDIR) || die "can't cd to $TMPDIR: $!";
# Line 105  _NEW_REP_ Line 109  _NEW_REP_
109          chdir($TMPDIR) || die "can't cd to $TMPDIR: $!";          chdir($TMPDIR) || die "can't cd to $TMPDIR: $!";
110          rmdir $CVSREP || die "can't remove $CVSREP: $!";          rmdir $CVSREP || die "can't remove $CVSREP: $!";
111    
112          # and checkout it          # and get new changes it
113          log_system("$cvs -q checkout $CVSREP", "cvs checkout failed");          log_system("$cvs -q update -d $CVSREP", "cvs update -d failed");
114    
115          chdir($CVSREP) || die "can't cd to $TMPDIR/$CVSREP: $!";          chdir($CVSREP) || die "can't cd to $TMPDIR/$CVSREP: $!";
116    
# Line 173  while(<LOG>) { Line 177  while(<LOG>) {
177  }  }
178  close(LOG);  close(LOG);
179    
180  my $xml = XMLin($log, ForceArray => [ 'logentry', 'path' ]);  
181    my $xml;
182    eval {
183            $xml = XMLin($log, ForceArray => [ 'logentry', 'path' ]);
184    };
185    
186    
187  #=begin log_example  #=begin log_example
# Line 202  sub in_entries($) { Line 210  sub in_entries($) {
210                  if ($d !~ m,/$, && $d ne "") {                  if ($d !~ m,/$, && $d ne "") {
211                          $d .= "/";                          $d .= "/";
212                  }                  }
213                  open(E, $d."CVS/Entries") || die "can't open ${d}CVS/Entries: $!";                  open(E, $d."CVS/Entries") || return 0;
214                  while(<E>) {                  while(<E>) {
215                          return(1) if (m,^/$f/,);                          return(1) if (m,^/$f/,);
216                  }                  }
# Line 211  sub in_entries($) { Line 219  sub in_entries($) {
219          }          }
220  }  }
221    
222    chdir("$TMPDIR/$CVSREP") || die "can't cd to $TMPDIR/$CVSREP: $!";
223    
224  foreach my $e (@{$xml->{'logentry'}}) {  foreach my $e (@{$xml->{'logentry'}}) {
225          die "BUG: revision from .svnrev ($rev) greater than from subversion (".$e->{'revision'}.")" if ($rev > $e->{'revision'});          die "BUG: revision from .svnrev ($rev) greater than from subversion (".$e->{'revision'}.")" if ($rev > $e->{'revision'});
226          $rev = $e->{'revision'};          $rev = $e->{'revision'};
# Line 257  foreach my $e (@{$xml->{'logentry'}}) { Line 267  foreach my $e (@{$xml->{'logentry'}}) {
267                          if (-d $path) {                          if (-d $path) {
268                                  chdir($path) || die "can't cd into dir $path for import: $!";                                  chdir($path) || die "can't cd into dir $path for import: $!";
269                                  log_system("$cvs import -d -m '$msg' $CVSREP/$path svn r$rev", "cvs import of $path failed");                                  log_system("$cvs import -d -m '$msg' $CVSREP/$path svn r$rev", "cvs import of $path failed");
270                                    chdir("$TMPDIR") || die "can't cd to $TMPDIR/$CVSREP: $!";
271                                  if (-d "$CVSREP/$path") {                                  if (-d "$CVSREP/$path") {
272                                          rmdir "$CVSREP/$path" || die "can't remove $CVSREP/$path: $!";                                          rmtree "$CVSREP/$path" || die "can't remove $CVSREP/$path: $!";
273                                  } else {                                  } else {
274                                          unlink "$CVSREP/$path" || die "can't remove $CVSREP/$path: $!";                                          unlink "$CVSREP/$path" || die "can't remove $CVSREP/$path: $!";
275                                  }                                  }
276                                  chdir("$TMPDIR") || die "can't cd to $TMPDIR/$CVSREP: $!";                                  log_system("$cvs update -d $CVSREP", "cvs update -d of imported dir $path failed");
                                 log_system("$cvs checkout $CVSREP/$path", "cvs checkout of imported dir $path failed");  
277                                  chdir("$TMPDIR/$CVSREP") || die "can't cd back to $TMPDIR/$CVSREP: $!";                                  chdir("$TMPDIR/$CVSREP") || die "can't cd back to $TMPDIR/$CVSREP: $!";
278                          } elsif ($path =~ m,^(.+)/[^/]+$, && ! -e "$1/CVS/Root") {                          } elsif ($path =~ m,^(.+)/[^/]+$, && ! -e "$1/CVS/Root") {
279                                  my $dir = $1;                                  my $dir = $1;
# Line 293  foreach my $e (@{$xml->{'logentry'}}) { Line 303  foreach my $e (@{$xml->{'logentry'}}) {
303          commit_svnrev($rev);          commit_svnrev($rev);
304  }  }
305    
306    # cd out of $CVSREP before File::Temp::END is called
307    chdir("/tmp") || die "can't cd to /tmp: $!";
308    
309  __END__  __END__
310    
311  =pod  =pod
# Line 408  Documentation improvements and other sma Line 421  Documentation improvements and other sma
421    
422  Fixed path deduction (overlap between Subversion reporistory and CVS checkout).  Fixed path deduction (overlap between Subversion reporistory and CVS checkout).
423    
424    =item r21
425    
426    Use C<update -d> instead of checkout after import.
427    Added fixes by Paul Egan <paulegan@mail.com> for XMLin and fixing working
428    directory.
429    
430    
431  =back  =back
432    
433  =head1 AUTHOR  =head1 AUTHOR

Legend:
Removed from v.20  
changed lines
  Added in v.21

  ViewVC Help
Powered by ViewVC 1.1.26