@matheusbsbs / matheus-bagliano / commits / 4083c2fce8
Fork 0

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>

Martin Langhoff committed Jan 8, 2007 at 21:08 UTC 4083c2fce86c777415a3bc0d5813bcb73f676f98
1 file changed +11 -5
git-cvsimport.perl
+11 -5
@@ -575,9 +575,11 @@ if ($opt_A) {
575 # run cvsps into a file unless we are getting
576 # it passed as a file via $opt_P
577 #
578 +my $cvspsfile;
579 unless ($opt_P) {
580 print "Running cvsps...\n" if $opt_v;
581 my $pid = open(CVSPS,"-|");
582 + my $cvspsfh;
583 die "Cannot fork: $!\n" unless defined $pid;
584 unless ($pid) {
585 my @opt;
@@ -590,18 +592,18 @@ unless ($opt_P) {
592 exec("cvsps","--norc",@opt,"-u","-A",'--root',$opt_d,$cvs_tree);
593 die "Could not start cvsps: $!\n";
594 }
593 - my ($cvspsfh, $cvspsfile) = tempfile('gitXXXXXX', SUFFIX => '.cvsps',
594 - DIR => File::Spec->tmpdir());
595 + ($cvspsfh, $cvspsfile) = tempfile('gitXXXXXX', SUFFIX => '.cvsps',
596 + DIR => File::Spec->tmpdir());
597 while (<CVSPS>) {
598 print $cvspsfh $_;
599 }
600 close CVSPS;
601 close $cvspsfh;
600 - $opt_P = $cvspsfile;
602 +} else {
603 + $cvspsfile = $opt_P;
604 }
605
603 -
604 -open(CVS, "<$opt_P") or die $!;
606 +open(CVS, "<$cvspsfile") or die $!;
607
608 ## cvsps output:
609 #---------------------
@@ -936,6 +938,10 @@ while (<CVS>) {
938 }
939 commit() if $branch and $state != 11;
940
941 +unless ($opt_P) {
942 + unlink($cvspsfile);
943 +}
944 +
945 # The heuristic of repacking every 1024 commits can leave a
946 # lot of unpacked data. If there is more than 1MB worth of
947 # not-packed objects, repack once more.