Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Jan 2005 15:17:19 -0000
From:      "Chris Brown" <chris@thebrown.net>
To:        freebsd-cvsweb@freebsd.org
Subject:   Command line too long!
Message-ID:  <opskwp25aprf1x8w@mail.thebrown.net>

next in thread | raw e-mail | index | archive | help
------------GcJSO5lZsUx7DsSCl52kkW
Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15
Content-Transfer-Encoding: 8bit

Hi,

For a while now cvsweb has incorrectly displayed a particuar module in my  
CVS repository - quite a few of the files are missing from the log lists  
but can be accessed if the url to the file is typed directly into my  
browser, e.g., http://www/cgi-bin/cvsweb/cvsweb.cgi/opt/parmip.c. A Google  
search found other people with this symptom but I couldn't find any fix.

I have now realised that my module contains so many files (~570) that the  
command line to run rlog is longer than it (or the shell maybe) can  
handle. To get around this I wrote a patch to version 3.0.4 of cvsweb.cgi  
so it calls rlog incrementally with a configurable number of files at a  
time (at the moment set to 150). I hope this is useful to someone.

Chris Brown
------------GcJSO5lZsUx7DsSCl52kkW
Content-Disposition: attachment; filename=diff-cvsweb-inc_rlog.diff
Content-Type: application/octet-stream; name=diff-cvsweb-inc_rlog.diff
Content-Transfer-Encoding: 8bit

--- cvsweb.cgi	2005-01-20 12:53:08.000000000 +0000
+++ cvsweb-inc_rlog.cgi	2005-01-20 14:28:12.000000000 +0000
@@ -202,6 +202,7 @@
 sub startproc(@);
 sub runproc(@);
 sub checkout_to_temp($$$);
+sub get_rlog_incremental($$@);
 
 ##### Start of Configuration Area ########
 
@@ -2452,29 +2453,13 @@
   # If there are no files, we're done.
   return @unreadable unless @files;
 
-  my @cmd = ($CMD{rlog});
-  # Can't use -r<tag> as '-' is allowed in tagnames,
-  # but misinterpreted by rlog.
-  push(@cmd, '-r') unless defined($tag);
-
-  my $fh = do { local (*FH); };
-  if (!open($fh, '-|')) {                       # Child
-    open(STDERR, '>', devnull()) unless $DEBUG; # Ignore rlog's complaints.
-    openOutputFilter();
-    if ($file_list_len && $file_list_len > 1) {
-      while (scalar(@files) > $file_list_len) {  # Process files in chunks.
-        system(@cmd, splice(@files, 0, $file_list_len)) == 0 or exit -1;
-      }
-    }
-    exec(@cmd, @files) or exit -1;
-  }
-  undef @cmd;
+  my @rlog_lines = get_rlog_incremental (100, $tag, @files);
 
   my $state = 'start';
   my ($date, $branchpoint, $branch, $log, @filetags);
   my ($rev, $revision, $revwanted, $filename, $head, $author, $keywordsubst);
 
-  while (<$fh>) {
+  for (@rlog_lines) {
     if ($state eq "start") {
 
       #Next file. Initialize file variables
@@ -2609,15 +2594,6 @@
     }
   }
 
-  my $linesread = $. || 0;
-  close($fh);
-
-  if ($linesread == 0) {
-    fatal('500 Internal Error',
-          'Failed to spawn GNU rlog on <em>"%s"</em>.<br /><br />Did you set the <b><code>@command_path</code></b> in your configuration file correctly? (Currently: "<code>%s</code>")',
-          htmlquote(join(', ', @files)), join(':', @command_path));
-  }
-
   return @unreadable;
 }
 
@@ -4377,6 +4353,51 @@
   return ($exitcode, $errormsg);
 }
 
+
+sub get_rlog_incremental($$@)
+{
+  my $files_at_once = shift;
+  my $tag = shift;
+  my @all_files = @_;
+  my @rlog_lines;
+
+  my @cmd = ($CMD{rlog});
+  # Can't use -r<tag> as '-' is allowed in tagnames,
+  # but misinterpreted by rlog.
+  push(@cmd, '-r') unless defined($tag);
+
+  while( my @files = splice (@all_files, 0, $files_at_once)) {
+
+    my $fh = do { local (*FH); };
+    if (!open($fh, '-|')) {                       # Child
+      open(STDERR, '>', devnull()) unless $DEBUG; # Ignore rlog's complaints.
+      openOutputFilter();
+      if ($file_list_len && $file_list_len > 1) {
+        while (scalar(@files) > $file_list_len) {  # Process files in chunks.
+          system(@cmd, splice(@files, 0, $file_list_len)) == 0 or exit -1;
+        }
+      }
+      exec(@cmd, @files) or exit -1;
+    }
+
+    push @rlog_lines, <$fh>;
+
+    my $linesread = $. || 0;
+    close($fh);
+
+    if ($linesread == 0) {
+      fatal('500 Internal Error',
+            'Failed to spawn GNU rlog on <em>"%s"</em>.<br /><br />Did you set the <b><code>@command_path</code></b> in your configuration file correctly? (Currently: "<code>%s</code>")',
+            htmlquote(join(', ', @files)), join(':', @command_path));
+    }
+  }
+
+  return @rlog_lines;
+}
+
+
+
+
 #
 # Check out a file to a temporary file.
 #

------------GcJSO5lZsUx7DsSCl52kkW--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?opskwp25aprf1x8w>