=================================================================== RCS file: /cvs/cvsweb/cvsweb.cgi,v retrieving revision 1.2 retrieving revision 1.8 diff -u -p -r1.2 -r1.8 --- cvsweb/cvsweb.cgi 1996/09/29 02:19:30 1.2 +++ cvsweb/cvsweb.cgi 1997/07/01 22:19:57 1.8 @@ -44,6 +44,10 @@ diffs between that revision and the previous one, and a form at the bottom of the page that allows you to display diffs between arbitrary revisions.

+If you would like to use this CGI script on your own web server and +CVS tree, see +the CVSWeb distribution site. +

Please send any suggestions, comments, etc. to Bill Fenner <fenner@freebsd.org> "; @@ -65,13 +69,18 @@ $scriptwhere =~ s|/$||; if (!-d $cvsroot) { &fatal("500 Internal Error",'$CVSROOT not found!'); } + +if ($q = $ENV{'QUERY_STRING'}) { + foreach (split(/&/, $q)) { + s/%(..)/sprintf("%c", hex($1))/ge; # unquote %-quoted + if (/(\S+)=(.*)/) { + $input{$1} = $2; + } else { + $input{$_}++; + } + } +} if (-d $fullname) { -# Something that would be nice to support, although I have no real -# good idea of how, would be to get full directory diff's, using -# symbolic names (revision numbers would be meaningless). -# The problem is finding a list of symbolic names that is common -# to all the files in the directory. -# opendir(DIR, $fullname) || &fatal("404 Not Found","$where: $!"); @dir = readdir(DIR); closedir(DIR); @@ -97,10 +106,13 @@ if (-d $fullname) { ($updir = $scriptwhere) =~ s|[^/]+$||; print " ", &link("Previous Directory",$updir), "
"; +# print " ", +# &link("Directory-wide diffs", $scriptwhere . '/*'), "
"; } elsif (-d $fullname . "/" . $_) { print " ", &link($_ . "/", $scriptwhere . '/' . $_ . '/'), "
"; } elsif (s/,v$//) { +# TODO: add date/time? How about sorting? print " ", &link($_, $scriptwhere . '/' . $_), "
"; } @@ -109,130 +121,22 @@ if (-d $fullname) { print &html_footer; print "\n"; } elsif (-f $fullname . ',v') { - if ($_ = $ENV{'QUERY_STRING'}) { - s/%(..)/sprintf("%c", hex($1))/ge; # unquote %-quoted - if (/rev=([\d\.]+)/) { - $rev = $1; - open(RCS, "co -p$rev '$fullname' 2>&1 |") || - &fail("500 Internal Error", "Couldn't co: $!"); -# /home/ncvs/src/sys/netinet/igmp.c,v --> standard output -# revision 1.1.1.2 -# /* - $_ = ; - if (/^$fullname,v\s+-->\s+standard output\s*$/o) { - # As expected - } else { - &fatal("500 Internal Error", - "Unexpected output from co: $_"); - } - $_ = ; - if (/^revision\s+$rev\s*$/) { - # As expected - } else { - &fatal("500 Internal Error", - "Unexpected output from co: $_"); - } - $| = 1; - print "Content-type: text/plain\n"; - print "Content-encoding: x-gzip\n\n"; - open(GZIP, "|gzip -1 -c"); # need lightweight compression - print GZIP ; - close(GZIP); - close(RCS); + if ($input{'rev'} =~ /^[\d\.]+$/) { + &checkout($fullname, $input{'rev'}); exit; - } - if (/r1=([^&:]+)(:([^&]+))?/) { - $rev1 = $1; - $sym1 = $3; - } - if ($rev1 eq 'text') { - if (/tr1=([^&]+)/) { - $rev1 = $1; - } - } - if (/r2=([^&:]+)(:([^&]+))?/) { - $rev2 = $1; - $sym2 = $3; - } - if ($rev2 eq 'text') { - if (/tr2=([^&]+)/) { - $rev2 = $1; - } - } - if (!($rev1 =~ /^[\d\.]+$/) || !($rev2 =~ /^[\d\.]+$/)) { - &fatal("404 Not Found", - "Malformed query \"$ENV{'QUERY_STRING'}\""); - } -# -# rev1 and rev2 are now both numeric revisions. -# Thus we do a DWIM here and swap them if rev1 is after rev2. -# XXX should we warn about the fact that we do this? - if (&revcmp($rev1,$rev2) > 0) { - ($tmp1, $tmp2) = ($rev1, $sym1); - ($rev1, $sym1) = ($rev2, $sym2); - ($rev2, $sym2) = ($tmp1, $tmp2); - } -# - $difftype = "-u"; - $diffname = "Unidiff"; - if (/f=([^&]+)/) { - if ($1 eq 'c') { - $difftype = '-c'; - $diffname = "Context diff"; - } - } -# XXX should this just be text/plain -# or should it have an HTML header and then a

