[Cvsnt] Cvsweb, annotate, and LockDir

Jeff Loomis jloomis at authentica.com
Thu Jul 25 12:06:40 BST 2002


Community technical support mailing list was retired 2010 and replaced with a professional technical support team. For assistance please contact: Pre-sales Technical support via email to sales@march-hare.com.


"Tony Hoyle" <tmh at nothing-on.tv> wrote in message
news:3d3806e8.1186991421 at news.cvsnt.org...

> CVSWeb probably needs modifying to use the rannotate command rather
> than trying to do it itself.  I did something like this once but
> unfortunately have lost that version.

I did this myself.  I also removed some code that prevented file download
off the mainline, and allowed for longer revision numbers without breaking
the annotation.  If you are using cvswebnt with a cvs that has LockDir
enbabled, it is not obeying those locks so you could be risking problems.

I found that viewcvs works fine for annotations and is probably nicer, but
is quite a bit slower.  It doesn't use CVS for annotations but instead
builds them itself using rlog.

For those interested in cvswebnt, here are diffs from the version at:
http://198.142.100.140/cvswebnt/cvsweb.cgi/

--- cvsweb.cgi Thu Dec  6 15:14:00 2001
+++ newcvsweb.cgi Wed Jul 24 15:17:23 2002
@@ -70,7 +70,7 @@
     $navigationHeaderColor $tableBorderColor $markupLogColor
     $tabstop $state $annTable $sel $curbranch @HideModules
     $module $use_descriptions %descriptions @mytz $dwhere $moddate
-    $use_moddate $annotate_file
+    $use_moddate $annotate_file %REMOTEROOT
 );

 ##### Start of Configuration Area ########
@@ -88,7 +88,7 @@
 ######## Configuration variables #########
 # These are defined to allow checking with perl -cw
 %CVSROOT = %MIRRORS = %DEFAULTVALUE = %ICONS = %MTYPES =
-%tags = %alltags = @tabcolors = ();
+%tags = %alltags = @tabcolors = %REMOTEROOT = ();
 $cvstreedefault = $body_tag = $logo = $defaulttitle = $address =
 $backcolor = $long_intro = $short_instruction = $shortLogLen =
 $show_author = $dirtable = $tablepadding = $columnHeaderColorDefault =
@@ -1038,75 +1038,13 @@
     # this seems to be necessary
     $| = 1; $| = 0; # Flush

-    # this annotate version is based on the
-    # cvs annotate-demo Perl script by Cyclic Software
-    # It was written by Cyclic Software, http://www.cyclic.com/, and is in

