2006-01-13 16:57:25 +00:00
|
|
|
#!/usr/bin/perl -w
|
1998-06-16 21:43:24 +00:00
|
|
|
#
|
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
|
|
|
|
1999-10-18 22:55:01 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1999-07-23 18:39:31 +00:00
|
|
|
use File::Basename;
|
|
|
|
|
|
|
|
require "CGI.pl";
|
|
|
|
|
|
|
|
sub ProcessOneFile {
|
|
|
|
my ($filename) = @_;
|
2004-09-13 21:41:22 +00:00
|
|
|
my $rlog = Param('rlogcommand') . " " . shell_escape($filename) . " |";
|
1999-07-23 18:39:31 +00:00
|
|
|
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);
|
|
|
|
|
2006-06-13 18:03:07 +00:00
|
|
|
print "$filename";
|
1999-07-23 18:39:31 +00:00
|
|
|
|
|
|
|
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-16 21:43:24 +00:00
|
|
|
# Don't touch the tags database for now. Nothing uses it, and it just takes
|
|
|
|
# up too much damn space.
|
1999-07-23 18:39:31 +00:00
|
|
|
#
|
|
|
|
# SendSQL "replace into tags (branchid, repositoryid,
|
|
|
|
# dirid, fileid, revision) values ($branchid,
|
|
|
|
# $repositoryid, $dirid, $fileid, '$version')"
|
|
|
|
#
|
1998-06-16 21:43:24 +00:00
|
|
|
|
|
|
|
# Aha! Second-to-last being a zero is CVS's special way
|
|
|
|
# of remembering a branch tag.
|
1999-07-23 18:39:31 +00: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 04:31:28 +00:00
|
|
|
$datestr =~ s!^(\d{4})/(\d+/\d+)!$2/$1!;
|
1999-09-23 23:34:59 +00:00
|
|
|
$date = str2time($datestr, "GMT");
|
1999-07-23 18:39:31 +00:00
|
|
|
if ($date >= $::StartFrom) {
|
2006-06-13 18:03:07 +00:00
|
|
|
AddToDatabase("C|$date|$author|$::Repository|$filehead|$filetail|$revision||$branch|+$pluscount|-$minuscount", $desc, 'verbose');
|
1999-07-23 18:39:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$indesc = 0;
|
|
|
|
} else {
|
|
|
|
$desc .= $line . "\n";
|
|
|
|
}
|
1998-06-16 21:43:24 +00:00
|
|
|
}
|
1999-07-23 18:39:31 +00: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 17:45:52 +00:00
|
|
|
# become part of the description.
|
1999-07-23 18:39:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
$indesc = 1;
|
|
|
|
$desc = "$line\n";
|
|
|
|
}
|
1998-06-16 21:43:24 +00:00
|
|
|
}
|
|
|
|
|
1999-10-18 22:55:01 +00:00
|
|
|
$line = <RLOG_PROC>;
|
|
|
|
if (!defined $line) {
|
|
|
|
last;
|
|
|
|
}
|
1999-07-23 18:39:31 +00:00
|
|
|
chop($line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-06-16 21:43:24 +00:00
|
|
|
|
1999-07-23 18:39:31 +00:00
|
|
|
close(RLOG_PROC);
|
2006-06-13 18:03:07 +00:00
|
|
|
print "\n";
|
1998-06-16 21:43:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-23 18:39:31 +00: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-18 22:55:01 +00:00
|
|
|
if ($::FirstFile && ($::FirstFile ne $file)) {
|
1999-07-23 18:39:31 +00:00
|
|
|
print "Skipping $file...\n";
|
|
|
|
next;
|
|
|
|
}
|
1999-10-18 22:55:01 +00:00
|
|
|
$::FirstFile = 0;
|
1999-07-23 18:39:31 +00:00
|
|
|
ProcessOneFile($file);
|
|
|
|
}
|
|
|
|
}
|
1998-06-16 21:43:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-23 18:39:31 +00:00
|
|
|
$| = 1;
|
1998-06-16 21:43:24 +00:00
|
|
|
|
1999-07-23 18:39:31 +00: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-16 21:43:24 +00:00
|
|
|
}
|
|
|
|
|
1999-07-23 18:39:31 +00:00
|
|
|
$::StartFrom = ParseTimeAndCheck(FormData('startfrom'));
|
|
|
|
$::FirstFile = trim(FormData('firstfile'));
|
|
|
|
$::SubDir = trim(FormData('subdir'));
|
|
|
|
$::Modules = '';
|
1998-06-16 21:43:24 +00:00
|
|
|
|
1999-07-23 18:39:31 +00:00
|
|
|
if (defined($::FORM{'modules'})) {
|
|
|
|
$::Modules = trim(FormData('modules'));
|
1998-06-16 21:43:24 +00:00
|
|
|
}
|
|
|
|
|
1999-07-23 18:39:31 +00:00
|
|
|
Lock();
|
|
|
|
LoadTreeConfig();
|
|
|
|
Unlock();
|
1998-06-16 21:43:24 +00:00
|
|
|
|
1999-07-23 18:39:31 +00:00
|
|
|
ConnectToDatabase();
|
1998-06-16 21:43:24 +00:00
|
|
|
|
1999-07-23 18:39:31 +00:00
|
|
|
$::Repository = $::TreeInfo{$::TreeID}{'repository'};
|
|
|
|
$::Description = $::TreeInfo{$::TreeID}{'description'};
|
|
|
|
$::RepositoryID = GetId('repositories', 'repository', $::Repository);
|
1998-06-16 21:43:24 +00:00
|
|
|
|
1999-07-23 18:39:31 +00:00
|
|
|
print "
|
|
|
|
Rebuilding entire checkin history in $::Description, (`$::TreeID' tree) ...
|
|
|
|
";
|
1998-06-16 21:43:24 +00:00
|
|
|
|
1999-07-23 18:39:31 +00:00
|
|
|
Log("Rebuilding cvs history in $::Description, (`$::TreeID' tree)...");
|
1998-06-16 21:43:24 +00:00
|
|
|
|
1999-07-23 18:39:31 +00:00
|
|
|
LoadDirList();
|
1999-10-18 22:55:01 +00:00
|
|
|
my @Dirs = grep(!/\*$/, @::LegalDirs);
|
1999-07-23 18:39:31 +00:00
|
|
|
@Dirs = split(/,\s*/, $::Modules) if $::Modules;
|
2005-04-02 23:53:46 +00:00
|
|
|
if ($::SubDir) {
|
|
|
|
@Dirs = ($::SubDir);
|
|
|
|
}
|
1998-06-16 21:43:24 +00:00
|
|
|
|
1999-07-23 18:39:31 +00:00
|
|
|
print "Doing directories: @Dirs ...\n";
|
1999-10-18 22:55:01 +00:00
|
|
|
foreach my $Dir (@Dirs) {
|
1999-07-23 18:39:31 +00:00
|
|
|
my $dir = "$::Repository/$Dir";
|
1998-06-16 21:43:24 +00:00
|
|
|
|
1999-07-23 18:39:31 +00:00
|
|
|
unless (grep $Dir, @::LegalDirs) {
|
|
|
|
print "$Dir: is invalid, skipping...\n";
|
|
|
|
}
|
1998-06-16 21:43:24 +00:00
|
|
|
|
1999-07-23 18:39:31 +00:00
|
|
|
if (-f $dir) {
|
|
|
|
ProcessOneFile($dir);
|
|
|
|
} elsif (-d $dir) {
|
|
|
|
ProcessDirectory($dir);
|
2003-11-13 21:07:29 +00:00
|
|
|
} elsif (!-r $dir) {
|
|
|
|
print "$Dir: not readable, skipping...\n";
|
1999-07-23 18:39:31 +00:00
|
|
|
} else {
|
|
|
|
print "$Dir: not a file or directory, skipping...\n";
|
|
|
|
}
|
1998-06-16 21:43:24 +00:00
|
|
|
}
|
|
|
|
|
1999-07-23 18:39:31 +00:00
|
|
|
exit 0;
|