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>
Martin Langhoff committed
Jun 11, 2006 at 20:12 UTC
2f57c69792146e6c178a05edec18ab15d0138ad6
1 file changed
+28
-14
git-cvsimport.perl
+28
-14
@@ -529,25 +529,39 @@ if ($opt_A) {
529
write_author_info("$git_dir/cvs-authors");
530
}
531
532
-my $pid = open(CVS,"-|");
533
-die "Cannot fork: $!\n" unless defined $pid;
534
-unless($pid) {
535
- my @opt;
536
- @opt = split(/,/,$opt_p) if defined $opt_p;
537
- unshift @opt, '-z', $opt_z if defined $opt_z;
538
- unshift @opt, '-q' unless defined $opt_v;
539
- unless (defined($opt_p) && $opt_p =~ m/--no-cvs-direct/) {
540
- push @opt, '--cvs-direct';
532
+
533
+#
534
+# run cvsps into a file unless we are getting
535
+# it passed as a file via $opt_P
536
+#
537
+unless ($opt_P) {
538
+ print "Running cvsps...\n" if $opt_v;
539
+ my $pid = open(CVSPS,"-|");
540
+ die "Cannot fork: $!\n" unless defined $pid;
541
+ unless($pid) {
542
+ my @opt;
543
+ @opt = split(/,/,$opt_p) if defined $opt_p;
544
+ unshift @opt, '-z', $opt_z if defined $opt_z;
545
+ unshift @opt, '-q' unless defined $opt_v;
546
+ unless (defined($opt_p) && $opt_p =~ m/--no-cvs-direct/) {
547
+ push @opt, '--cvs-direct';
548
+ }
549
+ exec("cvsps","--norc",@opt,"-u","-A",'--root',$opt_d,$cvs_tree);
550
+ die "Could not start cvsps: $!\n";
551
}
542
- if ($opt_P) {
543
- exec("cat", $opt_P);
544
- } else {
545
- exec("cvsps","--norc",@opt,"-u","-A",'--root',$opt_d,$cvs_tree);
546
- die "Could not start cvsps: $!\n";
552
+ my ($cvspsfh, $cvspsfile) = tempfile('gitXXXXXX', SUFFIX => '.cvsps',
553
+ DIR => File::Spec->tmpdir());
554
+ while (<CVSPS>) {
555
+ print $cvspsfh $_;
556
}
557
+ close CVSPS;
558
+ close $cvspsfh;
559
+ $opt_P = $cvspsfile;
560
}
561
562
563
+open(CVS, "<$opt_P") or die $!;
564
+
565
## cvsps output:
566
#---------------------
567
#PatchSet 314