Add support for multiple cvs root directories. This allow
to use one script for different cvs trees, e.g. learn: cvsweb.cgi?cvsroot=learn freebsd: cvsweb.cgi?cvsroot=freebsd openbsd: cvsweb.cgi/src/bin/cat/cat.c?cvsroot=openbsd The default cvs root is `freebsd'.
This commit is contained in:
parent
195c0bb1a1
commit
c97e6997ab
Notes:
svn2git
2020-12-08 03:00:23 +00:00
svn path=/www/; revision=2166
2 changed files with 84 additions and 18 deletions
|
@ -31,7 +31,17 @@ require 'ctime.pl';
|
||||||
$hsty_base = "";
|
$hsty_base = "";
|
||||||
require 'cgi-style.pl';
|
require 'cgi-style.pl';
|
||||||
|
|
||||||
$cvsroot = '/home/ncvs';
|
%CVSROOT = (
|
||||||
|
'freebsd', '/home/ncvs',
|
||||||
|
'openbsd', '/home/OpenBSD/cvs',
|
||||||
|
'learn', '/c/learncvs',
|
||||||
|
);
|
||||||
|
|
||||||
|
$cvstreedefault = 'freebsd';
|
||||||
|
$cvstree = $cvstreedefault;
|
||||||
|
$cvsroot = $CVSROOT{"$cvstree"} || "/home/ncvs";
|
||||||
|
|
||||||
|
|
||||||
$intro = "
|
$intro = "
|
||||||
This is a WWW interface to the FreeBSD CVS tree.
|
This is a WWW interface to the FreeBSD CVS tree.
|
||||||
You can browse the file hierarchy by picking directories
|
You can browse the file hierarchy by picking directories
|
||||||
|
@ -49,7 +59,7 @@ CVS tree, see <A HREF=\"http://www.freebsd.org/~fenner/cvsweb/\">
|
||||||
the CVSWeb distribution site</A>.
|
the CVSWeb distribution site</A>.
|
||||||
<p>
|
<p>
|
||||||
Please send any suggestions, comments, etc. to
|
Please send any suggestions, comments, etc. to
|
||||||
<A HREF=\"mailto:fenner@freebsd.org\">Bill Fenner <fenner@freebsd.org></A>
|
<A HREF=\"mailto:fenner\@freebsd.org\">Bill Fenner <fenner\@freebsd.org></A>
|
||||||
";
|
";
|
||||||
$shortinstr = "
|
$shortinstr = "
|
||||||
Click on a directory to enter that directory. Click on a file to display
|
Click on a directory to enter that directory. Click on a file to display
|
||||||
|
@ -60,15 +70,11 @@ chance to display diffs between revisions.
|
||||||
$verbose = $v;
|
$verbose = $v;
|
||||||
($where = $ENV{'PATH_INFO'}) =~ s|^/||;
|
($where = $ENV{'PATH_INFO'}) =~ s|^/||;
|
||||||
$where =~ s|/$||;
|
$where =~ s|/$||;
|
||||||
$fullname = $cvsroot . '/' . $where;
|
|
||||||
($scriptname = $ENV{'SCRIPT_NAME'}) =~ s|^/?|/|;
|
($scriptname = $ENV{'SCRIPT_NAME'}) =~ s|^/?|/|;
|
||||||
$scriptname =~ s|/$||;
|
$scriptname =~ s|/$||;
|
||||||
$scriptwhere = $scriptname . '/' . $where;
|
$scriptwhere = $scriptname . '/' . $where;
|
||||||
$scriptwhere =~ s|/$||;
|
$scriptwhere =~ s|/$||;
|
||||||
|
|
||||||
if (!-d $cvsroot) {
|
|
||||||
&fatal("500 Internal Error",'$CVSROOT not found!');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($query = $ENV{'QUERY_STRING'}) {
|
if ($query = $ENV{'QUERY_STRING'}) {
|
||||||
foreach (split(/&/, $query)) {
|
foreach (split(/&/, $query)) {
|
||||||
|
@ -81,6 +87,22 @@ if ($query = $ENV{'QUERY_STRING'}) {
|
||||||
}
|
}
|
||||||
$query = "?" . $query;
|
$query = "?" . $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if ($input{'cvsroot'}) {
|
||||||
|
if ($CVSROOT{$input{'cvsroot'}}) {
|
||||||
|
$cvstree = $input{'cvsroot'};
|
||||||
|
$cvsroot = $CVSROOT{"$cvstree"};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$fullname = $cvsroot . '/' . $where;
|
||||||
|
if (!-d $cvsroot) {
|
||||||
|
&fatal("500 Internal Error",'$CVSROOT not found!');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (-d $fullname) {
|
if (-d $fullname) {
|
||||||
opendir(DIR, $fullname) || &fatal("404 Not Found","$where: $!");
|
opendir(DIR, $fullname) || &fatal("404 Not Found","$where: $!");
|
||||||
@dir = readdir(DIR);
|
@dir = readdir(DIR);
|
||||||
|
@ -344,7 +366,8 @@ if (-d $fullname) {
|
||||||
$nameprinted{$br}++;
|
$nameprinted{$br}++;
|
||||||
}
|
}
|
||||||
print "\n";
|
print "\n";
|
||||||
print "<A HREF=\"$scriptwhere?rev=$_\"><b>$_</b></A>";
|
print "<A HREF=\"$scriptwhere?rev=$_" .
|
||||||
|
&cvsroot . qq{"><b>$_</b></A>};
|
||||||
if (/^1\.1\.1\.\d+$/) {
|
if (/^1\.1\.1\.\d+$/) {
|
||||||
print " <i>(vendor branch)</i>";
|
print " <i>(vendor branch)</i>";
|
||||||
}
|
}
|
||||||
|
@ -387,7 +410,7 @@ if (-d $fullname) {
|
||||||
if ($prevrev[$#prevrev] != 0) {
|
if ($prevrev[$#prevrev] != 0) {
|
||||||
$prev = join(".", @prevrev);
|
$prev = join(".", @prevrev);
|
||||||
print "<BR><A HREF=\"${scriptwhere}.diff?r1=$prev";
|
print "<BR><A HREF=\"${scriptwhere}.diff?r1=$prev";
|
||||||
print "&r2=$_\">Diffs to $prev</A>\n";
|
print "&r2=$_" . &cvsroot . qq{">Diffs to $prev</A>\n};
|
||||||
#
|
#
|
||||||
# Plus, if it's on a branch, and it's not a vendor branch,
|
# Plus, if it's on a branch, and it's not a vendor branch,
|
||||||
# offer to diff with the immediately-preceding commit if it
|
# offer to diff with the immediately-preceding commit if it
|
||||||
|
@ -401,7 +424,8 @@ if (-d $fullname) {
|
||||||
@tmp2 = split(/\./, $_);
|
@tmp2 = split(/\./, $_);
|
||||||
if ($#tmp1 < $#tmp2) {
|
if ($#tmp1 < $#tmp2) {
|
||||||
print "; <A HREF=\"${scriptwhere}.diff?r1=$revorder[$i+1]";
|
print "; <A HREF=\"${scriptwhere}.diff?r1=$revorder[$i+1]";
|
||||||
print "&r2=$_\">Diffs to $revorder[$i+1]</A>\n";
|
print "&r2=$_" . &cvsroot .
|
||||||
|
qq{">Diffs to $revorder[$i+1]</A>\n};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -419,6 +443,8 @@ if (-d $fullname) {
|
||||||
print "name using the type-in text box.\n";
|
print "name using the type-in text box.\n";
|
||||||
print "</A><P>\n";
|
print "</A><P>\n";
|
||||||
print "<FORM METHOD=\"GET\" ACTION=\"${scriptwhere}.diff\">\n";
|
print "<FORM METHOD=\"GET\" ACTION=\"${scriptwhere}.diff\">\n";
|
||||||
|
print qq{<input type=hidden name=cvsroot value=$cvstree>\n}
|
||||||
|
if &cvsroot;
|
||||||
print "Diffs between \n";
|
print "Diffs between \n";
|
||||||
print "<SELECT NAME=\"r1\">\n";
|
print "<SELECT NAME=\"r1\">\n";
|
||||||
print "<OPTION VALUE=\"text\" SELECTED>Use Text Field\n";
|
print "<OPTION VALUE=\"text\" SELECTED>Use Text Field\n";
|
||||||
|
@ -442,6 +468,8 @@ if (-d $fullname) {
|
||||||
print "a single branch.\n";
|
print "a single branch.\n";
|
||||||
print "</A><P>\n";
|
print "</A><P>\n";
|
||||||
print "<FORM METHOD=\"GET\" ACTION=\"$scriptwhere\">\n";
|
print "<FORM METHOD=\"GET\" ACTION=\"$scriptwhere\">\n";
|
||||||
|
print qq{<input type=hidden name=cvsroot value=$cvstree>\n}
|
||||||
|
if &cvsroot;
|
||||||
print "Branch: \n";
|
print "Branch: \n";
|
||||||
print "<SELECT NAME=\"only_on_branch\">\n";
|
print "<SELECT NAME=\"only_on_branch\">\n";
|
||||||
print "<OPTION VALUE=\"\"";
|
print "<OPTION VALUE=\"\"";
|
||||||
|
@ -704,3 +732,8 @@ sub dodiff {
|
||||||
}
|
}
|
||||||
close(RCSDIFF);
|
close(RCSDIFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub cvsroot {
|
||||||
|
return '' if $cvstree eq $cvstreedefault;
|
||||||
|
return "&cvsroot=" . $cvstree;
|
||||||
|
}
|
||||||
|
|
|
@ -31,7 +31,17 @@ require 'ctime.pl';
|
||||||
$hsty_base = "";
|
$hsty_base = "";
|
||||||
require 'cgi-style.pl';
|
require 'cgi-style.pl';
|
||||||
|
|
||||||
$cvsroot = '/home/ncvs';
|
%CVSROOT = (
|
||||||
|
'freebsd', '/home/ncvs',
|
||||||
|
'openbsd', '/home/OpenBSD/cvs',
|
||||||
|
'learn', '/c/learncvs',
|
||||||
|
);
|
||||||
|
|
||||||
|
$cvstreedefault = 'freebsd';
|
||||||
|
$cvstree = $cvstreedefault;
|
||||||
|
$cvsroot = $CVSROOT{"$cvstree"} || "/home/ncvs";
|
||||||
|
|
||||||
|
|
||||||
$intro = "
|
$intro = "
|
||||||
This is a WWW interface to the FreeBSD CVS tree.
|
This is a WWW interface to the FreeBSD CVS tree.
|
||||||
You can browse the file hierarchy by picking directories
|
You can browse the file hierarchy by picking directories
|
||||||
|
@ -49,7 +59,7 @@ CVS tree, see <A HREF=\"http://www.freebsd.org/~fenner/cvsweb/\">
|
||||||
the CVSWeb distribution site</A>.
|
the CVSWeb distribution site</A>.
|
||||||
<p>
|
<p>
|
||||||
Please send any suggestions, comments, etc. to
|
Please send any suggestions, comments, etc. to
|
||||||
<A HREF=\"mailto:fenner@freebsd.org\">Bill Fenner <fenner@freebsd.org></A>
|
<A HREF=\"mailto:fenner\@freebsd.org\">Bill Fenner <fenner\@freebsd.org></A>
|
||||||
";
|
";
|
||||||
$shortinstr = "
|
$shortinstr = "
|
||||||
Click on a directory to enter that directory. Click on a file to display
|
Click on a directory to enter that directory. Click on a file to display
|
||||||
|
@ -60,15 +70,11 @@ chance to display diffs between revisions.
|
||||||
$verbose = $v;
|
$verbose = $v;
|
||||||
($where = $ENV{'PATH_INFO'}) =~ s|^/||;
|
($where = $ENV{'PATH_INFO'}) =~ s|^/||;
|
||||||
$where =~ s|/$||;
|
$where =~ s|/$||;
|
||||||
$fullname = $cvsroot . '/' . $where;
|
|
||||||
($scriptname = $ENV{'SCRIPT_NAME'}) =~ s|^/?|/|;
|
($scriptname = $ENV{'SCRIPT_NAME'}) =~ s|^/?|/|;
|
||||||
$scriptname =~ s|/$||;
|
$scriptname =~ s|/$||;
|
||||||
$scriptwhere = $scriptname . '/' . $where;
|
$scriptwhere = $scriptname . '/' . $where;
|
||||||
$scriptwhere =~ s|/$||;
|
$scriptwhere =~ s|/$||;
|
||||||
|
|
||||||
if (!-d $cvsroot) {
|
|
||||||
&fatal("500 Internal Error",'$CVSROOT not found!');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($query = $ENV{'QUERY_STRING'}) {
|
if ($query = $ENV{'QUERY_STRING'}) {
|
||||||
foreach (split(/&/, $query)) {
|
foreach (split(/&/, $query)) {
|
||||||
|
@ -81,6 +87,22 @@ if ($query = $ENV{'QUERY_STRING'}) {
|
||||||
}
|
}
|
||||||
$query = "?" . $query;
|
$query = "?" . $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if ($input{'cvsroot'}) {
|
||||||
|
if ($CVSROOT{$input{'cvsroot'}}) {
|
||||||
|
$cvstree = $input{'cvsroot'};
|
||||||
|
$cvsroot = $CVSROOT{"$cvstree"};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$fullname = $cvsroot . '/' . $where;
|
||||||
|
if (!-d $cvsroot) {
|
||||||
|
&fatal("500 Internal Error",'$CVSROOT not found!');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (-d $fullname) {
|
if (-d $fullname) {
|
||||||
opendir(DIR, $fullname) || &fatal("404 Not Found","$where: $!");
|
opendir(DIR, $fullname) || &fatal("404 Not Found","$where: $!");
|
||||||
@dir = readdir(DIR);
|
@dir = readdir(DIR);
|
||||||
|
@ -344,7 +366,8 @@ if (-d $fullname) {
|
||||||
$nameprinted{$br}++;
|
$nameprinted{$br}++;
|
||||||
}
|
}
|
||||||
print "\n";
|
print "\n";
|
||||||
print "<A HREF=\"$scriptwhere?rev=$_\"><b>$_</b></A>";
|
print "<A HREF=\"$scriptwhere?rev=$_" .
|
||||||
|
&cvsroot . qq{"><b>$_</b></A>};
|
||||||
if (/^1\.1\.1\.\d+$/) {
|
if (/^1\.1\.1\.\d+$/) {
|
||||||
print " <i>(vendor branch)</i>";
|
print " <i>(vendor branch)</i>";
|
||||||
}
|
}
|
||||||
|
@ -387,7 +410,7 @@ if (-d $fullname) {
|
||||||
if ($prevrev[$#prevrev] != 0) {
|
if ($prevrev[$#prevrev] != 0) {
|
||||||
$prev = join(".", @prevrev);
|
$prev = join(".", @prevrev);
|
||||||
print "<BR><A HREF=\"${scriptwhere}.diff?r1=$prev";
|
print "<BR><A HREF=\"${scriptwhere}.diff?r1=$prev";
|
||||||
print "&r2=$_\">Diffs to $prev</A>\n";
|
print "&r2=$_" . &cvsroot . qq{">Diffs to $prev</A>\n};
|
||||||
#
|
#
|
||||||
# Plus, if it's on a branch, and it's not a vendor branch,
|
# Plus, if it's on a branch, and it's not a vendor branch,
|
||||||
# offer to diff with the immediately-preceding commit if it
|
# offer to diff with the immediately-preceding commit if it
|
||||||
|
@ -401,7 +424,8 @@ if (-d $fullname) {
|
||||||
@tmp2 = split(/\./, $_);
|
@tmp2 = split(/\./, $_);
|
||||||
if ($#tmp1 < $#tmp2) {
|
if ($#tmp1 < $#tmp2) {
|
||||||
print "; <A HREF=\"${scriptwhere}.diff?r1=$revorder[$i+1]";
|
print "; <A HREF=\"${scriptwhere}.diff?r1=$revorder[$i+1]";
|
||||||
print "&r2=$_\">Diffs to $revorder[$i+1]</A>\n";
|
print "&r2=$_" . &cvsroot .
|
||||||
|
qq{">Diffs to $revorder[$i+1]</A>\n};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -419,6 +443,8 @@ if (-d $fullname) {
|
||||||
print "name using the type-in text box.\n";
|
print "name using the type-in text box.\n";
|
||||||
print "</A><P>\n";
|
print "</A><P>\n";
|
||||||
print "<FORM METHOD=\"GET\" ACTION=\"${scriptwhere}.diff\">\n";
|
print "<FORM METHOD=\"GET\" ACTION=\"${scriptwhere}.diff\">\n";
|
||||||
|
print qq{<input type=hidden name=cvsroot value=$cvstree>\n}
|
||||||
|
if &cvsroot;
|
||||||
print "Diffs between \n";
|
print "Diffs between \n";
|
||||||
print "<SELECT NAME=\"r1\">\n";
|
print "<SELECT NAME=\"r1\">\n";
|
||||||
print "<OPTION VALUE=\"text\" SELECTED>Use Text Field\n";
|
print "<OPTION VALUE=\"text\" SELECTED>Use Text Field\n";
|
||||||
|
@ -442,6 +468,8 @@ if (-d $fullname) {
|
||||||
print "a single branch.\n";
|
print "a single branch.\n";
|
||||||
print "</A><P>\n";
|
print "</A><P>\n";
|
||||||
print "<FORM METHOD=\"GET\" ACTION=\"$scriptwhere\">\n";
|
print "<FORM METHOD=\"GET\" ACTION=\"$scriptwhere\">\n";
|
||||||
|
print qq{<input type=hidden name=cvsroot value=$cvstree>\n}
|
||||||
|
if &cvsroot;
|
||||||
print "Branch: \n";
|
print "Branch: \n";
|
||||||
print "<SELECT NAME=\"only_on_branch\">\n";
|
print "<SELECT NAME=\"only_on_branch\">\n";
|
||||||
print "<OPTION VALUE=\"\"";
|
print "<OPTION VALUE=\"\"";
|
||||||
|
@ -704,3 +732,8 @@ sub dodiff {
|
||||||
}
|
}
|
||||||
close(RCSDIFF);
|
close(RCSDIFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub cvsroot {
|
||||||
|
return '' if $cvstree eq $cvstreedefault;
|
||||||
|
return "&cvsroot=" . $cvstree;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue