git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Sven Verdoolaege <skimo@kotnet.org>
To: Matthias Urlichs <smurf@smurf.noris.de>, git@vger.kernel.org
Subject: [PATCH] git-cvsimport-script: leave working directory alone.
Date: Mon, 4 Jul 2005 14:13:09 +0200	[thread overview]
Message-ID: <20050704121309.GI18608MdfPADPa@garage.linux.student.kuleuven.ac.be> (raw)
In-Reply-To: <20050703103517.GJ5992MdfPADPa@garage.linux.student.kuleuven.ac.be>

git-cvsimport-script: leave working directory alone.

---
commit 2eb6d82eaa869a1faf4ba3326fd628f76f9f93a8
tree 3e59c8c298e51a8ae20102b4b139c84c79fa54a0
parent 866d13108e969773347828daa9b7f3476ec70cb8
author Sven Verdoolaege <skimo@kotnet.org> Mon, 04 Jul 2005 00:43:26 +0200
committer Sven Verdoolaege <skimo@kotnet.org> Mon, 04 Jul 2005 00:43:26 +0200

 git-cvsimport-script |   81 ++++++++++++++++++++++++++++++--------------------
 1 files changed, 48 insertions(+), 33 deletions(-)

diff --git a/git-cvsimport-script b/git-cvsimport-script
--- a/git-cvsimport-script
+++ b/git-cvsimport-script
@@ -80,6 +80,8 @@ package CVSconn;
 # Basic CVS dialog.
 # We're only interested in connecting and downloading, so ...
 
