git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH/RFC] git-cvsimport: When fetching a file and an error occurs, disconnect and retry

From
Michal Sojka <sojkam1@fel.cvut.cz>
Date
Mar 30, 2008, 01:50 UTC
Message-ID
<1206841808-24605-1-git-send-email-sojkam1@fel.cvut.cz>

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
Message 1 of 1 in “git-cvsimport: When fetching a file and an error occurs, disconnect and retry”
  1. git-cvsimport: When fetching a file and an error occurs, disconnect and retryMichal Sojka, Mar 30, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.