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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux