=================================================================== RCS file: /cvs/cvsweb/cvsweb.cgi,v retrieving revision 1.1 retrieving revision 1.9 diff -u -p -r1.1 -r1.9 --- cvsweb/cvsweb.cgi 1996/09/28 23:31:06 1.1 +++ cvsweb/cvsweb.cgi 1997/07/19 00:54:40 1.9 @@ -28,6 +28,9 @@ require 'timelocal.pl'; require 'ctime.pl'; +$hsty_base = ""; +require 'cgi-style.pl'; + $cvsroot = '/home/ncvs'; $intro = " This is a WWW interface to the FreeBSD CVS tree. @@ -41,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> "; @@ -62,190 +69,116 @@ $scriptwhere =~ s|/$||; if (!-d $cvsroot) { &fatal("500 Internal Error",'$CVSROOT not found!'); } + +if ($query = $ENV{'QUERY_STRING'}) { + foreach (split(/&/, $query)) { + s/%(..)/sprintf("%c", hex($1))/ge; # unquote %-quoted + if (/(\S+)=(.*)/) { + $input{$1} = $2; + } else { + $input{$_}++; + } + } + $query = "?" . $query; +} 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); - print "Content-type: text/html\n\n"; - print "
Current directory: /$where\n"; - print "
- 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; @@ -262,6 +195,12 @@ print "
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 @@ -281,7 +220,7 @@ print "
} $_ =; print "D:", $_ if ($verbose); - if (m|^date:\s+(\d+)/(\d+)/(\d+)\s+(\d+):(\d+):(\d+);\s+author:\s+(\S+);|) { + if (m|^date:\s+(\d+)/(\d+)/(\d+)\s+(\d+):(\d+):(\d+);\s+author:\s+(\S+);\s+state:\s+(\S+);|) { $yr = $1; # damn 2-digit year routines if ($yr > 100) { @@ -289,6 +228,7 @@ print "
} $date{$rev} = &timelocal($6,$5,$4,$3,$2 - 1,$yr); $author{$rev} = $7; + $state{$rev} = $8; } else { &fatal("500 Internal Error", "Error parsing RCS output: $_"); } @@ -309,12 +249,13 @@ print "
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]} .= ", "; } @@ -334,6 +275,7 @@ print "
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". @@ -341,8 +283,6 @@ print "
# 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; @@ -360,19 +300,27 @@ print "
} $revsym{$rev} .= ", " if ($revsym{$rev}); $revsym{$rev} .= $_; + if ($rev ne $head) { + $branchpoint{$head} .= ", " if ($branchpoint{$head}); + $branchpoint{$head} .= $_; + } } $sel .= "
\n"; - print "
\n"; -print "\n"; + print "
\n"; + print &html_footer; print "\n"; +} elsif ($fullname =~ s/\.diff$// && -f $fullname . ",v" && + $input{'r1'} && $input{'r2'}) { + # Allow diffs using the ".diff" extension + # so that browsers that default to the URL + # for a save filename don't save diff's as + # e.g. foo.c + &dodiff($fullname, $input{'r1'}, $input{'tr1'}, + $input{'r2'}, $input{'tr2'}, $input{'f'}); + exit; +} elsif (($newname = $fullname) =~ s|/([^/]+)$|/Attic/$1| && + -f $newname . ",v") { + # The file has been removed and is in the Attic. + # Send a redirect pointing to the file in the Attic. + ($newplace = $scriptwhere) =~ s|/([^/]+)$|/Attic/$1|; + &redirect($newplace); + exit; +} elsif (0 && (@files = &safeglob($fullname . ",v"))) { + print "Content-type: text/plain\n\n"; + print "You matched the following files:\n"; + print join("\n", @files); + # Find the tags from each file + # Display a form offering diffs between said tags } else { + # Assume it's a module name with a potential path following it. + ($module = $where) =~ s|/.*||; + $xtra = $&; + # Is there an indexed version of modules? + if (open(MODULES, "$cvsroot/CVSROOT/modules")) { + while (+ 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); }