git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Optimized cvsexportcommit: calling 'cvs status' only once instead of once per changed file.
@ 2007-05-08 23:59 Steffen Prohaska
  2007-05-09  7:42 ` Steffen Prohaska
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Steffen Prohaska @ 2007-05-08 23:59 UTC (permalink / raw)
  To: git

The old implementation executed 'cvs status' for each file touched by  
the patch
to be applied. The new code calls 'cvs status' only once and parses  
cvs's
output to collect status information of all files contained in the  
cvs working
copy.

Runtime is now independent of the number of modified files. A  
drawback is that
the new code retrieves status information for all files even if only  
a few are
touched. The old implementation may be noticeably faster for small  
patches to
large workingcopies. However, the old implementation doesn't scale if  
more
files are touched, especially in remotely located cvs repositories.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
git-cvsexportcommit.perl |   45 ++++++++++++++++++++++++++++++++++ 
+----------
1 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl
index 6ed4719..f2c4bc4 100755
--- a/git-cvsexportcommit.perl
+++ b/git-cvsexportcommit.perl
@@ -160,36 +160,61 @@ foreach my $p (@afiles) {
      }
}
+# ... check dirs,
foreach my $d (@dirs) {
      if (-e $d) {
	$dirty = 1;
	warn "$d exists and is not a directory!\n";
      }
}
+# ... query and store status of files by parsing output of 'cvs  
status',
+my @cvsoutput;
+my %cvsstat;
+open CVSSTAT, "cvs status 2>&1 |" || die "failed to query cvs status";
+@cvsoutput=<CVSSTAT>;
+close CVSSTAT || die "failed to query cvs status";
+my ( $dir, $status, $file );
+foreach my $f (@cvsoutput) {
+# cvs reports directories on stderr before reporting file status on  
stdout
+# using basename of 'Repository revision:' should be a safe way to  
deal with whitespace in filenames.
+    chomp $f;
+    if ( $f =~ /^cvs status: Examining (.*)$/ ) {
+        $dir = $1;
+        if ( $dir ne "." ) {
+            $dir .= "/";
+        } else {
+            $dir = "";
+        }
+    } elsif ( $f =~ /Status: (.*)$/ ) {
+        $status = $1;
+    } elsif ( $f =~ /^   Repository revision:/ ) {
+        $f =~ s/,v$//;
+        $f =~ /([^\/]*)$/;
+        $file = $1;
+        $cvsstat{"$dir$file"} = $status;
+    }
+}
+
+# ... validate new files,
foreach my $f (@afiles) {
      # This should return only one value
      if ($f =~ m,(.*)/[^/]*$,) {
	my $p = $1;
	next if (grep { $_ eq $p } @dirs);
      }
-    my @status = grep(m/^File/,  safe_pipe_capture(@cvs, '-q',  
'status' ,$f));
-    if (@status > 1) { warn 'Strange! cvs status returned more than  
one line?'};
-    if (-d dirname $f and $status[0] !~ m/Status: Unknown$/
-	and $status[0] !~ m/^File: no file /) {
+    if (defined ($cvsstat{$f})) {
   	$dirty = 1;
	warn "File $f is already known in your CVS checkout -- perhaps it  
has been added by another user. Or this may indicate that it exists  
on a different branch. If this is the case, use -f to force the merge. 
\n";
-	warn "Status was: $status[0]\n";
+	warn "Status was: $cvsstat{$f}\n";
      }
}
-
+# ... validate known files.
foreach my $f (@files) {
      next if grep { $_ eq $f } @afiles;
      # TODO:we need to handle removed in cvs
-    my @status = grep(m/^File/,  safe_pipe_capture(@cvs, '-q',  
'status' ,$f));
-    if (@status > 1) { warn 'Strange! cvs status returned more than  
one line?'};
-    unless ($status[0] =~ m/Status: Up-to-date$/) {
+    unless (defined ($cvsstat{$f}) and $cvsstat{$f} eq "Up-to-date") {
	$dirty = 1;
-	warn "File $f not up to date in your CVS checkout!\n";
+	warn "File $f not up to date but has status '$cvsstat{$f}' in your  
CVS checkout!\n";
      }
}
if ($dirty) {
--
1.5.1.2

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2007-05-14  6:40 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-08 23:59 [PATCH] Optimized cvsexportcommit: calling 'cvs status' only once instead of once per changed file Steffen Prohaska
2007-05-09  7:42 ` Steffen Prohaska
2007-05-09  7:45   ` [PATCH (corrected)] " Steffen Prohaska
2007-05-09 11:04 ` [PATCH] " Johannes Schindelin
2007-05-09 11:43   ` Steffen Prohaska
2007-05-09 12:25     ` Johannes Schindelin
2007-05-09 13:00       ` Steffen Prohaska
2007-05-09 20:30 ` Robin Rosenberg
2007-05-09 22:45   ` Steffen Prohaska
2007-05-09 23:06     ` [PATCH] Optimized cvsexportcommit: calling 'cvs status' once instead of once per touched file Steffen Prohaska
2007-05-10  6:53     ` [PATCH] Optimized cvsexportcommit: calling 'cvs status' only once instead of once per changed file Martin Langhoff
2007-05-10  7:08       ` Junio C Hamano
2007-05-13 21:01         ` RFH for " Junio C Hamano
2007-05-13 21:51           ` Robin Rosenberg
2007-05-14  6:40             ` Martin Langhoff

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).