@matheusbsbs / matheus-bagliano / commits / f0daa628a2
Fork 0

svn import: copy path information

Due to a bug in the SVN library, path information is freed as soon as the callback returns, even if it still refers to the data. Workaround: Copy it. (Also fix a wrong-method-name bug while we're at it.) Signed-Off-By: Matthias Urlichs <smurf@smurf.noris.de>

Matthias Urlichs committed Oct 10, 2005 at 12:41 UTC f0daa628a297819ed039e6b61d337fde02d8a6dd
1 file changed +16 -10
git-svnimport.perl
+16 -10
@@ -346,9 +346,9 @@ sub commit {
346 $dest = $parent;
347
348 my $prev = $changed_paths->{"/"};
349 - if($prev and $prev->action eq "A") {
349 + if($prev and $prev->[0] eq "A") {
350 delete $changed_paths->{"/"};
351 - my $oldpath = $prev->copyfrom_path;
351 + my $oldpath = $prev->[1];
352 my $rev;
353 if(defined $oldpath) {
354 my $p;
@@ -385,7 +385,7 @@ sub commit {
385 $rev = undef;
386 }
387
388 -# if($prev and $prev->action eq "A") {
388 +# if($prev and $prev->[0] eq "A") {
389 # if(not $tag) {
390 # unless(open(H,"> $git_dir/refs/heads/$branch")) {
391 # print STDERR "$revision: Could not create branch $branch: $!\n";
@@ -408,21 +408,21 @@ sub commit {
408 }
409
410 while(my($path,$action) = each %$changed_paths) {
411 - if ($action->action eq "A") {
411 + if ($action->[0] eq "A") {
412 my $f = get_file($revision,$branch,$path);
413 push(@new,$f) if $f;
414 - } elsif ($action->action eq "D") {
414 + } elsif ($action->[0] eq "D") {
415 push(@old,$path);
416 - } elsif ($action->action eq "M") {
416 + } elsif ($action->[0] eq "M") {
417 my $f = get_file($revision,$branch,$path);
418 push(@new,$f) if $f;
419 - } elsif ($action->action eq "R") {
419 + } elsif ($action->[0] eq "R") {
420 # refer to a file/tree in an earlier commit
421 push(@old,$path); # remove any old stuff
422
423 # ... and add any new stuff
424 - my($b,$p) = split_path($revision,$action->oldpath);
425 - open my $F,"-|","git-ls-tree","-r","-z", $branches{$b}{$action->oldrev}, $p;
424 + my($b,$p) = split_path($revision,$action->[1]);
425 + open my $F,"-|","git-ls-tree","-r","-z", $branches{$b}{$action->[2]}, $p;
426 local $/ = '\0';
427 while(<$F>) {
428 chomp;
@@ -432,7 +432,7 @@ sub commit {
432 push(@new,[$mode,$sha1,$p]);
433 }
434 } else {
435 - die "$revision: unknown action '".$action->action."' for $path\n";
435 + die "$revision: unknown action '".$action->[0]."' for $path\n";
436 }
437 }
438
@@ -596,7 +596,13 @@ sub commit {
596 my ($changed_paths, $revision, $author, $date, $message, $pool) = @_;
597 sub _commit_all {
598 ($changed_paths, $revision, $author, $date, $message, $pool) = @_;
599 + my %p;
600 + while(my($path,$action) = each %$changed_paths) {
601 + $p{$path} = [ $action->action,$action->copyfrom_path, $action->copyfrom_rev ];
602 + }
603 + $changed_paths = \%p;
604 }
605 +
606 sub commit_all {
607 my %done;
608 my @col;