File: repophook.cgi

package info (click to toggle)
bonsai 1.3%2Bcvs20060111-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,096 kB
  • ctags: 445
  • sloc: perl: 11,380; sh: 271; makefile: 223; sql: 217
file content (158 lines) | stat: -rwxr-xr-x 4,374 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/usr/bonsaitools/bin/perl -w
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# 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/
#
# 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.
#
# Contributor(s): 

use lib '/usr/share/bonsai/lib'; 

require 'CGI.pl';

use strict;

# Shut up misguided -w warnings about "used only once".  "use vars" just
# doesn't work for me.

sub sillyness {
    my $zz;
    $zz = $::FORM{password};
    $zz = $::LegalDirs;
    $zz = $::TreeOpen;
}


print "Content-type: text/html

<HTML>";

&validateReferer('admin.cgi');
CheckPassword($::FORM{'password'});

my $startfrom = ParseTimeAndCheck(FormData('startfrom'));

LoadTreeConfig();
LoadDirList();
LoadCheckins();
@::CheckInList = ();

Lock();

$| = 1;

ConnectToDatabase();

print "<TITLE> Rebooting, please wait...</TITLE>

<H1>Recreating the hook</H1>

<h3>$::TreeInfo{$::TreeID}->{'description'}</h3>

<p>
Searching for first checkin after " . SqlFmtClock($startfrom) . "...<p>\n";

my $inbranch = $::TreeInfo{$::TreeID}->{'branch'};
print "<p> $inbranch <p> \n";

my $sqlstring = "SELECT type, UNIX_TIMESTAMP(ci_when), people.who, " .
    "repositories.repository, dirs.dir, files.file, revision, stickytag, " .
    "branches.branch, addedlines, removedlines, descs.description FROM " .
    "checkins,people,repositories,dirs,files,branches,descs WHERE " .
    "people.id=whoid AND repositories.id=repositoryid AND dirs.id=dirid " .
    "AND files.id=fileid AND branches.id=branchid AND descs.id=descid AND " .
    "branches.branch=? AND ci_when>=? ORDER BY ci_when;";
my @bind_values = ($inbranch, &SqlFmtClock($startfrom));
print "<p> " . &html_quote($sqlstring) . " <br>\n";
print "With values:<br>\n";
foreach my $v (@bind_values) {
    print "\t" . &html_quote($v) . "<br>\n";
}
print "<p>\n";
&SendSQL($sqlstring, @bind_values);

my ($change, $date, $who, $repos, $dir, $file, $rev, $sticky, $branch, $linesa, $linesr, $log);
my ($lastchange, $lastdate, $lastwho, $lastrepos, $lastdir, $lastrev, $laststicky, $lastbranch, $lastlinesa, $lastlinesr, $lastlog);
my ($id, $info, @files, @fullinfo);
my ($d, $f, $okdir, $full);
my ($r);
$lastdate = "";
$lastdir = "";
@files = ();
@fullinfo = ();
while (($change, $date, $who, $repos, $dir, $file, $rev, $sticky, $branch, $linesa, $linesr, $log) = FetchSQLData()) {
#	print "<p>$change $date $who $repos $dir $file $rev $sticky $branch $linesa $linesr $log<p>\n ";
if (($date ne $lastdate && $lastdate ne "") || ($dir ne $lastdir && $lastdir ne "")) {

	$okdir = 0;
LEGALDIR:
	foreach $d (sort( grep(!/\*$/, @::LegalDirs))) {
		if ($lastdir =~ m!^$d\b!) {
			$okdir = 1;
			last LEGALDIR;
		}
	}
	if ($okdir) {
		print "<br>";
		print "$lastchange $lastdate $lastwho $lastrepos <br> $lastdir ";
		print "<br>";
		foreach $f (@files) { print "$f ";}
		print " <br>$lastrev $laststicky $lastbranch $lastlinesa $lastlinesr <br>$lastlog";
		print "\n<br>--------------------------------------------------------<br>\n";
		$r++;
		$id = "::checkin_${lastdate}_$r";
		push @::CheckInList, $id;
	
		$info = eval("\\\%$id");
		%$info = (
		person	  => $lastwho,
		date	  => $lastdate,
		dir	  => $lastdir,
		files	  => join('!NeXt!', @files),
		'log'	  => MarkUpText(html_quote(trim($lastlog))),
		treeopen => $::TreeOpen,
		fullinfo => join('!NeXt!', @fullinfo)
		);
	}

@files = ();
@fullinfo = ();
}
$lastchange = $change;
$lastdate = $date;
$lastwho = $who;
$lastrepos = $repos;
$lastdir = $dir;
$lastrev = $rev;
$laststicky = $sticky;
$lastbranch = $branch;
$lastlinesa = $linesa;
$lastlinesr = $linesr;
$lastlog = $log;

if (!($file=~/Tag:/ || ($file=~/$branch/) && ($branch) )) {
push @files, $file;
push @fullinfo, "$file|$rev|$linesa|$linesr|";
}
}

WriteCheckins();
Unlock();

print "<p>OK, done. \n";

PutsTrailer();