{"thread":{"id":"4461","subject":"[PATCH] cvsimport: complete the cvsps run before starting the import - take 2","startedAt":"2006-06-11T08:12:20Z","lastAt":"2006-06-11T08:12:20Z","messageCount":1,"participants":["Martin Langhoff"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"21583","messageId":"11500135403166-git-send-email-martin@catalyst.net.nz","threadId":"4461","inReplyTo":null,"subject":"[PATCH] cvsimport: complete the cvsps run before starting the import - take 2","fromName":"Martin Langhoff","fromEmail":"martin@catalyst.net.nz","sentAt":"2006-06-11T08:12:20Z","receivedAt":"2006-06-11T08:12:20Z","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\nThis is a more reliable implementation, which fork/execs and passes the cvsps\noutput into the tempfile.\n---\n git-cvsimport.perl |   42 ++++++++++++++++++++++++++++--------------\n 1 files changed, 28 insertions(+), 14 deletions(-)\n\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex 07b3203..9a7408b 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -529,25 +529,39 @@ 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-\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-\tunless (defined($opt_p) && $opt_p =~ m/--no-cvs-direct/) {\n-\t\tpush @opt, '--cvs-direct';\n+\n+#\n+# run cvsps into a file unless we are getting\n+# it passed as a file via $opt_P\n+#\n+unless ($opt_P) {\n+\tprint \"Running cvsps...\\n\" if $opt_v;\n+\tmy $pid = open(CVSPS,\"-|\");\n+\tdie \"Cannot fork: $!\\n\" unless defined $pid;\n+\tunless($pid) {\n+\t\tmy @opt;\n+\t\t@opt = split(/,/,$opt_p) if defined $opt_p;\n+\t\tunshift @opt, '-z', $opt_z if defined $opt_z;\n+\t\tunshift @opt, '-q'         unless defined $opt_v;\n+\t\tunless (defined($opt_p) && $opt_p =~ m/--no-cvs-direct/) {\n+\t\t\tpush @opt, '--cvs-direct';\n+\t\t}\n+\t\texec(\"cvsps\",\"--norc\",@opt,\"-u\",\"-A\",'--root',$opt_d,$cvs_tree);\n+\t\tdie \"Could not start cvsps: $!\\n\";\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+\tmy ($cvspsfh, $cvspsfile) = tempfile('gitXXXXXX', SUFFIX => '.cvsps',\n+\t\t\t\t\t     DIR => File::Spec->tmpdir());\n+\twhile (<CVSPS>) {\n+\t    print $cvspsfh $_;\n \t}\n+\tclose CVSPS;\n+\tclose $cvspsfh;\n+\t$opt_P = $cvspsfile;\n }\n \n \n+open(CVS, \"<$opt_P\") or die $!;\n+\n ## cvsps output:\n #---------------------\n #PatchSet 314\n-- \n1.4.0.gcda2\n"}]}