gecko-dev/webtools/bonsai/repophook.cgi

135 строки
3.3 KiB
Plaintext
Исходник Обычный вид История

#!/usr/bonsaitools/bin/perl -w
# -*- Mode: perl; indent-tabs-mode: nil -*-
1998-06-17 01:43:24 +04:00
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (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.
require 'CGI.pl';
1998-06-17 01:43:24 +04:00
use diagnostics;
use strict;
1998-06-17 01:43:24 +04:00
print "Content-type: text/html
1998-06-17 01:43:24 +04:00
<HTML>";
1998-06-17 01:43:24 +04:00
CheckPassword($::FORM{'password'});
1998-06-17 01:43:24 +04:00
my $startfrom = ParseTimeAndCheck(FormData('startfrom'));
1998-06-17 01:43:24 +04:00
Lock();
LoadTreeConfig();
LoadCheckins();
@::CheckInList = ();
WriteCheckins();
Unlock();
1998-06-17 01:43:24 +04:00
$| = 1;
print "<TITLE> Rebooting, please wait...</TITLE>
1998-06-17 01:43:24 +04:00
<H1>Recreating the hook</H1>
<h3>$::TreeInfo{$::TreeID}->{'description'}</h3>
1998-06-17 01:43:24 +04:00
<p>
Searching for first checkin after " . MyFmtClock($startfrom) . "...<p>\n";
1998-06-17 01:43:24 +04:00
my $mungedname = $::TreeInfo{$::TreeID}->{'repository'};
$mungedname =~ s@/@_@g;
$mungedname =~ s/^_//;
1998-06-17 01:43:24 +04:00
my $filename = "data/checkinlog/$mungedname";
1998-06-17 01:43:24 +04:00
open(FID, "<$filename") || die "Can't open $filename";
1998-06-17 01:43:24 +04:00
my $foundfirst = 0;
1998-06-17 01:43:24 +04:00
my $buffer = "";
1998-06-17 01:43:24 +04:00
my $tempfile = "data/repophook.$$";
1998-06-17 01:43:24 +04:00
my $count = 0;
my $lastdate = 0;
1998-06-17 01:43:24 +04:00
sub FlushBuffer {
if (!$foundfirst || $buffer eq "") {
return;
1998-06-17 01:43:24 +04:00
}
open(TMP, ">$tempfile") || die "Can't open $tempfile";
print TMP "junkline\n\n$buffer\n";
close(TMP);
system("./addcheckin.pl -treeid $::TreeID $tempfile");
# unlink($tempfile);
$buffer = "";
$count++;
if ($count % 100 == 0) {
print "$count scrutinized...<br>\n";
1998-06-17 01:43:24 +04:00
}
}
my $now = time();
while (<FID>) {
chomp();
my $line = $_;
if ($line =~ /^.\|/) {
my ($chtype, $date) = (split(/\|/, $line));
if ($date < $lastdate) {
print "Ick; dates out of order!<br>\n";
print "<pre>" . value_quote($line) . "</pre><p>\n";
}
$lastdate = $date;
if ($foundfirst) {
$buffer .= "$line\n";
} else {
if ($date >= $startfrom) {
if ($date >= $now) {
print "Found a future date! (ignoring):<br>\n";
print "<pre>" . value_quote($line) . "</pre><p>\n";
1998-06-17 01:43:24 +04:00
} else {
$foundfirst = 1;
print "Found first line: <br>\n";
print "<pre>" . value_quote($line) . "</pre><p>\n";
print "OK, now processing checkins...<p>";
$buffer = "$line\n";
$count = 0;
}
} else {
$count++;
if ($count % 2000 == 0) {
print "Skipped $count lines...<p>\n";
1998-06-17 01:43:24 +04:00
}
}
}
} elsif ($line =~ /^:ENDLOGCOMMENT$/) {
$buffer .= "$line\n";
FlushBuffer();
} else {
$buffer .= "$line\n";
1998-06-17 01:43:24 +04:00
}
}
FlushBuffer();
1998-06-17 01:43:24 +04:00
print "OK, done. \n";
1998-06-17 01:43:24 +04:00
PutsTrailer();