-	    print "Content-type: text/plain\n\n";
-	    open(RCSDIFF, "rcsdiff $difftype -r$rev1 -r$rev2 '$fullname' 2>&1 |") ||
-		&fail("500 Internal Error", "Couldn't rcsdiff: $!");
-#
-#===================================================================
-#RCS file: /home/ncvs/src/sys/netinet/tcp_output.c,v
-#retrieving revision 1.16
-#retrieving revision 1.17
-#diff -c -r1.16 -r1.17
-#*** /home/ncvs/src/sys/netinet/tcp_output.c     1995/11/03 22:08:08     1.16
-#--- /home/ncvs/src/sys/netinet/tcp_output.c     1995/12/05 17:46:35     1.17
-#
-# Ideas:
-# - nuke the stderr output if it's what we expect it to be
-# - Add "no differences found" if the diff command supplied no output.
-#
-#*** src/sys/netinet/tcp_output.c     1995/11/03 22:08:08     1.16
-#--- src/sys/netinet/tcp_output.c     1995/12/05 17:46:35     1.17 RELENG_2_1_0
-# (bogus example, but...)
-#
-	    if ($difftype eq '-u') {
-		$f1 = '---';
-		$f2 = '\+\+\+';
-	    } else {
-		$f1 = '\*\*\*';
-		$f2 = '---';
-	    }
-	    while () {
-		if (m|^$f1 $cvsroot|o) {
-		    s|$cvsroot/||o;
-		    if ($sym1) {
-			chop;
-			$_ .= " " . $sym1 . "\n";
-		    }
-		} elsif (m|^$f2 $cvsroot|o) {
-		    s|$cvsroot/||o;
-		    if ($sym2) {
-			chop;
-			$_ .= " " . $sym2 . "\n";
-		    }
-		}
-		print $_;
-	    }
-	    close(RCSDIFF);
-	    exit;
 	}
+	if ($input{'r1'} && $input{'r2'}) {
+		&dodiff($fullname, $input{'r1'}, $input{'tr1'},
+			$input{'r2'}, $input{'tr2'}, $input{'f'});
+		exit;
+	}
 	open(RCS, "rlog '$fullname'|") || &fatal("500 Internal Error",
 						"Failed to spawn rlog");
 	while () {
 	    print if ($verbose);
+	    if (/^branch:\s+([\d\.]+)/) {
+		$curbranch = $1;
+	    }
 	    if ($symnames) {
 		if (/^\s+([^:]+):\s+([\d\.]+)/) {
 		    $symrev{$1} = $2;
@@ -249,6 +153,12 @@ if (-d $fullname) {
 		last;
 	    }
 	}
+
+	if ($onlyonbranch = $input{'only_on_branch'}) {
+	    ($onlyonbranch = $symrev{$onlyonbranch}) =~ s/\.0\././;
+	    ($onlybranchpoint = $onlyonbranch) =~ s/\.\d+$//;
+	}
+
 # each log entry is of the form:
 # ----------------------------
 # revision 3.7.1.1
@@ -296,12 +206,13 @@ if (-d $fullname) {
 	print "Done sorting revisions\n" if ($verbose);
 #
 # HEAD is an artificial tag which is simply the highest tag number on the main
-# branch (I think!).  Find it by looking through @revorder; it should at least
-# be near the beginning (In fact, it *should* be the first commit listed on
-# the main branch.)
+# branch, unless there is a branch tag in the RCS file in which case it's the
+# highest revision on that branch.  Find it by looking through @revorder; it
+# is the first commit listed on the appropriate branch.
+	$headrev = $curbranch || "1";
 	revision:
 	for ($i = 0; $i <= $#revorder; $i++) {
-	    if ($revorder[$i] =~ /^\d+\.\d+$/) {
+	    if ($revorder[$i] =~ /^(\S*)\.\d+$/ && $headrev eq $1) {
 		if ($revsym{$revorder[$i]}) {
 		    $revsym{$revorder[$i]} .= ", ";
 		}
@@ -321,6 +232,7 @@ if (-d $fullname) {
 	foreach (sort keys %symrev) {
 	    $rev = $symrev{$_};
 	    if ($rev =~ /^(\d+(\.\d+)+)\.0\.(\d+)$/) {
+		push(@branchnames, $_);
 		#
 		# A revision number of A.B.0.D really translates into
 		# "the highest current revision on branch A.B.D".
@@ -328,8 +240,6 @@ if (-d $fullname) {
 		# If there is no branch A.B.D, then it translates into
 		# the head A.B .
 		#
-		# This is pure speculation.
-		#
 		$head = $1;
 		$branch = $3;
 		$regex = $head . "." . $branch;
@@ -347,6 +257,10 @@ if (-d $fullname) {
 		}
 		$revsym{$rev} .= ", " if ($revsym{$rev});
 		$revsym{$rev} .= $_;
+		if ($rev ne $head) {
+		    $branchpoint{$head} .= ", " if ($branchpoint{$head});
+		    $branchpoint{$head} .= $_;
+		}
 	    }
 	    $sel .= "