2006-12-07 07:59:39 +03:00
|
|
|
#!/usr/bin/perl --
|
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 Tinderbox build 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
|
|
|
|
2007-01-23 20:49:10 +03:00
|
|
|
use strict;
|
1999-12-09 22:28:39 +03:00
|
|
|
use File::Copy 'move';
|
1998-06-17 01:43:24 +04:00
|
|
|
|
2006-07-17 21:14:35 +04:00
|
|
|
use lib "@TINDERBOX_DIR@";
|
1999-07-23 23:36:38 +04:00
|
|
|
require 'tbglobals.pl';
|
2007-01-23 20:49:10 +03:00
|
|
|
my $F_DEBUG=0;
|
1998-06-17 01:43:24 +04:00
|
|
|
|
2006-07-17 21:14:35 +04:00
|
|
|
$ENV{'PATH'} = "@SETUID_PATH@";
|
|
|
|
|
1999-12-09 22:28:39 +03:00
|
|
|
# Process args:
|
|
|
|
# $days: How many days of data to process.
|
|
|
|
# $tree: Which tree to use.
|
2007-01-23 20:49:10 +03:00
|
|
|
my $days = undef;
|
|
|
|
my $tree = undef;
|
2006-06-23 20:12:41 +04:00
|
|
|
|
|
|
|
if ($ARGV[0] eq '-days') {
|
|
|
|
shift;
|
2006-07-17 21:14:35 +04:00
|
|
|
$days = &trick_taint(shift);
|
2006-06-23 20:12:41 +04:00
|
|
|
}
|
2006-07-17 21:14:35 +04:00
|
|
|
$tree = &trick_taint(shift);
|
2006-06-23 20:12:41 +04:00
|
|
|
|
|
|
|
&usage() if (!defined($tree));
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-12-09 22:28:39 +03:00
|
|
|
# Grab globals for this tree:
|
2006-06-23 20:12:41 +04:00
|
|
|
# $who_days: Number of days of commit info to make available
|
1999-12-09 22:28:39 +03:00
|
|
|
# $cvs_module: The checkout module
|
2001-03-26 03:53:37 +04:00
|
|
|
# $cvs_branch: The current branch
|
1999-12-09 22:28:39 +03:00
|
|
|
# $cvs_root: The path to the cvs root
|
2006-08-16 10:28:38 +04:00
|
|
|
# $bonsai_tree: The data directory for this tree in $bonsai_dir
|
2006-06-05 21:42:48 +04:00
|
|
|
# $viewvc_repository: Repository path used by viewvc for this tree
|
1998-06-17 01:43:24 +04:00
|
|
|
require "$tree/treedata.pl";
|
|
|
|
|
2007-01-23 20:49:10 +03:00
|
|
|
$days = $::who_days if (!defined($days));
|
2006-06-23 20:12:41 +04:00
|
|
|
|
2006-06-05 21:42:48 +04:00
|
|
|
# Exit early if no query system is enabled
|
2007-01-23 20:49:10 +03:00
|
|
|
exit 0 if (!$::use_bonsai && !$::use_viewvc);
|
2006-06-05 21:42:48 +04:00
|
|
|
|
|
|
|
# Only allow one process at a time to re-write "who.dat".
|
1999-12-09 22:28:39 +03:00
|
|
|
#
|
2006-10-19 22:13:12 +04:00
|
|
|
my $lockfile = "$tree/buildwho.sem";
|
|
|
|
my $lock = lock_datafile($lockfile);
|
1998-06-17 01:43:24 +04:00
|
|
|
|
2007-01-23 20:49:10 +03:00
|
|
|
if ($::use_bonsai) {
|
2006-06-05 21:42:48 +04:00
|
|
|
# Setup global variables for bonsai query
|
|
|
|
#
|
2007-01-23 20:49:10 +03:00
|
|
|
if ($::cvs_root eq '') {
|
|
|
|
$::CVS_ROOT = "$::default_cvsroot";
|
2006-06-05 21:42:48 +04:00
|
|
|
} else {
|
2007-01-23 20:49:10 +03:00
|
|
|
$::CVS_ROOT = $::cvs_root;
|
2006-06-05 21:42:48 +04:00
|
|
|
}
|
|
|
|
|
2007-01-23 20:49:10 +03:00
|
|
|
$::CVS_REPOS_SUFIX = $::CVS_ROOT;
|
|
|
|
$::CVS_REPOS_SUFIX =~ s/\//_/g;
|
1998-06-17 01:43:24 +04:00
|
|
|
|
2007-01-23 20:49:10 +03:00
|
|
|
$::CHECKIN_DATA_FILE = "$::bonsai_dir/data/checkinlog$::CVS_REPOS_SUFIX";
|
|
|
|
$::CHECKIN_INDEX_FILE = "$::bonsai_dir/data/index$::CVS_REPOS_SUFIX";
|
1998-06-17 01:43:24 +04:00
|
|
|
|
2006-08-16 10:28:38 +04:00
|
|
|
use lib "@BONSAI_DIR@";
|
2006-06-05 21:42:48 +04:00
|
|
|
require 'cvsquery.pl';
|
|
|
|
|
2007-01-23 20:49:10 +03:00
|
|
|
print "cvsroot='$::CVS_ROOT'\n" if $F_DEBUG;
|
|
|
|
} elsif ($::use_viewvc) {
|
2006-06-05 21:42:48 +04:00
|
|
|
require 'viewvc.pl';
|
|
|
|
}
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
|
1999-12-09 22:28:39 +03:00
|
|
|
build_who($tree);
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-12-09 22:28:39 +03:00
|
|
|
unlock_datafile($lock);
|
2006-10-19 22:13:12 +04:00
|
|
|
unlink($lockfile);
|
1999-12-09 22:28:39 +03:00
|
|
|
# End of main
|
|
|
|
##################################################################
|
2006-06-23 20:12:41 +04:00
|
|
|
sub usage() {
|
|
|
|
print "Usage: $0 [-days days_of_commitinfo] treename\n";
|
|
|
|
exit 1;
|
1999-12-09 22:28:39 +03:00
|
|
|
}
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-12-09 22:28:39 +03:00
|
|
|
sub build_who {
|
|
|
|
my ($tree) = @_;
|
2007-01-23 20:49:10 +03:00
|
|
|
$::query_date_min = time - (60 * 60 * 24 * $days);
|
1999-12-09 22:28:39 +03:00
|
|
|
|
2007-01-23 20:49:10 +03:00
|
|
|
print "Minimum date: $::query_date_min\n" if $F_DEBUG;
|
1998-06-17 01:43:24 +04:00
|
|
|
|
2007-01-23 20:49:10 +03:00
|
|
|
if ($::use_viewvc) {
|
|
|
|
$::query_module=$::viewvc_repository;
|
|
|
|
} elsif ($::use_bonsai) {
|
|
|
|
$::query_module=$::cvs_module;
|
|
|
|
$::query_branch=$::cvs_branch;
|
2006-06-05 21:42:48 +04:00
|
|
|
} else {
|
|
|
|
# Should never reach this
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-01-23 20:49:10 +03:00
|
|
|
$::query_branchtype='regexp' if $::query_branch =~ /\*|\?|\+/;
|
2006-01-14 06:37:29 +03:00
|
|
|
$::query_branch_head=1 if $::query_branch eq 'HEAD';
|
2001-03-26 03:53:37 +04:00
|
|
|
|
1999-12-09 22:28:39 +03:00
|
|
|
my $who_file = "$tree/who.dat";
|
|
|
|
my $temp_who_file = "$who_file.$$";
|
2006-07-25 00:12:09 +04:00
|
|
|
open(WHOLOG, ">", "$temp_who_file");
|
1999-07-24 08:47:57 +04:00
|
|
|
|
2007-01-23 20:49:10 +03:00
|
|
|
if ($::use_bonsai) {
|
|
|
|
chdir $::bonsai_dir;
|
|
|
|
$::TreeID = $::bonsai_tree;
|
2006-06-05 21:42:48 +04:00
|
|
|
}
|
2007-01-23 20:49:10 +03:00
|
|
|
my $result = &query_checkins(%::mod_map);
|
2006-06-05 21:42:48 +04:00
|
|
|
|
2007-01-23 20:49:10 +03:00
|
|
|
my $last_who='';
|
|
|
|
my $last_date=0;
|
|
|
|
for my $ci (@$result) {
|
|
|
|
if ($ci->[$::CI_DATE] != $last_date or $ci->[$::CI_WHO] ne $last_who) {
|
|
|
|
print WHOLOG "$ci->[$::CI_DATE]|$ci->[$::CI_WHO]\n";
|
1998-06-17 01:43:24 +04:00
|
|
|
}
|
2007-01-23 20:49:10 +03:00
|
|
|
$last_who=$ci->[$::CI_WHO];
|
|
|
|
$last_date=$ci->[$::CI_DATE];
|
1998-06-17 01:43:24 +04:00
|
|
|
}
|
1999-12-09 22:28:39 +03:00
|
|
|
close (WHOLOG);
|
2007-01-23 20:49:10 +03:00
|
|
|
if ($::use_bonsai) {
|
2006-08-16 10:28:38 +04:00
|
|
|
chdir "@TINDERBOX_DIR@";
|
2006-06-05 21:42:48 +04:00
|
|
|
}
|
1999-12-09 22:28:39 +03:00
|
|
|
move($temp_who_file, $who_file);
|
1998-06-17 01:43:24 +04:00
|
|
|
}
|