git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH/RFC] git-cvsimport: When fetching a file and an error occurs, disconnect and retry
@ 2008-03-30  1:50 Michal Sojka
  0 siblings, 0 replies; only message in thread
From: Michal Sojka @ 2008-03-30  1:50 UTC (permalink / raw)
  To: git; +Cc: Michal Sojka

I imported my repositories from CVSNT server 1.11.1.3 and on some of
them import died with error like this:

Fetching libvideo\libvideo/libvideo.dsp   v 1.1.1.1
Unknown: error

After some searching I have found that the reason is probably wrong
naming of my directories (i.e. directories with the same name at
different locations). I'm not CVS guru but guess that CVS server tracks
what we are downloading and assumes that we are downloading all
subdirectories (at all levels) to one common directory. If more
subdirectories have the same name, it refuses to send the latter ones to
avoid overwriting the first one.

The dump of TCP communication was like this:

C: Argument -N
C: Argument -P
C: Argument -r
C: Argument 1.1
C: Argument --
C: Argument video/libvideo\libvideo/libvideo.dsp
C: Directory .
C: /d//cvs
C: co
S: E cvs server: existing repository d:/cvs/video/libvideo does not match d:/cvs/video/libvideo\libvideo
S: E cvs server: ignoring module video/libvideo\libvideo/libvideo.dsp
S: error

This patch solved the problem for me. When the error is received,
instead of dying immediately, the connection is closed, then opened again
and the second fetch attempt is executed.
---
 git-cvsimport.perl |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index 95c5eec..b33ed53 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -438,7 +438,10 @@ sub _line {
 				die "Unknown: $line" if $line ne "ok";
 				return -1;
 			} else {
-				die "Unknown: $line\n";
+				STDOUT->flush(); # To see which file cannot be fetched
+				print STDERR "Unexpected response: $line\nDisconnecting and retrying...\n";
+				$self->{"socketo"}->close();
+				return -2;
 			}
 		}
 	}
@@ -453,13 +456,13 @@ sub file {
 
 	$self->_file($fn,$rev) and $res = $self->_line($fh);
 
-	if (!defined $res) {
-	    print STDERR "Server has gone away while fetching $fn $rev, retrying...\n";
+	if (!defined $res || $res == -2) {
+	    print STDERR "Server has gone away while fetching $fn $rev, retrying...\n" if !defined $res;
 	    truncate $fh, 0;
 	    $self->conn();
 	    $self->_file($fn,$rev) or die "No file command send";
 	    $res = $self->_line($fh);
-	    die "Retry failed" unless defined $res;
+	    die "Retry failed" unless (defined $res && $res != -2);
 	}
 	close ($fh);
 
-- 
1.5.4.5

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2008-03-30  2:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-30  1:50 [PATCH/RFC] git-cvsimport: When fetching a file and an error occurs, disconnect and retry Michal Sojka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).