threads / discuss / 2238

git-cvsimport: $cvs->file() fails silently

Subject: git-cvsimport: $cvs->file() fails silently

## tl;dr

2 messages between Oct 27, 2005 and Nov 1, 2005.

replies: 1people: 1as markdown or json

Martin Langhoff· Oct 27, 2005, 04:23 UTC · lore

We have seen a few instances of files extracted from a remote CVS repo by $cvs->file() being empty, and still git-cvsimport did not die or complain. If I rewind the affected head and re-run git-cvsimport, the file is imported correctly, which makes me suspect that the server went away or there was some other networking glitch, and that the file() and _file() methods didn't handle it gracefully.

I've been through the file(), _file() and _line() methods, and they seem pretty conservative -- they die or return undef in all the right places. There _must_ be one place that we're missing but I just can't see it.

Any ideas?
martin
Martin Langhoff· Nov 1, 2005, 01:22 UTC · re: Martin Langhoff · lore

Re: git-cvsimport: $cvs->file() fails silently

On 10/27/05, Martin Langhoff <martin.langhoff@gmail.com> wrote:
> There _must_ be one place that we're missing but I just can't
> see it.

Got some more info on this. The output of cvsimport when this happens looks like this:

Read from remote host cvs.sourceforge.net: Connection reset by peer Read from remote host cvs.sourceforge.net: Connection reset by peer Update course/enrol.php: bytes Use of uninitialized value in split at /home/martin/local/git/git-cvsimport line 362. Update lang/en/moodle.php: 66792 bytes Tree ID ef11ad5a0cf917e98bc477837de1b3f587e12027 Parent ID e972b3a28e1c4802fc5af6a996164c93fb4f3e53 Committed patch 20143 (MOODLE_15_STABLE 2005-10-31 20:31:57) Commit ID 95a748b0d9cd6dc74e65497561514fa5858c149c

Around line 335 $res = $self->_line($fh); is returning '', which is defined but otherwise empty. I've patched cvsimport thus to try and catch this kind of error:

diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index bbb83fb..f594df3 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -337,6 +337,10 @@ sub file {
        }
        close ($fh);

+       if ($res eq '') {
+           die "Looks like the server has gone away during the transaction!";
+       }
+
        return ($name, $res);
 }

@@ -764,6 +768,9 @@ while(<CVS>) {
                my $rev = $3;
                $fn =~ s#^/+##;
                my ($tmpname, $size) = $cvs->file($fn,$rev);
+               if ($size eq '') {
+                       die "Should not happen! Something went wrong
with the remote connection";
+               }
                if($size == -1) {
                        push(@old,$fn);
                        print "Drop $fn\n" if $opt_v;

Now, I'm sure we can catch it in the "right" place, but I'm not sure
where that is.

cheers,


martin

← back to recent threads