1999-07-23 22:39:31 +04:00
|
|
|
#!/usr/bonsaitools/bin/perl -w
|
1998-06-17 01:43:24 +04:00
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
|
|
|
#
|
1999-11-02 02:33:56 +03:00
|
|
|
# The contents of this file are subject to the Netscape Public
|
|
|
|
# License Version 1.1 (the "License"); you may not use this file
|
|
|
|
# except in compliance with the License. You may obtain a copy of
|
|
|
|
# the License at http://www.mozilla.org/NPL/
|
1998-06-17 01:43:24 +04:00
|
|
|
#
|
1999-11-02 02:33:56 +03:00
|
|
|
# Software distributed under the License is distributed on an "AS
|
|
|
|
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
# implied. See the License for the specific language governing
|
|
|
|
# rights and limitations under the License.
|
1998-06-17 01:43:24 +04:00
|
|
|
#
|
|
|
|
# The Original Code is the Bonsai CVS tool.
|
|
|
|
#
|
|
|
|
# The Initial Developer of the Original Code is Netscape Communications
|
1999-11-02 02:33:56 +03:00
|
|
|
# Corporation. Portions created by Netscape are
|
|
|
|
# Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
# Rights Reserved.
|
|
|
|
#
|
|
|
|
# Contributor(s):
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
# Query the CVS database.
|
|
|
|
#
|
|
|
|
|
1999-10-19 02:55:01 +04:00
|
|
|
use strict;
|
|
|
|
|
1999-07-23 22:39:31 +04:00
|
|
|
require 'CGI.pl';
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-07-23 22:39:31 +04:00
|
|
|
$|=1;
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
print "Content-type: text/html\n\n";
|
|
|
|
|
2004-12-01 07:25:22 +03:00
|
|
|
&LoadTreeConfig();
|
1999-10-19 02:55:01 +04:00
|
|
|
$::CVS_ROOT = $::FORM{'cvsroot'};
|
2004-12-01 07:25:22 +03:00
|
|
|
$::CVS_ROOT = &pickDefaultRepository() unless $::CVS_ROOT;
|
2004-12-01 03:22:53 +03:00
|
|
|
&validateRepository($::CVS_ROOT);
|
|
|
|
|
2004-12-01 07:25:22 +03:00
|
|
|
my $Module = &SanitizeModule($::FORM{'module'}) || 'default';
|
|
|
|
|
|
|
|
if (exists($::TreeInfo{$Module}{'repository'})) {
|
|
|
|
$::TreeID = $Module;
|
1999-10-16 03:16:32 +04:00
|
|
|
}
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-10-19 02:55:01 +04:00
|
|
|
$::modules = {};
|
1999-07-27 20:25:08 +04:00
|
|
|
require 'modules.pl';
|
|
|
|
|
2004-12-01 07:25:22 +03:00
|
|
|
&PutsHeader("Bonsai - CVS Query Form", "CVS Query Form",
|
1999-10-19 02:55:01 +04:00
|
|
|
"$::CVS_ROOT - $::TreeInfo{$::TreeID}{shortdesc}");
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
print "
|
|
|
|
<p>
|
|
|
|
<FORM METHOD=GET ACTION='cvsquery.cgi'>
|
1999-07-23 22:39:31 +04:00
|
|
|
<INPUT TYPE=HIDDEN NAME=treeid VALUE=$::TreeID>
|
1998-06-17 01:43:24 +04:00
|
|
|
<p>
|
|
|
|
<TABLE BORDER CELLPADDING=8 CELLSPACING=0>
|
|
|
|
";
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# module selector
|
|
|
|
#
|
|
|
|
print "
|
|
|
|
<TR><TH ALIGN=RIGHT>Module:</TH>
|
|
|
|
<TD>
|
|
|
|
<SELECT name='module' size=5>
|
|
|
|
";
|
|
|
|
|
|
|
|
|
|
|
|
#
|
2001-07-13 21:45:52 +04:00
|
|
|
# check to see if there are multiple repositories
|
1998-06-17 01:43:24 +04:00
|
|
|
#
|
1999-10-19 02:55:01 +04:00
|
|
|
my @reposList = &getRepositoryList();
|
|
|
|
my $bMultiRepos = (@reposList > 1);
|
2004-12-01 07:25:22 +03:00
|
|
|
my %module_selection;
|
|
|
|
$module_selection{'all'} = $module_selection{'allrepos'} = "";
|
1998-06-17 01:43:24 +04:00
|
|
|
|
2004-12-01 07:25:22 +03:00
|
|
|
if ($::TreeID eq 'default' || $Module eq 'default' || $Module eq 'all') {
|
|
|
|
$module_selection{'all'} = "SELECTED";
|
|
|
|
} elsif( $Module eq 'allrepositories'){
|
|
|
|
$module_selection{'allrepos'} = "SELECTED";
|
|
|
|
} else {
|
|
|
|
$module_selection{'custom'} = "SELECTED";
|
1998-06-17 01:43:24 +04:00
|
|
|
}
|
2004-12-01 07:25:22 +03:00
|
|
|
|
|
|
|
print "<OPTION $module_selection{'all'} VALUE='all'>All Files in the Repository\n";
|
|
|
|
if( $bMultiRepos ){
|
|
|
|
print "<OPTION $module_selection{'allreps'} VALUE='allrepositories'>All Files in all Repositories\n";
|
1998-06-17 01:43:24 +04:00
|
|
|
}
|
2004-12-01 07:25:22 +03:00
|
|
|
|
|
|
|
if (defined($module_selection{'custom'})) {
|
|
|
|
my $escaped_module = &html_quote($Module);
|
2002-08-29 01:03:26 +04:00
|
|
|
print "<OPTION SELECTED VALUE='$escaped_module'>$escaped_module\n";
|
1998-06-17 01:43:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Print out all the Different Modules
|
|
|
|
#
|
|
|
|
|
2004-12-01 07:25:22 +03:00
|
|
|
if ($::TreeID eq "default") {
|
|
|
|
for my $k (sort( keys( %$::modules ) ) ){
|
|
|
|
print "<OPTION value='$k'>$k\n";
|
|
|
|
}
|
|
|
|
}
|
1999-07-27 20:25:08 +04:00
|
|
|
|
1998-06-17 01:43:24 +04:00
|
|
|
print "</SELECT></td>\n";
|
|
|
|
print "<td rowspan=2>";
|
|
|
|
cvsmenu();
|
|
|
|
print "</td></tr>";
|
|
|
|
|
|
|
|
#
|
|
|
|
# Branch
|
|
|
|
#
|
2004-12-01 07:25:22 +03:00
|
|
|
$b = &SanitizeRevision($::FORM{branch}) || "HEAD";
|
1998-06-17 01:43:24 +04:00
|
|
|
print "<tr>
|
|
|
|
<th align=right>Branch:</th>
|
|
|
|
<td> <input type=text name=branch value='$b' size=25><br>\n" .
|
|
|
|
regexpradio('branchtype') .
|
|
|
|
"<br>(leaving this field empty will show you checkins on both
|
|
|
|
<tt>HEAD</tt> and branches)
|
|
|
|
</td></tr>";
|
|
|
|
|
|
|
|
#
|
|
|
|
# Query by directory
|
|
|
|
#
|
1999-10-16 03:16:32 +04:00
|
|
|
|
|
|
|
$::FORM{dir} ||= "";
|
2004-12-01 07:25:22 +03:00
|
|
|
my $url_dir = &url_quote($::FORM{'dir'});
|
1999-10-16 03:16:32 +04:00
|
|
|
|
1998-06-17 01:43:24 +04:00
|
|
|
print "
|
|
|
|
<tr>
|
|
|
|
<th align=right>Directory:</th>
|
|
|
|
<td colspan=2>
|
2004-12-01 07:25:22 +03:00
|
|
|
<input type=text name=dir value='$url_dir' size=45><br>
|
1998-06-17 01:43:24 +04:00
|
|
|
(you can list multiple directories)
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
";
|
|
|
|
|
1999-10-16 03:16:32 +04:00
|
|
|
$::FORM{file} ||= "";
|
2004-12-01 07:25:22 +03:00
|
|
|
my $url_file = &url_quote($::FORM{'file'}) || "";
|
1999-10-16 03:16:32 +04:00
|
|
|
|
1998-06-17 01:43:24 +04:00
|
|
|
print "
|
|
|
|
<tr>
|
|
|
|
<th align=right>File:</th>
|
|
|
|
<td colspan=2>
|
2004-12-01 07:25:22 +03:00
|
|
|
<input type=text name=file value='$url_file' size=45><br>" .
|
1998-06-17 01:43:24 +04:00
|
|
|
regexpradio('filetype') . "
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
";
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Who
|
|
|
|
#
|
1999-10-16 03:16:32 +04:00
|
|
|
|
2004-12-01 07:25:22 +03:00
|
|
|
my $url_who = &url_quote(&SanitizeUsernames($::FORM{'who'}));
|
1999-10-16 03:16:32 +04:00
|
|
|
|
1998-06-17 01:43:24 +04:00
|
|
|
print "
|
|
|
|
<tr>
|
|
|
|
<th align=right>Who:</th>
|
2004-12-01 07:25:22 +03:00
|
|
|
<td colspan=2> <input type=text name=who value='$url_who' size=45><br>" .
|
1998-06-17 01:43:24 +04:00
|
|
|
regexpradio('whotype') . "
|
|
|
|
</td>
|
|
|
|
</tr>";
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Log contains
|
|
|
|
#
|
|
|
|
#print "
|
2002-09-26 01:55:22 +04:00
|
|
|
#<tr>
|
|
|
|
#<th align=right>Log contains:</th>
|
|
|
|
#<td colspan=2> <input type=text name=logexpr value='$::FORM{logexpr}' size=45><br>
|
|
|
|
#(you can use <a href=cvsregexp.html>regular expressions</a>)
|
|
|
|
#</td>
|
|
|
|
#</tr>
|
|
|
|
#";
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Sort order
|
|
|
|
#
|
|
|
|
print "
|
|
|
|
<tr>
|
|
|
|
<th align=right>Sort By:</th>
|
|
|
|
<td colspan=2>
|
|
|
|
<SELECT name='sortby'>
|
|
|
|
<OPTION" . &sortTest("Date") . ">Date
|
|
|
|
<OPTION" . &sortTest("Who") . ">Who
|
|
|
|
<OPTION" . &sortTest("File") . ">File
|
|
|
|
<OPTION" . &sortTest("Change Size") . ">Change Size
|
|
|
|
</SELECT>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
";
|
|
|
|
|
|
|
|
#
|
|
|
|
# Print the date selector
|
|
|
|
#
|
|
|
|
|
1999-10-19 02:55:01 +04:00
|
|
|
my $startdate = fetchCachedStartDate($::CVS_ROOT);
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-07-23 22:39:31 +04:00
|
|
|
if (!defined($::FORM{date}) || $::FORM{date} eq "") {
|
|
|
|
$::FORM{date} = "hours";
|
1998-06-17 01:43:24 +04:00
|
|
|
}
|
|
|
|
|
2004-12-01 07:25:22 +03:00
|
|
|
my $mindate = '';
|
|
|
|
my $maxdate = '';
|
|
|
|
$mindate = &ExpectDate($::FORM{'mindate'}) if ($::FORM{'mindate'});
|
|
|
|
$maxdate = &ExpectDate($::FORM{'maxdate'}) if ($::FORM{'maxdate'});
|
1999-07-23 22:39:31 +04:00
|
|
|
|
1998-06-17 01:43:24 +04:00
|
|
|
print "
|
|
|
|
<tr>
|
|
|
|
<th align=right valign=top><br>Date:</th>
|
|
|
|
<td colspan=2>
|
|
|
|
<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
|
|
|
|
<tr>
|
|
|
|
<td><input type=radio name=date " . &dateTest("hours") . "></td>
|
|
|
|
<td>In the last <input type=text name=hours value=2 size=4> hours</td>
|
|
|
|
</tr><tr>
|
|
|
|
<td><input type=radio name=date " . &dateTest("day") . "></td>
|
|
|
|
<td>In the last day</td>
|
|
|
|
</tr><tr>
|
|
|
|
<td><input type=radio name=date " . &dateTest("week") . "></td>
|
|
|
|
<td>In the last week</td>
|
|
|
|
</tr><tr>
|
|
|
|
<td><input type=radio name=date " . &dateTest("month") . "></td>
|
|
|
|
<td>In the last month</td>
|
|
|
|
</tr><tr>
|
|
|
|
<td><input type=radio name=date " . &dateTest("all") . "></td>
|
|
|
|
<td>Since the beginning of time (which happens to be <TT><NOBR>$startdate</NOBR></TT> currently)</td>
|
|
|
|
</tr><tr>
|
|
|
|
<td><input type=radio name=date " . &dateTest("explicit") . "></td>
|
|
|
|
<td><table BORDER=0 CELLPADDING=0 CELLPSPACING=0>
|
|
|
|
<tr>
|
|
|
|
<TD VALIGN=TOP ALIGN=RIGHT NOWRAP>
|
2004-12-01 07:25:22 +03:00
|
|
|
Between <input type=text name=mindate value='$mindate' size=25></td>
|
1998-06-17 01:43:24 +04:00
|
|
|
<td valign=top rowspan=2>You can use the form
|
2004-03-22 21:04:17 +03:00
|
|
|
<B><TT><NOBR>yyyy-mm-dd hh:mm:ss</NOBR></TT></B> or a Unix <TT>time_t</TT>
|
1998-06-17 01:43:24 +04:00
|
|
|
(seconds since the Epoch.)
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td VALIGN=TOP ALIGN=RIGHT NOWRAP>
|
2004-12-01 07:25:22 +03:00
|
|
|
and <input type=text name=maxdate value='$maxdate' size=25></td>
|
1998-06-17 01:43:24 +04:00
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</tr>
|
|
|
|
";
|
|
|
|
|
|
|
|
print "
|
|
|
|
<tr>
|
|
|
|
<th><BR></th>
|
|
|
|
<td colspan=2>
|
1999-10-19 02:55:01 +04:00
|
|
|
<INPUT TYPE=HIDDEN NAME=cvsroot VALUE='$::CVS_ROOT'>
|
1998-06-17 01:43:24 +04:00
|
|
|
<INPUT TYPE=SUBMIT VALUE='Run Query'>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</FORM>";
|
|
|
|
|
1999-07-23 22:39:31 +04:00
|
|
|
|
|
|
|
PutsTrailer();
|
|
|
|
|
1998-06-17 01:43:24 +04:00
|
|
|
sub sortTest {
|
1999-07-23 22:39:31 +04:00
|
|
|
return ""
|
|
|
|
unless (exists($::FORM{sortby}) && defined($_[0]) &&
|
2002-09-07 13:29:13 +04:00
|
|
|
($_[0] eq $::FORM{sortby}));
|
1999-07-23 22:39:31 +04:00
|
|
|
|
|
|
|
return " SELECTED";
|
1998-06-17 01:43:24 +04:00
|
|
|
}
|
|
|
|
|
1999-10-19 02:55:01 +04:00
|
|
|
refigureStartDateIfNecessary($::CVS_ROOT);
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
sub dateTest {
|
1999-07-23 22:39:31 +04:00
|
|
|
if( $_[0] eq $::FORM{date} ){
|
1998-06-17 01:43:24 +04:00
|
|
|
return " CHECKED value=$_[0]";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return "value=$_[0]";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub regexpradio {
|
1999-07-23 22:39:31 +04:00
|
|
|
my ($name) = @_;
|
|
|
|
my ($c1, $c2, $c3);
|
|
|
|
|
1998-10-09 02:01:36 +04:00
|
|
|
$c1 = $c2 = $c3 = "";
|
1999-10-16 03:16:32 +04:00
|
|
|
|
|
|
|
my $n = $::FORM{$name} || "";
|
|
|
|
|
|
|
|
if( $n eq 'regexp'){
|
1998-10-09 02:01:36 +04:00
|
|
|
$c2 = "checked";
|
|
|
|
}
|
1999-10-16 03:16:32 +04:00
|
|
|
elsif( $n eq 'notregexp'){
|
1998-10-09 02:01:36 +04:00
|
|
|
$c3 = "checked";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$c1 = "checked";
|
|
|
|
}
|
1998-06-17 01:43:24 +04:00
|
|
|
return "
|
|
|
|
<input type=radio name=$name value=match $c1>Exact match
|
|
|
|
|
1998-10-09 02:01:36 +04:00
|
|
|
<input type=radio name=$name value=regexp $c2><a href=cvsregexp.html>Regular expression</a>
|
|
|
|
|
|
|
|
<input type=radio name=$name value=notregexp $c3>Doesn't match <a href=cvsregexp.html>Reg Exp</a>";
|
1998-06-17 01:43:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 02:55:01 +04:00
|
|
|
my $rememberedcachedate;
|
|
|
|
|
1998-06-17 01:43:24 +04:00
|
|
|
sub fetchCachedStartDate {
|
|
|
|
my ($repository) = @_;
|
|
|
|
open(CACHE, "<data/cachedstartdates") || return "unknown";
|
|
|
|
while (<CACHE>) {
|
|
|
|
chop();
|
|
|
|
my($rep,$date,$cachedate) = split(/\|/);
|
|
|
|
if ($rep eq $repository) {
|
|
|
|
$rememberedcachedate = $cachedate;
|
|
|
|
return $date;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "unknown";
|
|
|
|
}
|
|
|
|
|
|
|
|
sub refigureStartDateIfNecessary {
|
|
|
|
my ($repository) = @_;
|
|
|
|
my $now = time();
|
|
|
|
if ((defined $rememberedcachedate) &&
|
|
|
|
$now - $rememberedcachedate < 24*60*60 &&
|
|
|
|
$rememberedcachedate < $now) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-12-01 11:28:06 +03:00
|
|
|
&ConnectToDatabase();
|
|
|
|
&SendSQL("SELECT MIN(ci_when)
|
|
|
|
FROM checkins,repositories
|
|
|
|
WHERE repositories.id = repositoryid and
|
|
|
|
repository = ?", $::CVS_ROOT);
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-07-23 22:39:31 +04:00
|
|
|
my $startdate = FetchOneColumn();
|
1998-06-17 01:43:24 +04:00
|
|
|
if ($startdate eq "") {
|
|
|
|
$startdate = "nonexistant";
|
|
|
|
}
|
|
|
|
open(OUTCACHE, ">data/cachedstartdates.$$") || die "Can't open output date cache file";
|
|
|
|
if (open(INCACHE, "<data/cachedstartdates")) {
|
|
|
|
while (<INCACHE>) {
|
|
|
|
chop();
|
|
|
|
my($rep,$date,$cachedate) = split(/\|/);
|
|
|
|
if ($rep ne $repository) {
|
|
|
|
print OUTCACHE "$_\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close INCACHE;
|
|
|
|
}
|
|
|
|
print OUTCACHE "$repository|$startdate|$now\n";
|
|
|
|
close OUTCACHE;
|
|
|
|
rename "data/cachedstartdates.$$", "data/cachedstartdates";
|
|
|
|
}
|