svn import: add eval()
Trying to downlaod a file that's really a subdirectory doesn't work too well. Signed-Off-By: Matthias Urlichs <smurf@smurf.noris.de>
Matthias Urlichs committed
Oct 10, 2005 at 12:33 UTC
2b5e63d1b4a6f1b0ef58755a192ecb2d04e3569d
1 file changed
+11
-5
git-svnimport.perl
+11
-5
@@ -121,12 +121,15 @@ sub file {
121
my ($fh, $name) = tempfile('gitsvn.XXXXXX',
122
DIR => File::Spec->tmpdir(), UNLINK => 1);
123
124
- $self->{'svn'}->get_file($path,$rev,$fh) or do {
124
+ print "... $rev $path ...\n" if $opt_v;
125
+ eval { $self->{'svn'}->get_file($path,$rev,$fh); };
126
+ if (defined $@ and $@ !~ /Attempted to get checksum/) {
127
# retry
128
$self->conn();
127
- $self->{'svn'}->get_file($path,$rev,$fh)
128
- or die "$rev: No file $path at $rev\n";
129
+ eval { $self->{'svn'}->get_file($path,$rev,$fh); };
130
};
131
+ return () if defined $@ and $@ !~ /Attempted to get checksum/;
132
+ die $@ if $@;
133
close ($fh);
134
135
return ($name, $res);
@@ -308,7 +311,8 @@ sub get_file($$$) {
311
}
312
313
# now get it
311
- my ($name, $res) = $svn->file($svnpath,$rev);
314
+ my ($name, $res) = eval { $svn->file($svnpath,$rev); };
315
+ return () unless defined $name;
316
317
open my $F, '-|', "git-hash-object -w $name"
318
or die "Cannot create object: $!\n";
@@ -343,7 +347,9 @@ sub commit {
347
my($author_name,$author_email,$dest);
348
my(@old,@new);
349
346
- if ($author =~ /^(.*?)\s+<(.*)>$/) {
350
+ if (not defined $author) {
351
+ $author_name = $author_email = "unknown";
352
+ } elsif ($author =~ /^(.*?)\s+<(.*)>$/) {
353
($author_name, $author_email) = ($1, $2);
354
} else {
355
$author =~ s/^<(.*)>$/$1/;