Annotation of cvsweb/cvsweb.cgi, Revision 1.14
1.1 jfieber 1: #!/usr/bin/perl -s
2: #
3: # cvsweb - a CGI interface to the CVS tree.
4: #
5: # Written by Bill Fenner <fenner@parc.xerox.com> on his own time.
6: # Insert BSD copyright here.
7: #
8: #HTTP_USER_AGENT: Mozilla/1.1N (X11; I; SunOS 4.1.3_U1 sun4m) via proxy gateway CERN-HTTPD/3.0 libwww/2.17
9: #SERVER_NAME: www.freebsd.org
10: #QUERY_STRING: baz
11: #SCRIPT_FILENAME: /usr/local/www/cgi-bin/env.pl
12: #SERVER_PORT: 80
13: #HTTP_ACCEPT: */*, image/gif, image/x-xbitmap, image/jpeg
14: #SERVER_PROTOCOL: HTTP/1.0
15: #HTTP_COOKIE: s=beta26429821397802167
16: #PATH_INFO: /foo/bar
17: #REMOTE_ADDR: 13.1.64.94
18: #DOCUMENT_ROOT: /usr/local/www/data/
19: #PATH: /sbin:/bin:/usr/sbin:/usr/bin
20: #PATH_TRANSLATED: /usr/local/www/data//foo/bar
21: #GATEWAY_INTERFACE: CGI/1.1
22: #REQUEST_METHOD: GET
23: #SCRIPT_NAME: /cgi-bin/env.pl
24: #SERVER_SOFTWARE: Apache/1.0.0
25: #REMOTE_HOST: beta.xerox.com
26: #SERVER_ADMIN: webmaster@freebsd.org
27: #
28: require 'timelocal.pl';
29: require 'ctime.pl';
30:
1.2 jfieber 31: $hsty_base = "";
32: require 'cgi-style.pl';
1.11 wosch 33: #&get_the_source;
1.2 jfieber 34:
1.10 wosch 35: %CVSROOT = (
36: 'freebsd', '/home/ncvs',
37: 'openbsd', '/home/OpenBSD/cvs',
38: 'learn', '/c/learncvs',
39: );
40:
41: $cvstreedefault = 'freebsd';
42: $cvstree = $cvstreedefault;
43: $cvsroot = $CVSROOT{"$cvstree"} || "/home/ncvs";
44:
45:
1.1 jfieber 46: $intro = "
47: This is a WWW interface to the FreeBSD CVS tree.
48: You can browse the file hierarchy by picking directories
49: (which have slashes after them, e.g. <b>src/</b>).
50: If you pick a file, you will see the revision history
51: for that file.
52: Selecting a revision number will download that revision of
53: the file. There is a link at each revision to display
54: diffs between that revision and the previous one, and
55: a form at the bottom of the page that allows you to
56: display diffs between arbitrary revisions.
57: <p>
1.7 fenner 58: If you would like to use this CGI script on your own web server and
59: CVS tree, see <A HREF=\"http://www.freebsd.org/~fenner/cvsweb/\">
60: the CVSWeb distribution site</A>.
61: <p>
1.1 jfieber 62: Please send any suggestions, comments, etc. to
1.10 wosch 63: <A HREF=\"mailto:fenner\@freebsd.org\">Bill Fenner <fenner\@freebsd.org></A>
1.1 jfieber 64: ";
65: $shortinstr = "
66: Click on a directory to enter that directory. Click on a file to display
67: its revision history and to get a
68: chance to display diffs between revisions.
69: ";
70:
71: $verbose = $v;
72: ($where = $ENV{'PATH_INFO'}) =~ s|^/||;
73: $where =~ s|/$||;
74: ($scriptname = $ENV{'SCRIPT_NAME'}) =~ s|^/?|/|;
75: $scriptname =~ s|/$||;
76: $scriptwhere = $scriptname . '/' . $where;
77: $scriptwhere =~ s|/$||;
78:
1.9 fenner 79: if ($query = $ENV{'QUERY_STRING'}) {
80: foreach (split(/&/, $query)) {
1.7 fenner 81: s/%(..)/sprintf("%c", hex($1))/ge; # unquote %-quoted
82: if (/(\S+)=(.*)/) {
83: $input{$1} = $2;
84: } else {
85: $input{$_}++;
86: }
87: }
1.9 fenner 88: $query = "?" . $query;
1.7 fenner 89: }
1.10 wosch 90:
91:
1.11 wosch 92: $config = '/usr/local/etc/cvsweb';
93: do "$config" if -f $config;
1.10 wosch 94:
95: if ($input{'cvsroot'}) {
96: if ($CVSROOT{$input{'cvsroot'}}) {
97: $cvstree = $input{'cvsroot'};
98: $cvsroot = $CVSROOT{"$cvstree"};
99: }
100: }
1.11 wosch 101: do "$config-$cvstree" if -f "$config-$cvstree";
1.10 wosch 102:
103: $fullname = $cvsroot . '/' . $where;
1.12 fenner 104:
1.10 wosch 105: if (!-d $cvsroot) {
1.12 fenner 106: &fatal("500 Internal Error",'$CVSROOT not found!<P>The server on which the CVS tree lives is probably down. Please try again in a few minutes.');
1.10 wosch 107: }
108:
109:
1.1 jfieber 110: if (-d $fullname) {
111: opendir(DIR, $fullname) || &fatal("404 Not Found","$where: $!");
112: @dir = readdir(DIR);
113: closedir(DIR);
114: if ($where eq '') {
1.2 jfieber 115: print &html_header("FreeBSD CVS Repository");
1.1 jfieber 116: print $intro;
117: } else {
1.2 jfieber 118: print &html_header("/$where");
1.1 jfieber 119: print $shortinstr;
120: }
121: print "<p>Current directory: <b>/$where</b>\n";
1.2 jfieber 122: print "<P><HR NOSHADE>\n";
1.1 jfieber 123: # Using <MENU> in this manner violates the HTML2.0 spec but
124: # provides the results that I want in most browsers. Another
125: # case of layout spooging up HTML.
126: print "<MENU>\n";
1.9 fenner 127: lookingforattic:
128: for ($i = 0; $i <= $#dir; $i++) {
129: if ($dir[$i] eq "Attic") {
130: last lookingforattic;
131: }
132: }
1.12 fenner 133: $haveattic = 1 if ($i <= $#dir);
1.9 fenner 134: if (!$input{"showattic"} && ($i <= $#dir) &&
135: opendir(DIR, $fullname . "/Attic")) {
136: splice(@dir, $i, 1,
137: grep((s|^|Attic/|,!m|/\.|), readdir(DIR)));
138: closedir(DIR);
139: }
140: # Sort without the Attic/ pathname.
141: foreach (sort {($c=$a)=~s|.*/||;($d=$b)=~s|.*/||;($c cmp $d)} @dir) {
1.1 jfieber 142: if ($_ eq '.') {
143: next;
144: }
1.9 fenner 145: if (s|^Attic/||) {
146: $attic = " (in the Attic)";
147: } else {
148: $attic = "";
149: }
1.1 jfieber 150: if ($_ eq '..') {
151: next if ($where eq '');
152: ($updir = $scriptwhere) =~ s|[^/]+$||;
153: print "<IMG SRC=\"/icons/back.gif\"> ",
1.9 fenner 154: &link("Previous Directory",$updir . $query), "<BR>";
1.7 fenner 155: # print "<IMG SRC=???> ",
156: # &link("Directory-wide diffs", $scriptwhere . '/*'), "<BR>";
1.1 jfieber 157: } elsif (-d $fullname . "/" . $_) {
158: print "<IMG SRC=\"/icons/dir.gif\"> ",
1.12 fenner 159: &link($_ . "/", $scriptwhere . '/' . $_ . '/' . $query),
160: $attic, "<BR>";
1.1 jfieber 161: } elsif (s/,v$//) {
1.7 fenner 162: # TODO: add date/time? How about sorting?
1.1 jfieber 163: print "<IMG SRC=\"/icons/text.gif\"> ",
1.9 fenner 164: &link($_, $scriptwhere . '/' .
165: ($attic ? "Attic/" : "") . $_ . $query),
1.12 fenner 166: $attic, "<BR>";
1.1 jfieber 167: }
168: }
169: print "</MENU>\n";
1.9 fenner 170: if ($input{"only_on_branch"}) {
171: print "<HR><FORM METHOD=\"GET\" ACTION=\"${scriptwhere}\">\n";
172: print "Currently showing only branch $input{'only_on_branch'}.\n";
173: $input{"only_on_branch"}="";
174: foreach $k (keys %input) {
175: print "<INPUT TYPE=hidden NAME=$k VALUE=$input{$k}>\n" if $input{$k};
176: }
177: print "<INPUT TYPE=SUBMIT VALUE=\"Show all branches\">\n";
178: print "</FORM>\n";
179: }
180: $formwhere = $scriptwhere;
181: $formwhere =~ s|Attic/?$|| if ($input{"showattic"});
1.12 fenner 182: if ($haveattic) {
183: print "<HR><FORM METHOD=\"GET\" ACTION=\"${formwhere}\">\n";
184: $input{"showattic"}=!$input{"showattic"};
185: foreach $k (keys %input) {
186: print "<INPUT TYPE=hidden NAME=$k VALUE=$input{$k}>\n" if $input{$k};
187: }
188: print "<INPUT TYPE=SUBMIT VALUE=\"";
189: print ($input{"showattic"} ? "Show" : "Hide");
190: print " attic directories\">\n";
191: print "</FORM>\n";
192: }
1.2 jfieber 193: print &html_footer;
1.1 jfieber 194: print "</BODY></HTML>\n";
195: } elsif (-f $fullname . ',v') {
1.7 fenner 196: if ($input{'rev'} =~ /^[\d\.]+$/) {
197: &checkout($fullname, $input{'rev'});
198: exit;
199: }
200: if ($input{'r1'} && $input{'r2'}) {
201: &dodiff($fullname, $input{'r1'}, $input{'tr1'},
202: $input{'r2'}, $input{'tr2'}, $input{'f'});
1.1 jfieber 203: exit;
204: }
1.12 fenner 205: print("going to dolog($fullname)\n") if ($verbose);
206: &dolog($fullname);
207: } elsif ($fullname =~ s/\.diff$// && -f $fullname . ",v" &&
208: $input{'r1'} && $input{'r2'}) {
209: # Allow diffs using the ".diff" extension
210: # so that browsers that default to the URL
211: # for a save filename don't save diff's as
212: # e.g. foo.c
213: &dodiff($fullname, $input{'r1'}, $input{'tr1'},
214: $input{'r2'}, $input{'tr2'}, $input{'f'});
215: exit;
216: } elsif (($newname = $fullname) =~ s|/([^/]+)$|/Attic/$1| &&
217: -f $newname . ",v") {
218: # The file has been removed and is in the Attic.
219: # Send a redirect pointing to the file in the Attic.
220: ($newplace = $scriptwhere) =~ s|/([^/]+)$|/Attic/$1|;
221: &redirect($newplace);
222: exit;
223: } elsif (0 && (@files = &safeglob($fullname . ",v"))) {
224: print "Content-type: text/plain\n\n";
225: print "You matched the following files:\n";
226: print join("\n", @files);
227: # Find the tags from each file
228: # Display a form offering diffs between said tags
229: } else {
230: # Assume it's a module name with a potential path following it.
1.13 fenner 231: $xtra = $& if (($module = $where) =~ s|/.*||);
1.12 fenner 232: # Is there an indexed version of modules?
233: if (open(MODULES, "$cvsroot/CVSROOT/modules")) {
234: while (<MODULES>) {
235: if (/^(\S+)\s+(\S+)/o && $module eq $1
236: && -d "${cvsroot}/$2" && $module ne $2) {
237: &redirect($scriptname . '/' . $2 . $xtra);
238: }
239: }
240: }
241: &fatal("404 Not Found","$where: no such file or directory");
242: }
243:
244: sub htmlify {
245: local($string, $pr) = @_;
246:
247: $string =~ s/&/&/g;
248: $string =~ s/</</g;
249: $string =~ s/>/>/g;
250:
251: if ($pr) {
252: $string =~ s|\bpr(\W+[a-z]+/\W*)(\d+)|<A HREF=/cgi/query-pr.cgi?pr=$2>$&</A>|ig;
253: }
254:
255: $string;
256: }
257:
258: sub link {
259: local($name, $where) = @_;
260:
261: "<A HREF=\"$where\">$name</A>\n";
262: }
263:
264: sub revcmp {
265: local($rev1, $rev2) = @_;
266: local(@r1) = split(/\./, $rev1);
267: local(@r2) = split(/\./, $rev2);
268: local($a,$b);
269:
270: while (($a = shift(@r1)) && ($b = shift(@r2))) {
271: if ($a != $b) {
272: return $a <=> $b;
273: }
274: }
275: if (@r1) { return 1; }
276: if (@r2) { return -1; }
277: return 0;
278: }
279:
280: sub fatal {
281: local($errcode, $errmsg) = @_;
282: print "Status: $errcode\n";
283: print &html_header("Error");
284: # print "Content-type: text/html\n";
285: # print "\n";
286: # print "<HTML><HEAD><TITLE>Error</TITLE></HEAD>\n";
287: # print "<BODY>Error: $errmsg</BODY></HTML>\n";
288: print "Error: $errmsg\n";
289: print &html_footer;
290: exit(1);
291: }
292:
293: sub redirect {
294: local($url) = @_;
295: print "Status: 301 Moved\n";
296: print "Location: $url\n";
297: print &html_header("Moved");
298: # print "Content-type: text/html\n";
299: # print "\n";
300: # print "<HTML><HEAD><TITLE>Moved</TITLE></HEAD>\n";
301: # print "<BODY>This document is located <A HREF=$url>here</A>.</BODY></HTML>\n";
302: print "This document is located <A HREF=$url>here</A>.\n";
303: print &html_footer;
304: exit(1);
305: }
306:
307: sub safeglob {
308: local($filename) = @_;
309: local($dirname);
310: local(@results);
311:
312: ($dirname = $filename) =~ s|/[^/]+$||;
313: $filename =~ s|.*/||;
314:
315: if (opendir(DIR, $dirname)) {
316: $glob = $filename;
317: # transform filename from glob to regex. Deal with:
318: # [, {, ?, * as glob chars
319: # make sure to escape all other regex chars
320: $glob =~ s/([\.\(\)\|\+])/\\$1/g;
321: $glob =~ s/\*/.*/g;
322: $glob =~ s/\?/./g;
323: $glob =~ s/{([^}]+)}/($t = $1) =~ s-,-|-g; "($t)"/eg;
324: foreach (readdir(DIR)) {
325: if (/^${glob}$/) {
326: push(@results, $dirname . "/" .$_);
327: }
328: }
329: }
330:
331: @results;
332: }
333:
334: sub checkout {
335: local($fullname, $rev) = @_;
336:
337: open(RCS, "co -p$rev '$fullname' 2>&1 |") ||
338: &fail("500 Internal Error", "Couldn't co: $!");
339: # /home/ncvs/src/sys/netinet/igmp.c,v --> standard output
340: # or
341: # /home/ncvs/src/sys/netinet/igmp.c,v --> stdout
342: # revision 1.1.1.2
343: # /*
344: $_ = <RCS>;
345: if (/^(\S+),v\s+-->\s+st(andar)?d ?out(put)?\s*$/o && $1 eq $fullname) {
346: # As expected
347: } else {
348: &fatal("500 Internal Error",
349: "Unexpected output from co: $_");
350: }
351: $_ = <RCS>;
352: if (/^revision\s+$rev\s*$/) {
353: # As expected
354: } else {
355: &fatal("500 Internal Error",
356: "Unexpected output from co: $_");
357: }
358: $| = 1;
359: print "Content-type: text/plain\n\n";
360: print <RCS>;
361: close(RCS);
362: }
363:
364: sub dodiff {
365: local($fullname, $r1, $tr1, $r2, $tr2, $f) = @_;
366:
367: if ($r1 =~ /([^:]+)(:(.+))?/) {
368: $rev1 = $1;
369: $sym1 = $3;
370: }
371: if ($rev1 eq 'text') {
372: $rev1 = $tr1;
373: }
374: if ($r2 =~ /([^:]+)(:(.+))?/) {
375: $rev2 = $1;
376: $sym2 = $3;
377: }
378: if ($rev2 eq 'text') {
379: $rev2 = $tr2;
380: }
381: if (!($rev1 =~ /^[\d\.]+$/) || !($rev2 =~ /^[\d\.]+$/)) {
382: &fatal("404 Not Found",
383: "Malformed query \"$ENV{'QUERY_STRING'}\"");
384: }
385: #
386: # rev1 and rev2 are now both numeric revisions.
387: # Thus we do a DWIM here and swap them if rev1 is after rev2.
388: # XXX should we warn about the fact that we do this?
389: if (&revcmp($rev1,$rev2) > 0) {
390: ($tmp1, $tmp2) = ($rev1, $sym1);
391: ($rev1, $sym1) = ($rev2, $sym2);
392: ($rev2, $sym2) = ($tmp1, $tmp2);
393: }
394: #
395: # XXX Putting '-p' here is a personal preference
396: if ($f eq 'c') {
397: $difftype = '-p -c';
398: $diffname = "Context diff";
399: } elsif ($f eq 's') {
400: $difftype = '--side-by-side --width=164';
401: $diffname = "Side by Side";
402: } else {
403: $difftype = '-p -u';
404: $diffname = "Unidiff";
405: }
406: # XXX should this just be text/plain
407: # or should it have an HTML header and then a <pre>
408: print "Content-type: text/plain\n\n";
409: open(RCSDIFF, "rcsdiff $difftype -r$rev1 -r$rev2 '$fullname' 2>&1 |") ||
410: &fail("500 Internal Error", "Couldn't rcsdiff: $!");
411: #
412: #===================================================================
413: #RCS file: /home/ncvs/src/sys/netinet/tcp_output.c,v
414: #retrieving revision 1.16
415: #retrieving revision 1.17
416: #diff -c -r1.16 -r1.17
417: #*** /home/ncvs/src/sys/netinet/tcp_output.c 1995/11/03 22:08:08 1.16
418: #--- /home/ncvs/src/sys/netinet/tcp_output.c 1995/12/05 17:46:35 1.17
419: #
420: # Ideas:
421: # - nuke the stderr output if it's what we expect it to be
422: # - Add "no differences found" if the diff command supplied no output.
423: #
424: #*** src/sys/netinet/tcp_output.c 1995/11/03 22:08:08 1.16
425: #--- src/sys/netinet/tcp_output.c 1995/12/05 17:46:35 1.17 RELENG_2_1_0
426: # (bogus example, but...)
427: #
428: if ($difftype eq '-u') {
429: $f1 = '---';
430: $f2 = '\+\+\+';
431: } else {
432: $f1 = '\*\*\*';
433: $f2 = '---';
434: }
435: while (<RCSDIFF>) {
436: if (m|^$f1 $cvsroot|o) {
437: s|$cvsroot/||o;
438: if ($sym1) {
439: chop;
440: $_ .= " " . $sym1 . "\n";
441: }
442: } elsif (m|^$f2 $cvsroot|o) {
443: s|$cvsroot/||o;
444: if ($sym2) {
445: chop;
446: $_ .= " " . $sym2 . "\n";
447: }
448: }
449: print $_;
450: }
451: close(RCSDIFF);
452: }
453:
454: sub dolog {
455: local($fullname) = @_;
456: local($curbranch,$symnames); #...
457:
458: print("Going to rlog '$fullname'\n") if ($verbose);
1.1 jfieber 459: open(RCS, "rlog '$fullname'|") || &fatal("500 Internal Error",
460: "Failed to spawn rlog");
461: while (<RCS>) {
462: print if ($verbose);
1.8 fenner 463: if (/^branch:\s+([\d\.]+)/) {
464: $curbranch = $1;
465: }
1.1 jfieber 466: if ($symnames) {
467: if (/^\s+([^:]+):\s+([\d\.]+)/) {
468: $symrev{$1} = $2;
469: if ($revsym{$2}) {
470: $revsym{$2} .= ", ";
471: }
472: $revsym{$2} .= $1;
473: } else {
474: $symnames = 0;
475: }
476: } elsif (/^symbolic names/) {
477: $symnames = 1;
478: } elsif (/^-----/) {
479: last;
480: }
481: }
1.7 fenner 482:
483: if ($onlyonbranch = $input{'only_on_branch'}) {
484: ($onlyonbranch = $symrev{$onlyonbranch}) =~ s/\.0\././;
485: ($onlybranchpoint = $onlyonbranch) =~ s/\.\d+$//;
486: }
487:
1.1 jfieber 488: # each log entry is of the form:
489: # ----------------------------
490: # revision 3.7.1.1
491: # date: 1995/11/29 22:15:52; author: fenner; state: Exp; lines: +5 -3
492: # log info
493: # ----------------------------
494: logentry:
495: while (!/^=========/) {
496: $_ = <RCS>;
1.12 fenner 497: last logentry if (!defined($_)); # EOF
1.1 jfieber 498: print "R:", $_ if ($verbose);
499: if (/^revision ([\d\.]+)/) {
500: $rev = $1;
501: } elsif (/^========/ || /^----------------------------$/) {
502: next logentry;
503: } else {
1.12 fenner 504: # The rlog output is syntactically ambiguous. We must
505: # have guessed wrong about where the end of the last log
506: # message was.
507: # Since this is likely to happen when people put rlog output
508: # in their commit messages, don't even bother keeping
509: # these lines since we don't know what revision they go with
510: # any more.
511: next logentry;
512: # &fatal("500 Internal Error","Error parsing RCS output: $_");
1.1 jfieber 513: }
514: $_ = <RCS>;
515: print "D:", $_ if ($verbose);
1.9 fenner 516: if (m|^date:\s+(\d+)/(\d+)/(\d+)\s+(\d+):(\d+):(\d+);\s+author:\s+(\S+);\s+state:\s+(\S+);|) {
1.1 jfieber 517: $yr = $1;
518: # damn 2-digit year routines
519: if ($yr > 100) {
520: $yr -= 1900;
521: }
522: $date{$rev} = &timelocal($6,$5,$4,$3,$2 - 1,$yr);
523: $author{$rev} = $7;
1.9 fenner 524: $state{$rev} = $8;
1.1 jfieber 525: } else {
526: &fatal("500 Internal Error", "Error parsing RCS output: $_");
527: }
528: line:
529: while (<RCS>) {
530: print "L:", $_ if ($verbose);
531: next line if (/^branches:\s/);
532: last line if (/^----------------------------$/ || /^=========/);
533: $log{$rev} .= $_;
534: }
535: print "E:", $_ if ($verbose);
536: }
537: close(RCS);
538: print "Done reading RCS file\n" if ($verbose);
539: #
540: # Sort the revisions into commit-date order.
541: @revorder = sort {$date{$b} <=> $date{$a}} keys %date;
542: print "Done sorting revisions\n" if ($verbose);
543: #
544: # HEAD is an artificial tag which is simply the highest tag number on the main
1.8 fenner 545: # branch, unless there is a branch tag in the RCS file in which case it's the
546: # highest revision on that branch. Find it by looking through @revorder; it
547: # is the first commit listed on the appropriate branch.
548: $headrev = $curbranch || "1";
1.1 jfieber 549: revision:
550: for ($i = 0; $i <= $#revorder; $i++) {
1.8 fenner 551: if ($revorder[$i] =~ /^(\S*)\.\d+$/ && $headrev eq $1) {
1.1 jfieber 552: if ($revsym{$revorder[$i]}) {
553: $revsym{$revorder[$i]} .= ", ";
554: }
555: $revsym{$revorder[$i]} .= "HEAD";
556: $symrev{"HEAD"} = $revorder[$i];
557: last revision;
558: }
559: }
560: print "Done finding HEAD\n" if ($verbose);
561: #
562: # Now that we know all of the revision numbers, we can associate
563: # absolute revision numbers with all of the symbolic names, and
564: # pass them to the form so that the same association doesn't have
565: # to be built then.
566: #
567: # should make this a case-insensitive sort
568: foreach (sort keys %symrev) {
569: $rev = $symrev{$_};
570: if ($rev =~ /^(\d+(\.\d+)+)\.0\.(\d+)$/) {
1.7 fenner 571: push(@branchnames, $_);
1.1 jfieber 572: #
573: # A revision number of A.B.0.D really translates into
574: # "the highest current revision on branch A.B.D".
575: #
576: # If there is no branch A.B.D, then it translates into
577: # the head A.B .
578: #
579: $head = $1;
580: $branch = $3;
581: $regex = $head . "." . $branch;
582: $regex =~ s/\./\./g;
583: # <
584: # \____/
585: $rev = $head;
586:
587: revision:
588: foreach $r (@revorder) {
589: if ($r =~ /^${regex}/) {
590: $rev = $head . "." . $branch;
591: last revision;
592: }
593: }
594: $revsym{$rev} .= ", " if ($revsym{$rev});
595: $revsym{$rev} .= $_;
1.8 fenner 596: if ($rev ne $head) {
597: $branchpoint{$head} .= ", " if ($branchpoint{$head});
598: $branchpoint{$head} .= $_;
599: }
1.1 jfieber 600: }
601: $sel .= "<OPTION VALUE=\"${rev}:${_}\">$_\n";
602: }
603: print "Done associating revisions with branches\n" if ($verbose);
1.2 jfieber 604: print &html_header("CVS log for $where");
1.9 fenner 605: ($upwhere = $where) =~ s|(Attic/)?[^/]+$||;
606: print "Up to ", &link($upwhere,$scriptname . "/" . $upwhere . $query);
1.1 jfieber 607: print "<BR>\n";
608: print "<A HREF=\"#diff\">Request diff between arbitrary revisions</A>\n";
1.2 jfieber 609: print "<HR NOSHADE>\n";
1.8 fenner 610: if ($curbranch) {
611: print "Default branch is ";
612: print ($revsym{$curbranch} || $curbranch);
613: } else {
614: print "No default branch";
615: }
616: print "<BR><HR NOSHADE>\n";
1.1 jfieber 617: # The other possible U.I. I can see is to have each revision be hot
618: # and have the first one you click do ?r1=foo
619: # and since there's no r2 it keeps going & the next one you click
620: # adds ?r2=foo and performs the query.
621: # I suppose there's no reason we can't try both and see which one
622: # people prefer...
623:
624: for ($i = 0; $i <= $#revorder; $i++) {
625: $_ = $revorder[$i];
1.7 fenner 626: ($br = $_) =~ s/\.\d+$//;
627: next if ($onlyonbranch && $br ne $onlyonbranch &&
628: $_ ne $onlybranchpoint);
1.4 fenner 629: print "<a NAME=\"rev$_\"></a>";
630: foreach $sym (split(", ", $revsym{$_})) {
631: print "<a NAME=\"$sym\"></a>";
632: }
633: if ($revsym{$br} && !$nameprinted{$br}) {
634: foreach $sym (split(", ", $revsym{$br})) {
635: print "<a NAME=\"$sym\"></a>";
636: }
637: $nameprinted{$br}++;
638: }
639: print "\n";
1.10 wosch 640: print "<A HREF=\"$scriptwhere?rev=$_" .
1.12 fenner 641: &cvsroot . "\"><b>$_</b></A>";
1.1 jfieber 642: if (/^1\.1\.1\.\d+$/) {
643: print " <i>(vendor branch)</i>";
644: }
1.14 ! wosch 645: print " <i>" . &ctime($date{$_}) . " UTC</i> by ";
1.1 jfieber 646: print "<i>" . $author{$_} . "</i>\n";
647: if ($revsym{$_}) {
648: print "<BR>CVS Tags: <b>$revsym{$_}</b>";
649: }
1.4 fenner 650: if ($revsym{$br}) {
1.1 jfieber 651: if ($revsym{$_}) {
652: print "; ";
653: } else {
654: print "<BR>";
655: }
1.8 fenner 656: print "Branch: <b>$revsym{$br}</b>\n";
657: }
658: if ($branchpoint{$_}) {
659: if ($revsym{$br} || $revsym{$_}) {
660: print "; ";
661: } else {
662: print "<BR>";
663: }
664: print "Branch point for: <b>$branchpoint{$_}</b>\n";
1.1 jfieber 665: }
666: # Find the previous revision on this branch.
667: @prevrev = split(/\./, $_);
668: if (--$prevrev[$#prevrev] == 0) {
669: # If it was X.Y.Z.1, just make it X.Y
670: if ($#prevrev > 1) {
671: pop(@prevrev);
672: pop(@prevrev);
673: } else {
674: # It was rev 1.1 (XXX does CVS use revisions
675: # greater than 1.x?)
676: if ($prevrev[0] != 1) {
677: print "<i>* I can't figure out the previous revision! *</i>\n";
678: }
679: }
680: }
681: if ($prevrev[$#prevrev] != 0) {
682: $prev = join(".", @prevrev);
1.7 fenner 683: print "<BR><A HREF=\"${scriptwhere}.diff?r1=$prev";
1.12 fenner 684: print "&r2=$_" . &cvsroot . "\">Diffs to $prev</A>\n";
1.1 jfieber 685: #
686: # Plus, if it's on a branch, and it's not a vendor branch,
687: # offer to diff with the immediately-preceding commit if it
688: # is not the previous revision as calculated above
689: # and if it is on the HEAD (or at least on a higher branch)
690: # (e.g. change gets committed and then brought
691: # over to -stable)
692: if (!/^1\.1\.1\.\d+$/ && ($i != $#revorder) &&
693: ($prev ne $revorder[$i+1])) {
694: @tmp1 = split(/\./, $revorder[$i+1]);
695: @tmp2 = split(/\./, $_);
696: if ($#tmp1 < $#tmp2) {
1.7 fenner 697: print "; <A HREF=\"${scriptwhere}.diff?r1=$revorder[$i+1]";
1.10 wosch 698: print "&r2=$_" . &cvsroot .
1.12 fenner 699: "\">Diffs to $revorder[$i+1]</A>\n";
1.1 jfieber 700: }
701: }
702: }
1.9 fenner 703: if ($state{$_} eq "dead") {
704: print "<BR><B><I>FILE REMOVED</I></B>\n";
705: }
1.1 jfieber 706: print "<PRE>\n";
1.7 fenner 707: print &htmlify($log{$_}, 1);
1.2 jfieber 708: print "</PRE><HR NOSHADE>\n";
1.1 jfieber 709: }
710: print "<A NAME=diff>\n";
711: print "This form allows you to request diff's between any two\n";
712: print "revisions of a file. You may select a symbolic revision\n";
713: print "name using the selection box or you may type in a numeric\n";
714: print "name using the type-in text box.\n";
715: print "</A><P>\n";
1.7 fenner 716: print "<FORM METHOD=\"GET\" ACTION=\"${scriptwhere}.diff\">\n";
1.12 fenner 717: print "<INPUT TYPE=HIDDEN NAME=\"cvsroot\" VALUE=\"$cvstree\">\n"
1.10 wosch 718: if &cvsroot;
1.1 jfieber 719: print "Diffs between \n";
720: print "<SELECT NAME=\"r1\">\n";
721: print "<OPTION VALUE=\"text\" SELECTED>Use Text Field\n";
722: print $sel;
723: print "</SELECT>\n";
724: print "<INPUT TYPE=\"TEXT\" NAME=\"tr1\" VALUE=\"$revorder[$#revorder]\">\n";
725: print " and \n";
726: print "<SELECT NAME=\"r2\">\n";
727: print "<OPTION VALUE=\"text\" SELECTED>Use Text Field\n";
728: print $sel;
729: print "</SELECT>\n";
730: print "<INPUT TYPE=\"TEXT\" NAME=\"tr2\" VALUE=\"$revorder[0]\">\n";
731: print "<BR><INPUT TYPE=RADIO NAME=\"f\" VALUE=u CHECKED>Unidiff<br>\n";
732: print "<INPUT TYPE=RADIO NAME=\"f\" VALUE=c>Context diff<br>\n";
1.7 fenner 733: print "<INPUT TYPE=RADIO NAME=\"f\" VALUE=s>Side-by-Side<br>\n";
1.1 jfieber 734: print "<INPUT TYPE=SUBMIT VALUE=\"Get Diffs\">\n";
735: print "</FORM>\n";
1.7 fenner 736: print "<HR noshade>\n";
737: print "<A name=branch>\n";
738: print "You may select to see revision information from only\n";
739: print "a single branch.\n";
740: print "</A><P>\n";
741: print "<FORM METHOD=\"GET\" ACTION=\"$scriptwhere\">\n";
1.10 wosch 742: print qq{<input type=hidden name=cvsroot value=$cvstree>\n}
743: if &cvsroot;
1.7 fenner 744: print "Branch: \n";
745: print "<SELECT NAME=\"only_on_branch\">\n";
1.9 fenner 746: print "<OPTION VALUE=\"\"";
747: print " SELECTED" if ($input{"only_on_branch"} eq "");
748: print ">Show all branches\n";
1.7 fenner 749: foreach (sort @branchnames) {
1.9 fenner 750: print "<OPTION";
751: print " SELECTED" if ($input{"only_on_branch"} eq $_);
752: print ">${_}\n";
1.7 fenner 753: }
754: print "</SELECT>\n";
755: print "<INPUT TYPE=SUBMIT VALUE=\"View Branch\">\n";
756: print "</FORM>\n";
1.2 jfieber 757: print &html_footer;
1.1 jfieber 758: print "</BODY></HTML>\n";
1.10 wosch 759: }
760:
761: sub cvsroot {
762: return '' if $cvstree eq $cvstreedefault;
763: return "&cvsroot=" . $cvstree;
1.1 jfieber 764: }
CVSweb