1999-10-19 02:55:01 +04:00
|
|
|
#!/usr/bonsaitools/bin/perl -w
|
1998-06-17 01:43:24 +04:00
|
|
|
#
|
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
|
|
|
|
1999-10-19 02:55:01 +04:00
|
|
|
use diagnostics;
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
# Shut up misguided -w warnings about "used only once". "use vars" just
|
|
|
|
# doesn't work for me.
|
|
|
|
|
|
|
|
sub sillyness {
|
|
|
|
my $zz;
|
|
|
|
$zz = $::RepositoryID;
|
|
|
|
$zz = $::StartingDir;
|
|
|
|
}
|
|
|
|
|
1999-07-23 22:39:31 +04:00
|
|
|
use File::Basename;
|
|
|
|
|
|
|
|
require "CGI.pl";
|
|
|
|
|
|
|
|
sub ProcessOneFile {
|
|
|
|
my ($filename) = @_;
|
|
|
|
my $rlog = Param('rlogcommand') . " $filename |";
|
|
|
|
my $doingtags = 0;
|
|
|
|
my $filehead = dirname($filename);
|
|
|
|
my (%branchname, $filerealname, $filetail, $line, $trimmed);
|
|
|
|
my ($tag, $version, $branchid, $dirid, $fileid, $indesc, $desc);
|
|
|
|
my ($author, $revision, $datestr, $date, $pluscount, $minuscount);
|
|
|
|
my ($branch);
|
|
|
|
|
|
|
|
print "$filename\n";
|
|
|
|
|
|
|
|
die "Unable to run rlog command '$rlog': $!\n"
|
|
|
|
unless (open(RLOG_PROC, "$rlog"));
|
|
|
|
undef (%branchname);
|
|
|
|
|
|
|
|
($filerealname = $filename) =~ s/,v$//g;
|
|
|
|
$filehead =~ s!^$::Repository/*!!;
|
|
|
|
$filehead = '.'
|
|
|
|
unless ($filehead);
|
|
|
|
$filetail = basename($filerealname);
|
|
|
|
|
|
|
|
while (<RLOG_PROC>) {
|
|
|
|
chop;
|
|
|
|
$line = $_;
|
|
|
|
$trimmed = trim($line);
|
|
|
|
|
|
|
|
if ($doingtags) {
|
|
|
|
if ($line !~ /^\t/) {
|
|
|
|
$doingtags = 0;
|
|
|
|
} else {
|
|
|
|
$trimmed =~ /^([^:]*):([^:]*)/;
|
|
|
|
$tag = trim($1);
|
|
|
|
$version = trim($2);
|
|
|
|
|
|
|
|
next
|
|
|
|
unless (length($tag) && length($version));
|
|
|
|
|
|
|
|
$branchid = GetId('branches', 'branch', $tag);
|
|
|
|
$dirid = GetId('dirs', 'dir', $filehead);
|
|
|
|
$fileid = GetId('files', 'file', $filetail);
|
|
|
|
#
|
1998-06-17 01:43:24 +04:00
|
|
|
# Don't touch the tags database for now. Nothing uses it, and it just takes
|
|
|
|
# up too much damn space.
|
1999-07-23 22:39:31 +04:00
|
|
|
#
|
|
|
|
# SendSQL "replace into tags (branchid, repositoryid,
|
|
|
|
# dirid, fileid, revision) values ($branchid,
|
|
|
|
# $repositoryid, $dirid, $fileid, '$version')"
|
|
|
|
#
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
# Aha! Second-to-last being a zero is CVS's special way
|
|
|
|
# of remembering a branch tag.
|
1999-07-23 22:39:31 +04:00
|
|
|
$version =~ /(.*)\.(\d+)(\.\d+)$/;
|
|
|
|
$branchname{"$1$3"} = $tag
|
|
|
|
if ($2 eq '0');
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($line =~ /^symbolic names/) {
|
|
|
|
$doingtags = 1;
|
|
|
|
next;
|
|
|
|
} elsif ($line =~ /^revision ([0-9.]*)$/) {
|
|
|
|
$pluscount = ($minuscount = ($date = ($indesc = 0)));
|
|
|
|
$desc = ($branch = ($author = ($datestr = ($revision = ''))));
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
# Dealing with descriptions in rlog output for a
|
|
|
|
# revision...
|
|
|
|
if ($indesc) {
|
|
|
|
if (($line =~ /^-{27,30}$/) ||
|
|
|
|
($line =~ /^={75,80}$/)) {
|
|
|
|
# OK, we're done. Write it out.
|
|
|
|
if ($author && $datestr && $revision) {
|
2002-06-27 08:31:28 +04:00
|
|
|
$datestr =~ s!^(\d{4})/(\d+/\d+)!$2/$1!;
|
1999-09-24 03:34:59 +04:00
|
|
|
$date = str2time($datestr, "GMT");
|
1999-07-23 22:39:31 +04:00
|
|
|
if ($date >= $::StartFrom) {
|
1999-10-19 02:55:01 +04:00
|
|
|
AddToDatabase("C|$date|$author|$::Repository|$filehead|$filetail|$revision||$branch|+$pluscount|-$minuscount", $desc);
|
1999-07-23 22:39:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$indesc = 0;
|
|
|
|
} else {
|
|
|
|
$desc .= $line . "\n";
|
|
|
|
}
|
1998-06-17 01:43:24 +04:00
|
|
|
}
|
1999-07-23 22:39:31 +04:00
|
|
|
|
|
|
|
# Dealing with revision information for a specific
|
|
|
|
# revision...
|
|
|
|
else {
|
|
|
|
if ($line =~ /^revision ([0-9.]*)$/) {
|
|
|
|
$pluscount = ($minuscount = 0);
|
|
|
|
$date = ($indesc = 0);
|
|
|
|
$datestr = ($desc = ($branch = ($author = "")));
|
|
|
|
$revision = $1;
|
|
|
|
|
|
|
|
$revision =~ /(.*)\.\d*$/;
|
|
|
|
$branch = $branchname{$1}
|
|
|
|
if (exists($branchname{$1}));
|
|
|
|
}
|
|
|
|
|
|
|
|
elsif ($line =~ /^date:/) {
|
|
|
|
$line =~ s!^date: ([0-9 /:]*);\s+!!;
|
|
|
|
$datestr = $1;
|
|
|
|
|
|
|
|
$line =~ s!^author: ([^;]*);\s+!!;
|
|
|
|
$author = $1;
|
|
|
|
|
|
|
|
if ($line =~ /lines: \+(\d+) -(\d+)/) {
|
|
|
|
$pluscount = $1;
|
|
|
|
$minuscount = $2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
elsif ($line =~ /^branches: [0-9 .;]*$/) {
|
|
|
|
# Ignore these lines; make sure they don't
|
2001-07-13 21:45:52 +04:00
|
|
|
# become part of the description.
|
1999-07-23 22:39:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
$indesc = 1;
|
|
|
|
$desc = "$line\n";
|
|
|
|
}
|
1998-06-17 01:43:24 +04:00
|
|
|
}
|
|
|
|
|
1999-10-19 02:55:01 +04:00
|
|
|
$line = <RLOG_PROC>;
|
|
|
|
if (!defined $line) {
|
|
|
|
last;
|
|
|
|
}
|
1999-07-23 22:39:31 +04:00
|
|
|
chop($line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-07-23 22:39:31 +04:00
|
|
|
close(RLOG_PROC);
|
1998-06-17 01:43:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-23 22:39:31 +04:00
|
|
|
sub ProcessDirectory {
|
|
|
|
my ($dir) = @_;
|
|
|
|
my ($file, @files);
|
|
|
|
|
|
|
|
die "$dir: not a directory" unless (-d $dir);
|
|
|
|
die "$dir: Couldn't open for reading: $!"
|
|
|
|
unless (opendir(DIR, $dir));
|
|
|
|
@files = readdir(DIR);
|
|
|
|
closedir (DIR);
|
|
|
|
|
|
|
|
foreach $file (@files) {
|
|
|
|
next if $file eq '.';
|
|
|
|
next if $file eq '..';
|
|
|
|
|
|
|
|
$file = "$dir/$file";
|
|
|
|
if (-d $file) {
|
|
|
|
&ProcessDirectory($file);
|
|
|
|
} else {
|
|
|
|
next unless ($file =~ /,v$/);
|
|
|
|
|
1999-10-19 02:55:01 +04:00
|
|
|
if ($::FirstFile && ($::FirstFile ne $file)) {
|
1999-07-23 22:39:31 +04:00
|
|
|
print "Skipping $file...\n";
|
|
|
|
next;
|
|
|
|
}
|
1999-10-19 02:55:01 +04:00
|
|
|
$::FirstFile = 0;
|
1999-07-23 22:39:31 +04:00
|
|
|
ProcessOneFile($file);
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
1999-07-23 22:39:31 +04:00
|
|
|
if ($#ARGV == 4) {
|
|
|
|
$::TreeID = $ARGV[0];
|
|
|
|
$::FORM{'startfrom'} = $ARGV[1];
|
|
|
|
$::FORM{'firstfile'} = $ARGV[2];
|
|
|
|
$::FORM{'subdir'} = $ARGV[3];
|
|
|
|
$::FORM{'modules'} = $ARGV[4];
|
|
|
|
} else {
|
|
|
|
print "Content-type: text/html
|
|
|
|
|
|
|
|
<HTML>";
|
|
|
|
CheckPassword(FormData('password'));
|
|
|
|
print "
|
|
|
|
<title>Rebuilding CVS history database... please be patient...</title>
|
|
|
|
<body>
|
|
|
|
<pre>\n";
|
1998-06-17 01:43:24 +04:00
|
|
|
}
|
|
|
|
|
1999-07-23 22:39:31 +04:00
|
|
|
$::StartFrom = ParseTimeAndCheck(FormData('startfrom'));
|
|
|
|
$::FirstFile = trim(FormData('firstfile'));
|
|
|
|
$::SubDir = trim(FormData('subdir'));
|
|
|
|
$::Modules = '';
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-07-23 22:39:31 +04:00
|
|
|
if (defined($::FORM{'modules'})) {
|
|
|
|
$::Modules = trim(FormData('modules'));
|
1998-06-17 01:43:24 +04:00
|
|
|
}
|
|
|
|
|
1999-07-23 22:39:31 +04:00
|
|
|
Lock();
|
|
|
|
LoadTreeConfig();
|
|
|
|
Unlock();
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-07-23 22:39:31 +04:00
|
|
|
ConnectToDatabase();
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-07-23 22:39:31 +04:00
|
|
|
$::Repository = $::TreeInfo{$::TreeID}{'repository'};
|
|
|
|
$::Description = $::TreeInfo{$::TreeID}{'description'};
|
|
|
|
$::RepositoryID = GetId('repositories', 'repository', $::Repository);
|
|
|
|
$::StartingDir = 0;
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-07-23 22:39:31 +04:00
|
|
|
print "
|
|
|
|
Rebuilding entire checkin history in $::Description, (`$::TreeID' tree) ...
|
|
|
|
";
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-07-23 22:39:31 +04:00
|
|
|
Log("Rebuilding cvs history in $::Description, (`$::TreeID' tree)...");
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-07-23 22:39:31 +04:00
|
|
|
LoadDirList();
|
1999-10-19 02:55:01 +04:00
|
|
|
my @Dirs = grep(!/\*$/, @::LegalDirs);
|
1999-07-23 22:39:31 +04:00
|
|
|
@Dirs = split(/,\s*/, $::Modules) if $::Modules;
|
1999-10-19 02:55:01 +04:00
|
|
|
my $StartingDir;
|
1999-07-23 22:39:31 +04:00
|
|
|
($StartingDir = "$::Repository/$::SubDir") =~ s!/.?$!! if $::SubDir;
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
|
1999-07-23 22:39:31 +04:00
|
|
|
print "Doing directories: @Dirs ...\n";
|
1999-10-19 02:55:01 +04:00
|
|
|
foreach my $Dir (@Dirs) {
|
1999-07-23 22:39:31 +04:00
|
|
|
my $dir = "$::Repository/$Dir";
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-07-23 22:39:31 +04:00
|
|
|
unless (grep $Dir, @::LegalDirs) {
|
|
|
|
print "$Dir: is invalid, skipping...\n";
|
|
|
|
}
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-07-23 22:39:31 +04:00
|
|
|
if (-f $dir) {
|
|
|
|
ProcessOneFile($dir);
|
|
|
|
} elsif (-d $dir) {
|
|
|
|
ProcessDirectory($dir);
|
|
|
|
} else {
|
|
|
|
print "$Dir: not a file or directory, skipping...\n";
|
|
|
|
}
|
1998-06-17 01:43:24 +04:00
|
|
|
}
|
|
|
|
|
1999-07-23 22:39:31 +04:00
|
|
|
exit 0;
|