{"thread":{"id":"4351","subject":"[PATCH] cvsimport: complete the cvsps run before starting the import","startedAt":"2006-05-30T08:08:50Z","lastAt":"2006-05-30T08:08:50Z","messageCount":1,"participants":["Martin Langhoff"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"20962","messageId":"11489765301990-git-send-email-martin@catalyst.net.nz","threadId":"4351","inReplyTo":null,"subject":"[PATCH] cvsimport: complete the cvsps run before starting the import","fromName":"Martin Langhoff","fromEmail":"martin@catalyst.net.nz","sentAt":"2006-05-30T08:08:50Z","receivedAt":"2006-05-30T08:08:50Z","isPatch":true,"sender":{"key":"martin@laptop.org","avatar":null},"body":"On 5/24/06, Linus Torvalds <torvalds@osdl.org> wrote:\n> It's entirely possible that the fact that it now seems to work for me is\n> purely timing-related, since I also ended up using \"-P cvsps-output\" to\n> avoid having a huge cvsps binary in memory at the same time.\n\nWe now capture the output of cvsps to a tempfile, and then read it in.\ncvsps 2.1 works quite a bit \"in memory\", and only prints its patchset info\nonce it has finished talking with cvs, but apparently retaining all that\nmemory allocation. With this patch, cvsps is finished and reaped before\ncvsimport start working (and growing). So the footprint of the whole\nprocess is much lower.\n\nSigned-off-by: Martin Langhoff <martin@catalyst.net.nz>\n---\n\nI don't particularly like the idea of switching from a safe system() call\nto this ugly one. But this patch makes a huge difference importing gentoo's\nrepo, and I could not find a way to get system() to do redirection.\n\nOf course, we could do the redirection in Perl. Ugly vs uglier?\n\n---\n\n git-cvsimport.perl |   32 ++++++++++++++++++++++----------\n 1 files changed, 22 insertions(+), 10 deletions(-)\n\n5ce458e0883f39ae774ec67211e6565b65139b7f\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex 60fc86a..2239c67 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -529,24 +529,36 @@ if ($opt_A) {\n \twrite_author_info(\"$git_dir/cvs-authors\");\n }\n \n-my $pid = open(CVS,\"-|\");\n-die \"Cannot fork: $!\\n\" unless defined $pid;\n-unless($pid) {\n+#\n+# run cvsps into a file unless it's provided already\n+#\n+my $cvspsfile;\n+if ($opt_P) {\n+       $cvspsfile = $opt_P;\n+} else {\n+\tmy $cvspsfh;\n+\t($cvspsfh, $cvspsfile) = tempfile('gitXXXXXX', SUFFIX => '.cvsps',\n+\t\t\t\t\t  DIR => File::Spec->tmpdir());\n+\tclose ($cvspsfh);\n+\tmy ($cvspserrfh, $cvspserr)  = tempfile('gitXXXXXX', SUFFIX => '.err',\n+\t\t\t\t\t\tDIR => File::Spec->tmpdir());\n+\tclose ($cvspserrfh);\n+\n \tmy @opt;\n \t@opt = split(/,/,$opt_p) if defined $opt_p;\n \tunshift @opt, '-z', $opt_z if defined $opt_z;\n-\tunshift @opt, '-q'         unless defined $opt_v;\n+\tunshift @opt, '-q'\t   unless defined $opt_v;\n \tunless (defined($opt_p) && $opt_p =~ m/--no-cvs-direct/) {\n \t\tpush @opt, '--cvs-direct';\n \t}\n-\tif ($opt_P) {\n-\t    exec(\"cat\", $opt_P);\n-\t} else {\n-\t    exec(\"cvsps\",\"--norc\",@opt,\"-u\",\"-A\",'--root',$opt_d,$cvs_tree);\n-\t    die \"Could not start cvsps: $!\\n\";\n-\t}\n+\n+\tprint \"Running cvsps\\n\"\t\t  if $opt_v;\n+\tsystem(join(' ', \"cvsps\",\"--norc\",@opt,\"-u\",\"-A\",'--root',$opt_d,$cvs_tree, \"1>$cvspsfile\" ))\n+\t\tor die \"Error in cvsps: $!\\n\";\n }\n \n+open (CVS, \"<$cvspsfile\") \n+        or die \"Cannot open cvsps output file $cvspsfile: $!\\n\";\n \n ## cvsps output:\n #---------------------\n-- \n1.3.2.g82000\n"}]}