{"thread":{"id":"9533","subject":"git-cvsexportcommit getting out of sync with CVS status requests","startedAt":"2007-08-15T11:48:30Z","lastAt":"2007-08-15T16:34:56Z","messageCount":5,"participants":["Alex Bennee","Simon 'corecode' Schubert","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"50766","messageId":"1187178510.13096.46.camel@murta.transitives.com","threadId":"9533","inReplyTo":null,"subject":"git-cvsexportcommit getting out of sync with CVS status requests","fromName":"Alex Bennee","fromEmail":"kernel-hacker@bennee.com","sentAt":"2007-08-15T11:48:30Z","receivedAt":"2007-08-15T11:48:30Z","isPatch":false,"sender":{"key":"kernel-hacker@bennee.com","avatar":null},"body":"Hi,\n\nOccasionally (usually when a lot of files have been added or moved in my\ngit tree) git-cvsexportcommit gets confused when I'm exporting. I'll get\nthe error like:\n\nFile path/to/filea is already known in your CVS checkout.\n\nBut when manually querying:\n\n$ cvs status path/to/filea\n===================================================================\nFile: no file filea           Status: Unknown\n\n   Working revision:    No entry for filea\n   Repository revision: No revision control file\n\nIt's often combined with other errors like:\n\nFile path/to/fileb not up to date but has status 'Unknown' in your CVS\ncheckout!\n\nAgain manually querying:\n\n$ cvs status path/to/fileb\n===================================================================\nFile: fileb        Status: Up-to-date\n\n   Working revision:    1.2\n   Repository revision: 1.2     /path/to/cvs/path/to/fileb,v\n   Sticky Tag:          ATAG (branch: 1.2.98)\n   Sticky Date:         (none)\n   Sticky Options:      (none)\n\nI'm trying to pick out how the script queries cvs but I'm no perl expert\nand there seems to be complex pipe->array magics going on in there. It\ncertainly looks like it's got the cvs status for the wrong file\nassociated with it.\n\nI've made some hacks to the script and now I can see it does get into a\nfunny state:\n\nWe matched File: a.sh      Status: Up-to-date and store Up-to-date for\npath/to/a.sh\nWe matched File: b                Status: Up-to-date and store\nUp-to-date for path/to/c.sh\nWe matched File: no file c.sh         Status: Unknown and store Unknown\nfor path/to/d.sh\n\nPatches (not fixes, just instrumentation to see whats going on) attached\nfor people who are interested.\n\n-- \nAlex, homepage: http://www.bennee.com/~alex/\nMerchandise can be shipped only upon receipt of payment.\n\n\n\n--- git-cvsexportcommit.perl\t2007-08-15 12:10:03.000000000 +0100\n+++ git-cvsexportcommit\t2007-08-15 12:37:50.000000000 +0100\n@@ -1,4 +1,5 @@\n #!/usr/bin/perl -w\n+use lib (split(/:/, $ENV{GITPERLLIB} || \"/home/alexjb/share/perl/5.8.8\"));\n \n # Known limitations:\n # - does not propagate permissions\n@@ -173,6 +174,9 @@\n foreach my $f (@files) {\n     my $path = dirname $f;\n     next if (grep { $_ eq $path } @dirs);\n+\n+    $opt_v && print \"Adding $f to files to check status of\\n\";\n+    \n     push @canstatusfiles, $f;\n }\n \n@@ -185,12 +189,13 @@\n     my @cvsoutput;\n     @cvsoutput= safe_pipe_capture(@cvs, 'status', @canstatusfiles);\n     my $matchcount = 0;\n-    foreach my $l (@cvsoutput) {\n-        chomp $l;\n+    foreach my $cvsoutput (@cvsoutput) {\n+        chomp $cvsoutput;\n \n-\t$opt_v && print \"Processing $1\\n\";\n+#\t$opt_v && print \"Processing $cvsoutput\\n\";\n \n-        if ( $l =~ /^File:/ and  $l =~ /Status: (.*)$/ ) {\n+        if ( $cvsoutput =~ /^File:/ and  $cvsoutput =~ /Status: (.*)$/ ) {\n+\t    $opt_v && print \"We matched $cvsoutput and store $1 for $canstatusfiles[$matchcount]\\n\";\n             $cvsstat{$canstatusfiles[$matchcount]} = $1;\n             $matchcount++;\n         }\n@@ -201,9 +206,9 @@\n foreach my $f (@afiles) {\n     if (defined ($cvsstat{$f}) and $cvsstat{$f} ne \"Unknown\") {\n \t$dirty = 1;\n-\twarn \"File $f is already known in your CVS checkout.\\n\"\n-\twarn \"  Perhaps it has been added by another user.\\n\"\n-\twarn \"  Or this may indicate that it exists on a different branch.\\n\"\n+\twarn \"File $f is already known in your CVS checkout.\\n\";\n+\twarn \"  Perhaps it has been added by another user?\\n\";\n+\twarn \"  Or this may indicate that it exists on a different branch?\\n\";\n \twarn \"  If this is the case, use -f to force the merge.\\n\";\n \twarn \"Status was: $cvsstat{$f}\\n\";\n     }\n@@ -300,6 +305,7 @@\n # if the exec returns non-zero we die\n sub safe_pipe_capture {\n     my @output;\n+\n     if (my $pid = open my $child, '-|') {\n \t@output = (<$child>);\n \tclose $child or die join(' ',@_).\": $! $?\";\n"},{"id":"50774","messageId":"1187182726.13096.50.camel@murta.transitives.com","threadId":"9533","inReplyTo":"1187178510.13096.46.camel@murta.transitives.com","subject":"Re: git-cvsexportcommit getting out of sync with CVS status requests","fromName":"Alex Bennee","fromEmail":"alex.bennee@transitive.com","sentAt":"2007-08-15T12:58:46Z","receivedAt":"2007-08-15T12:58:46Z","isPatch":false,"sender":{"key":"alex.bennee@transitive.com","avatar":null},"body":"On Wed, 2007-08-15 at 12:48 +0100, Alex Bennee wrote:\n> Hi,\n> \n> Occasionally (usually when a lot of files have been added or moved in my\n> git tree) git-cvsexportcommit gets confused when I'm exporting. I'll get\n> the error like:\n\nSo I have figured out the reason it goes out of sync. CVS doesn't seem\nto always report status in the order you give it on the command line\n(which is rather crucial to the functioning of the script).\n\ne.g. cvs status path/to/filea path/to/filev path/to/filec can return the\nstatus in order \n\nfileb\nfilea\nfilec\n\nIt looks like running a single CVS query for each file is the only\nsolution.\n\n-- \nAlex Bennee - Alex.Bennee@transitive.com\nBehind every great computer sits a skinny little geek.\n"},{"id":"50785","messageId":"46C3218E.6020309@fs.ei.tum.de","threadId":"9533","inReplyTo":"1187182726.13096.50.camel@murta.transitives.com","subject":"Re: git-cvsexportcommit getting out of sync with CVS status requests","fromName":"Simon 'corecode' Schubert","fromEmail":"corecode@fs.ei.tum.de","sentAt":"2007-08-15T15:53:50Z","receivedAt":"2007-08-15T15:53:50Z","isPatch":false,"sender":{"key":"corecode@fs.ei.tum.de","avatar":"https://gravatar.com/avatar/eff9dbf0cdac0d1e6a6cd7ed0e50763edcb376b493b5253a35ff167918ad79e1?d=mp&s=160"},"body":"Alex Bennee wrote:\n> It looks like running a single CVS query for each file is the only\n> solution.\n\nI think internally CVS is doing single queries anyways.  At least that was my impression.\n\nOr we find out which order cvs is reporting the status.  Maybe a simple sort of the pathnames could be sufficient?\n\ncheers\n  simon\n"},{"id":"50787","messageId":"Pine.LNX.4.64.0708151810000.19496@wbgn129.biozentrum.uni-wuerzburg.de","threadId":"9533","inReplyTo":"46C3218E.6020309@fs.ei.tum.de","subject":"Re: git-cvsexportcommit getting out of sync with CVS status requests","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-08-15T16:11:04Z","receivedAt":"2007-08-15T16:11:04Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 15 Aug 2007, Simon 'corecode' Schubert wrote:\n\n> Alex Bennee wrote:\n> > It looks like running a single CVS query for each file is the only\n> > solution.\n> \n> I think internally CVS is doing single queries anyways.  At least that \n> was my impression.\n\nWhy then was cvsexportcommit so much slower without \nc56f0d9c661dc918a088e60d0ab69dd48019a9be?\n\nCiao,\nDscho\n"},{"id":"50792","messageId":"46C32B30.8040504@fs.ei.tum.de","threadId":"9533","inReplyTo":"Pine.LNX.4.64.0708151810000.19496@wbgn129.biozentrum.uni-wuerzburg.de","subject":"Re: git-cvsexportcommit getting out of sync with CVS status requests","fromName":"Simon 'corecode' Schubert","fromEmail":"corecode@fs.ei.tum.de","sentAt":"2007-08-15T16:34:56Z","receivedAt":"2007-08-15T16:34:56Z","isPatch":false,"sender":{"key":"corecode@fs.ei.tum.de","avatar":"https://gravatar.com/avatar/eff9dbf0cdac0d1e6a6cd7ed0e50763edcb376b493b5253a35ff167918ad79e1?d=mp&s=160"},"body":"Johannes Schindelin wrote:\n>> Alex Bennee wrote:\n>>> It looks like running a single CVS query for each file is the only\n>>> solution.\n>> I think internally CVS is doing single queries anyways.  At least that \n>> was my impression.\n> Why then was cvsexportcommit so much slower without \n> c56f0d9c661dc918a088e60d0ab69dd48019a9be?\n\nAh, my bad.  Didn't use such a recent cvsexportcommit.  So we need to mimic the cvs sorting.\n\ncheers\n  simon\n"}]}