-    # the public domain.
-    # we could abandon the use of rlog, rcsdiff and co using
-    # the cvsserver in a similiar way one day (..after rewrite)
-    # $pid = open2($reader, $writer, "cvs server") || fatal ("500 Internal
Error",
-    #               "Fatal Error - unable to open cvs for annotation");
-    open ($writer, ">".$annotate_file) || fatal ("500 Internal Error",
-              "Fatal Error - unable to open cvs temp file for annotation -
$!");
-
-    binmode($writer);
-    # OK, first send the request to the server.  A simplified example is:
-    #     Root /home/kingdon/zwork/cvsroot
-    #     Argument foo/xx
-    #     Directory foo
-    #     /home/kingdon/zwork/cvsroot/foo
-    #     Directory .
-    #     /home/kingdon/zwork/cvsroot
-    #     annotate
-    # although as you can see there are a few more details.
-
-    print $writer "Root $cvsroot\n";
-    print $writer "Valid-responses ok error Valid-requests Checked-in
Updated Merged Removed M E\n";
-    # Don't worry about sending valid-requests, the server just needs to
-    # support "annotate" and if it doesn't, there isn't anything to be
done.
-    print $writer "UseUnchanged\n";
-    print $writer "Argument -r\n";
-    print $writer "Argument $rev\n";
-    print $writer "Argument $where\n";
-
-    # The protocol requires us to fully fake a working directory (at
-    # least to the point of including the directories down to the one
-    # containing the file in question).
-    # So if $where is "dir/sdir/file", then @dirs will be
("dir","sdir","file")
-    my @dirs = split (/\//, $where);
-    my $path = "";
-    foreach (@dirs) {
- if ($path eq "") {
-     # In our example, $_ is "dir".
-     $path = $_;
- }
- else {
-     print $writer "Directory " . $path . "\n";
-     print $writer "$cvsroot/" . $path ."\n";
-     # In our example, $_ is "sdir" and $path becomes "dir/sdir"
-     # And the next time, "file" and "dir/sdir/file" (which then gets
-     # ignored, because we don't need to send Directory for the file).
-            $path = $path . "/" . $_;
- }
-    }
-    # And the last "Directory" before "annotate" is the top level.
-    print $writer "Directory .\n";
-    print $writer "$cvsroot\n";
-
-    print $writer "annotate\n";
-    # OK, we've sent our command to the server.  Thing to do is to
-    # close the writer side and get all the responses.  If "cvs server"
-    # were nicer about buffering, then we could just leave it open, I
think.
-    close ($writer) || die "cannot close: $!";
-    $pid = open($reader,  "type \"$annotate_file\" | cvs server 2>&1 |" )
|| fatal ("500 Internal Error",
-              "Fatal Error - unable to open cvs for annotation - currently
under repair");
-
+    $pid = open($reader,  "cvs -d$REMOTEROOT{$cvsroot} rannotate -r$rev
$where 2>&1 |" ) || fatal ("500 Internal Error",
+              "Fatal Error - unable to execute cvs rannotate");
     # Ready to get the responses from the server.
     # For example:
-    #     E Annotations for foo/xx
-    #     E ***************
-    #     M 1.3          (kingdon  06-Sep-97): hello
-    #     ok
+    #     Annotations for foo/xx
+    #     ***************
+    #     1.3          (kingdon  06-Sep-97): hello
     my ($lineNr) = 0;
     my ($oldLrev, $oldLusr) = ("", "");
     my ($revprint, $usrprint);
@@ -1117,48 +1055,37 @@
  print "<pre>";
     }
     while (<$reader>) {
- my @words = split;
- # Adding one is for the (single) space which follows $words[0].
- my $rest = substr ($_, length ($words[0]) + 1);
- if ($words[0] eq "E") {
+        if(/^Annotations/ || /^\*+$/) {
      next;
  }
- elsif ($words[0] eq "M") {
+ elsif (/^([0-9.]+)\s+\((\S+)\s+..-...-...:(.*\n)/) {
      $lineNr++;
-     my $lrev = substr ($_, 2, 13);
-     my $lusr = substr ($_, 16,  9);
-     my $line = substr ($_, 36);
+            my $lrev = $1;
+            my $lusr = $2;
+            my $line = $3;
+
      # we should parse the date here ..
      if ($lrev eq $oldLrev) {
-  $revprint = "             ";
+  $revprint = "";
      }
      else {
   $revprint = $lrev; $oldLusr = "";
      }
      if ($lusr eq $oldLusr) {
-  $usrprint = "         ";
+  $usrprint = "";
      }
      else {
   $usrprint = $lusr;
      }
      $oldLrev = $lrev;
      $oldLusr = $lusr;
-     # is there a less timeconsuming way to strip spaces ?
-     ($lrev = $lrev) =~ s/\s+//g;
      my $isCurrentRev = ("$rev" eq "$lrev");

      print "<b>" if ($isCurrentRev);
-     printf ("%8s%s%8s %4d:", $revprint, ($isCurrentRev ? "|" : " "),
$usrprint, $lineNr);
+     printf ("%-13s%s%-9s%5d:", $revprint, ($isCurrentRev ? "|" : " "),
$usrprint, $lineNr);
      print spacedHtmlText($line);
      print "</b>" if ($isCurrentRev);
  }
- elsif ($words[0] eq "ok") {
-     # We could complain about any text received after this, like the
-     # CVS command line client.  But for simplicity, we don't.
- }
- elsif ($words[0] eq "error") {
-     fatal ("500 Internal Error", "Error occured during annotate:
<b>$_</b>");
- }
     }
     if ($annTable) {
  print "</table>";
@@ -1267,9 +1194,8 @@

 sub cvswebMarkup {
     my ($filehandle,$fullname,$revision) = @_;
-    my ($pathname, $filename, $revnum);
+    my ($pathname, $filename);

-    $revnum = $revision * 1; # force numeric
     ($pathname = $where) =~ s/(Attic\/)?[^\/]*$//;
     ($filename = $where) =~ s/^.*\///;
     my ($fileurl) = urlencode($filename);
@@ -1290,7 +1216,7 @@
     print "<BR>\n";
     if ($show_log_in_markup) {
  readLog($fullname); #,$revision);
- printLog($revnum,0);
+ printLog($revision,0);
     }
     else {
  print "Version: <B>$revision</B><BR>\n";
@@ -2366,18 +2292,17 @@

 sub navigateHeader ($$$$$) {
     my ($swhere,$path,$filename,$rev,$title) = @_;
-    my $revnum = $rev *1; # force numeric
     $swhere = "" if ($swhere eq $scriptwhere);
     $swhere = urlencode($filename) if ($swhere eq "");
     print "<\!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"
>";
     print "<HTML>\n<HEAD>\n";
     print '<!-- march-hare.com CVSwebNT $Revision: 1.93.2.2 $ -->';
-    print "\n<TITLE>$path$filename - $title - $revnum</TITLE></HEAD>\n";
+    print "\n<TITLE>$path$filename - $title - $rev</TITLE></HEAD>\n";
     print  "<BODY BGCOLOR=\"$backcolor\">\n";
     print "<table width=\"100%\" border=0 cellspacing=0 cellpadding=1
bgcolor=\"$navigationHeaderColor\">";
     print "<tr valign=bottom><td>";
-    print  "<a href=\"$swhere$query#rev$revnum\">$backicon";
-    print "</a> <b>Return to ",
&link("$filename","$swhere$query#rev$revnum")," CVS log";
+    print  "<a href=\"$swhere$query#rev$rev\">$backicon";
+    print "</a> <b>Return to ",
&link("$filename","$swhere$query#rev$rev")," CVS log";
     print "</b> $fileicon</td>";

     print "<td align=right>$diricon <b>Up to ". &clickablePath($path, 1).
"</b></td>";
@@ -2574,9 +2499,6 @@
 # make A url for downloading
 sub download_url {
     my ($url,$revision,$mimetype) = @_;
-    my $revnum = $revision *1; #force numeric
-
-    $revision =~ s/\b0\.//;

     if (defined($checkout_magic)
  && (!defined($mimetype) || $mimetype ne "text/x-cvsweb-markup")) {
@@ -2584,7 +2506,7 @@
  ($path = $where) =~ s|/[^/]*$|/|;
  $url = "$scriptname/$checkoutMagic/${path}$url";
     }
-    $url .= "?rev=$revnum";
+    $url .= "?rev=$revision";
     $url .= "&amp;content-type=$mimetype" if (defined($mimetype));

     return $url;
--- cvsweb.conf Wed Jul 24 15:26:48 2002
+++ newcvsweb.conf Wed Jul 24 15:28:05 2002
@@ -27,6 +27,14 @@
     'Configuration' => 'c:/cvsroot_config'
 );

+# This indicates a CVSROOT value used to connect to each
+# repository for annotations.  SSPI works well if you are using
+# windows authentication on your web server.  For other auth
+# types you will need to establish an appropriate .cvspass.
+%REMOTEROOT = (
+    'c:/cvs' => ':sspi:cvsweb_server:c:\\cvs'
+);
+
 # This tree is enabled by default when
 # you enter the page
 # $cvstreedefault = 'Configuration';



_______________________________________________
Cvsnt mailing list
Cvsnt at cvsnt.org
http://www.cvsnt.org/cgi-bin/mailman/listinfo/cvsnt https://www.march-hare.com/cvspro/en.asp#downcvs



More information about the cvsnt mailing list
Download the latest CVSNT, TortosieCVS, WinCVS etc. for Windows 8 etc.
@CVSNT on Twitter   CVSNT on Facebook