cvsimport: cleanup temporary cvsps file

It is bad manners to leave these sizable files
around when we are done with them.

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
2007-01-08 21:08:46 +13:00
committed by Junio C Hamano
parent eec8496210
commit 4083c2fce8

View File

@ -575,9 +575,11 @@ if ($opt_A) {
# run cvsps into a file unless we are getting # run cvsps into a file unless we are getting
# it passed as a file via $opt_P # it passed as a file via $opt_P
# #
my $cvspsfile;
unless ($opt_P) { unless ($opt_P) {
print "Running cvsps...\n" if $opt_v; print "Running cvsps...\n" if $opt_v;
my $pid = open(CVSPS,"-|"); my $pid = open(CVSPS,"-|");
my $cvspsfh;
die "Cannot fork: $!\n" unless defined $pid; die "Cannot fork: $!\n" unless defined $pid;
unless ($pid) { unless ($pid) {
my @opt; my @opt;
@ -590,18 +592,18 @@ unless ($opt_P) {
exec("cvsps","--norc",@opt,"-u","-A",'--root',$opt_d,$cvs_tree); exec("cvsps","--norc",@opt,"-u","-A",'--root',$opt_d,$cvs_tree);
die "Could not start cvsps: $!\n"; die "Could not start cvsps: $!\n";
} }
my ($cvspsfh, $cvspsfile) = tempfile('gitXXXXXX', SUFFIX => '.cvsps', ($cvspsfh, $cvspsfile) = tempfile('gitXXXXXX', SUFFIX => '.cvsps',
DIR => File::Spec->tmpdir()); DIR => File::Spec->tmpdir());
while (<CVSPS>) { while (<CVSPS>) {
print $cvspsfh $_; print $cvspsfh $_;
} }
close CVSPS; close CVSPS;
close $cvspsfh; close $cvspsfh;
$opt_P = $cvspsfile; } else {
$cvspsfile = $opt_P;
} }
open(CVS, "<$cvspsfile") or die $!;
open(CVS, "<$opt_P") or die $!;
## cvsps output: ## cvsps output:
#--------------------- #---------------------
@ -936,6 +938,10 @@ while (<CVS>) {
} }
commit() if $branch and $state != 11; commit() if $branch and $state != 11;
unless ($opt_P) {
unlink($cvspsfile);
}
# The heuristic of repacking every 1024 commits can leave a # The heuristic of repacking every 1024 commits can leave a
# lot of unpacked data. If there is more than 1MB worth of # lot of unpacked data. If there is more than 1MB worth of
# not-packed objects, repack once more. # not-packed objects, repack once more.