cvsimport: complete the cvsps run before starting the import

We now capture the output of cvsps to a tempfile, and then read it in.
cvsps 2.1 works quite a bit "in memory", and only prints its patchset
info once it has finished talking with cvs, but apparently retaining
all that memory allocation. With this patch, cvsps is finished and
reaped before cvsimport start working (and growing). So the footprint
of the whole process is much lower.

Signed-off-by: Martin Langhoff <martin@catalyst.net.nz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Martin Langhoff 2006-06-11 20:12:20 +12:00 committed by Junio C Hamano
parent 71b0814836
commit 2f57c69792

View File

@ -529,25 +529,39 @@ if ($opt_A) {
write_author_info("$git_dir/cvs-authors"); write_author_info("$git_dir/cvs-authors");
} }
my $pid = open(CVS,"-|");
die "Cannot fork: $!\n" unless defined $pid; #
unless($pid) { # run cvsps into a file unless we are getting
my @opt; # it passed as a file via $opt_P
@opt = split(/,/,$opt_p) if defined $opt_p; #
unshift @opt, '-z', $opt_z if defined $opt_z; unless ($opt_P) {
unshift @opt, '-q' unless defined $opt_v; print "Running cvsps...\n" if $opt_v;
unless (defined($opt_p) && $opt_p =~ m/--no-cvs-direct/) { my $pid = open(CVSPS,"-|");
push @opt, '--cvs-direct'; die "Cannot fork: $!\n" unless defined $pid;
unless($pid) {
my @opt;
@opt = split(/,/,$opt_p) if defined $opt_p;
unshift @opt, '-z', $opt_z if defined $opt_z;
unshift @opt, '-q' unless defined $opt_v;
unless (defined($opt_p) && $opt_p =~ m/--no-cvs-direct/) {
push @opt, '--cvs-direct';
}
exec("cvsps","--norc",@opt,"-u","-A",'--root',$opt_d,$cvs_tree);
die "Could not start cvsps: $!\n";
} }
if ($opt_P) { my ($cvspsfh, $cvspsfile) = tempfile('gitXXXXXX', SUFFIX => '.cvsps',
exec("cat", $opt_P); DIR => File::Spec->tmpdir());
} else { while (<CVSPS>) {
exec("cvsps","--norc",@opt,"-u","-A",'--root',$opt_d,$cvs_tree); print $cvspsfh $_;
die "Could not start cvsps: $!\n";
} }
close CVSPS;
close $cvspsfh;
$opt_P = $cvspsfile;
} }
open(CVS, "<$opt_P") or die $!;
## cvsps output: ## cvsps output:
#--------------------- #---------------------
#PatchSet 314 #PatchSet 314