+use File::Spec;
+use File::Temp qw(tempfile);
 use POSIX qw(strftime dup2);
 
 sub new {
@@ -231,11 +233,11 @@ sub _file {
 sub _line {
 	# Read a line from the server.
 	# ... except that 'line' may be an entire file. ;-)
-	my($self) = @_;
+	my($self, $fh) = @_;
 	die "Not in lines" unless defined $self->{'lines'};
 
 	my $line;
-	my $res="";
+	my $res=0;
 	while(defined($line = $self->readline())) {
 		# M U gnupg-cvs-rep/AUTHORS
 		# Updated gnupg-cvs-rep/
@@ -255,16 +257,18 @@ sub _line {
 			chomp $cnt;
 			die "Duh: Filesize $cnt" if $cnt !~ /^\d+$/;
 			$line="";
-			$res="";
+			$res=0;
 			while($cnt) {
 				my $buf;
 				my $num = $self->{'socketi'}->read($buf,$cnt);
 				die "Server: Filesize $cnt: $num: $!\n" if not defined $num or $num<=0;
-				$res .= $buf;
+				print $fh $buf;
+				$res += $num;
 				$cnt -= $num;
 			}
 		} elsif($line =~ s/^ //) {
-			$res .= $line;
+			print $fh $line;
+			$res += length($line);
 		} elsif($line =~ /^M\b/) {
 			# output, do nothing
 		} elsif($line =~ /^Mbinary\b/) {
@@ -277,7 +281,8 @@ sub _line {
 				my $buf;
 				my $num = $self->{'socketi'}->read($buf,$cnt);
 				die "S: Mbinary $cnt: $num: $!\n" if not defined $num or $num<=0;
-				$res .= $buf;
+				print $fh $buf;
+				$res += $num;
 				$cnt -= $num;
 			}
 		} else {
@@ -297,18 +302,21 @@ sub file {
 	my($self,$fn,$rev) = @_;
 	my $res;
 
-	if ($self->_file($fn,$rev)) {
-		$res = $self->_line();
-		return $res if defined $res;
+	my ($fh, $name) = tempfile('gitcvs.XXXXXX', 
+		    DIR => File::Spec->tmpdir(), UNLINK => 1);
+
+	$self->_file($fn,$rev) and $res = $self->_line($fh);
+
+	if (!defined $res) {
+	    # retry
+	    $self->conn();
+	    $self->_file($fn,$rev)
+		    or die "No file command send\n";
+	    $res = $self->_line($fh);
+	    die "No input: $fn $rev\n" unless defined $res;
 	}
 
-	# retry
-	$self->conn();
-	$self->_file($fn,$rev)
-		or die "No file command send\n";
-	$res = $self->_line();
-	die "No input: $fn $rev\n" unless defined $res;
-	return $res;
+	return ($name, $res);
 }
 
 
@@ -457,13 +465,14 @@ my $commit = sub {
 	}
 	while(@new) {
 		my @n2;
-		if(@new > 55) {
-			@n2 = splice(@new,0,50);
+		if(@new > 12) {
+			@n2 = splice(@new,0,10);
 		} else {
 			@n2 = @new;
 			@new = ();
 		}
-		system("git-update-cache","--add","--",@n2);
+		system("git-update-cache","--add",
+			(map { ('--cacheinfo', @$_) } @n2));
 		die "Cannot add files: $?\n" if $?;
 	}
 
@@ -631,7 +640,7 @@ while(<CVS>) {
 		}
 		if(($ancestor || $branch) ne $last_branch) {
 			print "Switching from $last_branch to $branch\n" if $opt_v;
-			system("git-read-tree","-m","-u","$last_branch","$branch");
+			system("git-read-tree","-m","$last_branch","$branch");
 			die "read-tree failed: $?\n" if $?;
 		}
 		if($branch ne $last_branch) {
@@ -648,17 +657,16 @@ while(<CVS>) {
 		my $fn = $1;
 		my $rev = $3;
 		$fn =~ s#^/+##;
-		my $data = $cvs->file($fn,$rev);
-		print "".($init ? "New" : "Update")." $fn: ".length($data)." bytes.\n" if $opt_v;
-		mkpath(dirname($fn),$opt_v);
-		open(F,"> ./$fn")
-			or die "Cannot create '$fn': $!\n";
-		print F $data
-			or die "Cannot write to '$fn': $!\n";
-		close(F)
-			or die "Cannot write to '$fn': $!\n";
-		chmod(pmode($cvs->{'mode'}), $fn);
-		push(@new,$fn); # may be resurrected!
+		my ($tmpname, $size) = $cvs->file($fn,$rev);
+		print "".($init ? "New" : "Update")." $fn: $size bytes.\n" if $opt_v;
+		open my $F, '-|', "git-write-blob $tmpname"
+			or die "Cannot create object: $!\n";
+		my $sha = <$F>;
+		chomp $sha;
+		close $F;
+		unlink($tmpname);
+		my $mode = pmode($cvs->{'mode'});
+		push(@new,[$mode, $sha, $fn]); # may be resurrected!
 	} elsif($state == 9 and /^\s+(\S+):\d(?:\.\d+)+->(\d(?:\.\d+)+)\(DEAD\)\s*$/) {
 		my $fn = $1;
 		$fn =~ s#^/+##;
@@ -688,8 +696,15 @@ if($orig_branch) {
 		unless -f "$git_dir/refs/heads/master";
 }
 
-system("git-read-tree","-m","-u","$last_branch","$orig_branch");
-die "read-tree failed: $?\n" if $?;
+if ($orig_branch) {
+	system("git-read-tree",$last_branch);
+	die "read-tree failed: $?\n" if $?;
+} else {
+	system('git-read-tree', $orig_branch);
+	die "read-tree failed: $?\n" if $?;
+	system('git-checkout-cache', '-a');
+	die "checkout-cache failed: $?\n" if $?;
+}
 
 unlink("$git_dir/HEAD");
 symlink("refs/heads/$orig_branch","$git_dir/HEAD");

  parent reply	other threads:[~2005-07-04 12:32 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-28 19:23 [PATCH] cvsimport: rewritten in Perl Matthias Urlichs
2005-06-29 15:06 ` Nicolas Pitre
2005-06-29 20:40   ` Matthias Urlichs
2005-06-30 10:30     ` Matthias Urlichs
2005-06-30 16:48       ` Nicolas Pitre
2005-06-30 10:34 ` [PATCH] cvsimport-in-Perl: Limit the number of arguments to git-update-cache Matthias Urlichs
2005-06-30 16:54   ` Nicolas Pitre
2005-06-30 17:15     ` Nicolas Pitre
2005-06-30 18:02       ` Matthias Urlichs
2005-06-30 14:55 ` [PATCH] cvsimport: perform string comparison on "HEAD" Sven Verdoolaege
2005-06-30 15:21   ` Matthias Urlichs
2005-06-30 16:38   ` [PATCH] cvsimport: Limit the log string to 32k Matthias Urlichs
2005-06-30 15:02 ` [PATCH] cvsimport: rewritten in Perl Sven Verdoolaege
2005-06-30 15:21   ` Matthias Urlichs
2005-06-30 15:44     ` Sven Verdoolaege
2005-06-30 16:10       ` Matthias Urlichs
2005-06-30 16:14         ` Sven Verdoolaege
2005-06-30 16:30           ` Matthias Urlichs
2005-06-30 17:22             ` Nicolas Pitre
2005-07-01  9:43               ` Matthias Urlichs
2005-07-03 10:35                 ` Sven Verdoolaege
2005-07-03 10:36                   ` [PATCH] Make specification of CVS module to convert optional Sven Verdoolaege
2005-07-03 10:37                   ` git-cvsimport-script: clean up documentation Sven Verdoolaege
2005-07-03 11:37                   ` git-cvsimport-script: Honour CVS_SERVER Sven Verdoolaege
2005-07-03 11:38                   ` [PATCH] git-cvsimport-script: Support :ext: access method Sven Verdoolaege
2005-07-03 12:21                   ` cvsimport: rewritten in Perl Sven Verdoolaege
2005-07-03 13:44                     ` Matthias Urlichs
2005-07-05 23:02                       ` Wolfgang Denk
2005-07-06  2:41                         ` Linus Torvalds
2005-07-06  6:37                           ` Sven Verdoolaege
2005-07-06  7:32                             ` Matthias Urlichs
2005-07-06 10:24                           ` Wolfgang Denk
2005-07-04 12:13                   ` Sven Verdoolaege [this message]
2005-07-04 12:13                   ` [PATCH] git-cvsimport-script: use private index Sven Verdoolaege
2005-07-04 14:06                   ` [PATCH] git-cvsimport-script: fix branch switching Sven Verdoolaege
2005-07-04 14:09                   ` [PATCH] git-cvsimport-script: update cvsps cache instead of rebuilding it Sven Verdoolaege
2005-06-30 19:38         ` [PATCH] cvsimport: rewritten in Perl Sven Verdoolaege
2005-06-30 21:00           ` Matthias Urlichs
2005-07-01  7:01             ` Sven Verdoolaege
2005-07-01  7:25               ` Matthias Urlichs
2005-07-04 13:03             ` Sven Verdoolaege
2005-07-04 13:53               ` Matthias Urlichs
2005-07-04 13:46                 ` Sven Verdoolaege
2005-07-04 14:36                   ` Matthias Urlichs
2005-07-04 15:52                     ` Sven Verdoolaege
2005-07-03 23:03     ` Sven Verdoolaege
2005-07-04  1:49       ` Matthias Urlichs
2005-07-04 10:47         ` Sven Verdoolaege
2005-06-30 18:48 ` Stephen C. Tweedie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050704121309.GI18608MdfPADPa@garage.linux.student.kuleuven.ac.be \
    --to=skimo@kotnet.org \
    --cc=git@vger.kernel.org \
    --cc=skimo@liacs.nl \
    --cc=smurf@smurf.noris.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).