gecko-dev/webtools/bonsai/cvsindex.pl

95 lines
2.4 KiB
Perl
Raw Normal View History

1998-06-16 21:43:24 +00:00
#!/usr/bonsaitools/bin/perl --
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
1999-11-01 23:33:56 +00: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-16 21:43:24 +00:00
#
1999-11-01 23:33:56 +00: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-16 21:43:24 +00:00
#
# The Original Code is the Bonsai CVS tool.
#
# The Initial Developer of the Original Code is Netscape Communications
1999-11-01 23:33:56 +00:00
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
1998-06-16 21:43:24 +00:00
# Figure out which directory bonsai is in by looking at argv[0]
$bonsaidir = $0;
$bonsaidir =~ s:/[^/]*$::; # Remove last word, and slash before it.
if ($bonsaidir eq "") {
$bonsaidir = ".";
}
chdir $bonsaidir || die "Couldn't chdir to $bonsaidir";
require "utils.pl";
if( $ARGV[0] eq '' ){
$::CVS_ROOT = pickDefaultRepository();
1998-06-16 21:43:24 +00:00
}
else {
$::CVS_ROOT = $ARGV[0];
1998-06-16 21:43:24 +00:00
}
$CVS_REPOS_SUFIX = $::CVS_ROOT;
1998-06-16 21:43:24 +00:00
$CVS_REPOS_SUFIX =~ s:/:_:g;
$CHECKIN_DATA_FILE = "$bonsaidir/data/checkinlog${CVS_REPOS_SUFIX}";
$CHECKIN_INDEX_FILE = "$bonsaidir/data/index${CVS_REPOS_SUFIX}";
&build_index;
&print_keys;
sub build_index {
open(CI, "<$CHECKIN_DATA_FILE") || die "could not open checkin data file\n";
$file_pos = 0;
$lastlog = 0;
$last_date = 0;
$index = {};
$now = time;
while( <CI> ){
if( /^LOGCOMMENT/ ){
$done = 0;
$file_pos += length;
while( !$done && ($line = <CI>) ){
if( $line =~ /^:ENDLOGCOMMENT/ ){
$done = 1;
}
$file_pos += length($line);
}
}
else {
#print $_ . "\n";
$ci = [split(/\|/)];
$d = $ci->[1];
if( $d < $now && $d > ($last_date + 60*60*4) ){
$index->{$d} = $file_pos;
$last_date = $d;
}
$file_pos += length;
}
}
close( CI );
}
sub print_keys {
Lock();
open(INDEX , ">$CHECKIN_INDEX_FILE");
for $i (sort {$b <=> $a} keys %{$index}) {
print INDEX "$index->{$i}|$i\n";
}
close(INDEX);
Unlock();
}