#!/usr/bonsaitools/bin/perl -w # -*- Mode: perl; indent-tabs-mode: nil -*- # # 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/ # # 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. # # The Original Code is the Bonsai CVS tool. # # The Initial Developer of the Original Code is Netscape Communications # Corporation. Portions created by Netscape are # Copyright (C) 1998 Netscape Communications Corporation. All # Rights Reserved. # # Contributor(s): # Query the CVS database. # use strict; require 'CGI.pl'; $|=1; print "Content-type: text/html\n\n"; &LoadTreeConfig(); $::CVS_ROOT = $::FORM{'cvsroot'}; $::CVS_ROOT = &pickDefaultRepository() unless $::CVS_ROOT; &validateRepository($::CVS_ROOT); my $Module = &SanitizeModule($::FORM{'module'}) || 'default'; if (exists($::TreeInfo{$Module}{'repository'})) { $::TreeID = $Module; } $::modules = {}; require 'modules.pl'; &PutsHeader("Bonsai - CVS Query Form", "CVS Query Form", "$::CVS_ROOT - $::TreeInfo{$::TreeID}{shortdesc}"); print "

"; # # module selector # print " \n"; print ""; # # Branch # $b = &SanitizeRevision($::FORM{branch}) || "HEAD"; print ""; # # Query by directory # $::FORM{dir} ||= ""; my $url_dir = &url_quote($::FORM{'dir'}); print " "; $::FORM{file} ||= ""; my $url_file = &url_quote($::FORM{'file'}) || ""; print " "; # # Who # my $url_who = &url_quote(&SanitizeUsernames($::FORM{'who'})); print " "; # # Log contains # #print " # # # # #"; # # Sort order # print " "; # # Print the date selector # my $startdate = fetchCachedStartDate($::CVS_ROOT); if (!defined($::FORM{date}) || $::FORM{date} eq "") { $::FORM{date} = "hours"; } my $mindate = ''; my $maxdate = ''; $mindate = &ExpectDate($::FORM{'mindate'}) if ($::FORM{'mindate'}); $maxdate = &ExpectDate($::FORM{'maxdate'}) if ($::FORM{'maxdate'}); print " "; print "
Module: "; cvsmenu(); print "
Branch:
\n" . regexpradio('branchtype') . "
(leaving this field empty will show you checkins on both HEAD and branches)
Directory:
(you can list multiple directories)
File:
" . regexpradio('filetype') . "
Who:
" . regexpradio('whotype') . "
Log contains:
#(you can use regular expressions) #
Sort By:

Date:
In the last hours
In the last day
In the last week
In the last month
Since the beginning of time (which happens to be $startdate currently)
Between You can use the form yyyy-mm-dd hh:mm:ss or a Unix time_t (seconds since the Epoch.)
and

"; PutsTrailer(); sub sortTest { return "" unless (exists($::FORM{sortby}) && defined($_[0]) && ($_[0] eq $::FORM{sortby})); return " SELECTED"; } refigureStartDateIfNecessary($::CVS_ROOT); sub dateTest { if( $_[0] eq $::FORM{date} ){ return " CHECKED value=$_[0]"; } else { return "value=$_[0]"; } } sub regexpradio { my ($name) = @_; my ($c1, $c2, $c3); $c1 = $c2 = $c3 = ""; my $n = $::FORM{$name} || ""; if( $n eq 'regexp'){ $c2 = "checked"; } elsif( $n eq 'notregexp'){ $c3 = "checked"; } else { $c1 = "checked"; } return " Exact match       Regular expression       Doesn't match Reg Exp"; } my $rememberedcachedate; sub fetchCachedStartDate { my ($repository) = @_; open(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; } &ConnectToDatabase(); &SendSQL("SELECT MIN(ci_when) FROM checkins,repositories WHERE repositories.id = repositoryid and repository = ?", $::CVS_ROOT); my $startdate = FetchOneColumn(); if ($startdate eq "") { $startdate = "nonexistant"; } open(OUTCACHE, ">data/cachedstartdates.$$") || die "Can't open output date cache file"; if (open(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"; }