2006-01-13 16:57:25 +00:00
|
|
|
#!/usr/bin/perl -w
|
2002-02-01 14:32:55 +00:00
|
|
|
# cvsgraph.cgi -- a graph of all branchs, tags, etc.
|
|
|
|
|
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
|
|
|
#
|
|
|
|
# The contents of this file are subject to the Mozilla 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/MPL/
|
|
|
|
#
|
|
|
|
# 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 Jacob Steenhagen
|
|
|
|
#
|
|
|
|
# Contributor(s): Jacob Steenhagen <jake@acutex.net>
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
2002-02-12 21:34:04 +00:00
|
|
|
use vars qw{ $revision_ctime $revision_author };
|
|
|
|
|
2002-02-01 14:32:55 +00:00
|
|
|
require 'CGI.pl';
|
|
|
|
|
|
|
|
# This cgi doesn't actually generate a graph. It relies on the cvsgraph
|
|
|
|
# program found at http://www.akhphd.au.dk/~bertho/cvsgraph/
|
|
|
|
# File locations can be set at in the editparams.cgi page.
|
|
|
|
|
|
|
|
sub print_top {
|
|
|
|
my ($title) = @_;
|
|
|
|
$title ||= "Error";
|
|
|
|
|
|
|
|
print "Content-type: text/html\n\n";
|
|
|
|
print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
|
|
|
|
print "<html>\n<head>\n";
|
|
|
|
print " <title>$title</title>\n";
|
|
|
|
print "</head>\n<body>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
sub print_bottom {
|
|
|
|
print "</body>\n</html>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
sub print_usage {
|
|
|
|
&print_top;
|
|
|
|
print "This script requires a filename.\n";
|
|
|
|
&print_bottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
### Live code below
|
|
|
|
|
|
|
|
unless (Param('cvsgraph')) {
|
|
|
|
&print_top;
|
|
|
|
print "CVS Graph is not currently configured for this installation\n";
|
|
|
|
&print_bottom;
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
my @src_roots = getRepositoryList();
|
|
|
|
|
|
|
|
# Handle the "file" argument
|
|
|
|
#
|
|
|
|
my $filename = '';
|
|
|
|
$filename = $::FORM{file} if defined $::FORM{file};
|
|
|
|
if ($filename eq '') {
|
|
|
|
&print_usage;
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
my ($file_head, $file_tail) = $filename =~ m@(.*/)?(.+)@;
|
2004-09-15 15:48:18 +00:00
|
|
|
my $url_filename = url_quote($filename);
|
2002-02-01 14:32:55 +00:00
|
|
|
|
|
|
|
# Handle the "root" argument
|
|
|
|
#
|
|
|
|
my $root = $::FORM{root};
|
|
|
|
if (defined $root and $root ne '') {
|
|
|
|
$root =~ s|/$||;
|
|
|
|
validateRepository($root);
|
|
|
|
if (-d $root) {
|
|
|
|
unshift(@src_roots, $root);
|
|
|
|
} else {
|
|
|
|
&print_top;
|
|
|
|
print "Error: Root, $root, is not a directory.<BR><BR>\n";
|
|
|
|
&print_bottom;
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Find the rcs file
|
|
|
|
#
|
|
|
|
my $rcs_filename;
|
|
|
|
my $found_rcs_file = 0;
|
|
|
|
foreach (@src_roots) {
|
|
|
|
$root = $_;
|
|
|
|
$rcs_filename = "$root/$filename,v";
|
|
|
|
$rcs_filename = Fix_BonsaiLink($rcs_filename);
|
|
|
|
$found_rcs_file = 1, last if -r $rcs_filename;
|
|
|
|
$rcs_filename = "$root/${file_head}Attic/$file_tail,v";
|
|
|
|
$found_rcs_file = 1, last if -r $rcs_filename;
|
|
|
|
}
|
|
|
|
|
|
|
|
unless ($found_rcs_file) {
|
2004-10-17 06:19:40 +00:00
|
|
|
my $escaped_filename = html_quote($filename);
|
|
|
|
my $shell_filename = shell_escape($filename);
|
2002-02-01 14:32:55 +00:00
|
|
|
&print_top;
|
2004-10-17 06:19:40 +00:00
|
|
|
print STDERR "cvsgraph.cgi: Rcs file, $shell_filename, does not exist.\n";
|
|
|
|
print "Invalid filename: $escaped_filename.\n";
|
2002-02-01 14:32:55 +00:00
|
|
|
&print_bottom;
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2004-12-01 08:40:33 +00:00
|
|
|
&ChrootFilename($root, $rcs_filename);
|
|
|
|
|
2002-02-01 14:32:55 +00:00
|
|
|
# Hack these variables up the way that the cvsgraph executable wants them
|
2002-02-12 21:34:04 +00:00
|
|
|
my $full_rcs_filename = $rcs_filename;
|
2002-02-01 14:32:55 +00:00
|
|
|
$rcs_filename =~ s:^$root/::;
|
|
|
|
my $conf = $0;
|
|
|
|
$conf =~ s:[^/\\]+$::;
|
|
|
|
$conf .= "data/cvsgraph.conf";
|
|
|
|
|
|
|
|
my @cvsgraph_cmd = (Param("cvsgraph"),
|
|
|
|
"-c", $conf,
|
|
|
|
"-r", $root);
|
|
|
|
|
|
|
|
if (defined $::FORM{'image'}) {
|
|
|
|
print "Content-type: image/png\n\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
push(@cvsgraph_cmd, "-i", "-M", "revmap"); # Include args to make map
|
|
|
|
&print_top("CVS Graph for " . $file_tail);
|
2002-02-12 21:34:04 +00:00
|
|
|
print <<"--endquote--" if $::use_dom;
|
|
|
|
<script $::script_type><!--
|
2006-08-18 10:35:51 +00:00
|
|
|
var r;
|
2002-02-12 21:34:04 +00:00
|
|
|
function showMessage(rev) {
|
|
|
|
if (r) {
|
2006-08-18 10:35:51 +00:00
|
|
|
r.style.display='none';
|
2002-02-12 21:34:04 +00:00
|
|
|
}
|
2006-08-18 10:35:51 +00:00
|
|
|
r = document.getElementById('rev_'+rev);
|
2004-07-07 14:32:48 +00:00
|
|
|
if (!r)
|
2006-08-18 10:35:51 +00:00
|
|
|
return false;
|
|
|
|
var l = document.getElementById('link_'+rev);
|
|
|
|
var coords = l.getAttribute("coords").split(",");
|
|
|
|
r.style.top = (coords[1]-0+20)+"px";
|
|
|
|
r.style.left = (coords[2]-0+20)+"px";
|
|
|
|
r.style.display='';
|
|
|
|
return true;
|
2002-02-12 21:34:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function hideMessage() {
|
|
|
|
if (r) {
|
2006-08-18 10:35:51 +00:00
|
|
|
r.style.display='none';
|
|
|
|
return true;
|
2002-02-12 21:34:04 +00:00
|
|
|
}
|
2006-08-18 10:35:51 +00:00
|
|
|
return false;
|
2002-02-12 21:34:04 +00:00
|
|
|
}
|
|
|
|
//--></script>
|
|
|
|
|
|
|
|
<style type="text/css">
|
|
|
|
.log_msg {
|
|
|
|
border-style: solid;
|
|
|
|
border-color: #F0A000;
|
|
|
|
background-color: #FFFFFF;
|
2004-10-11 20:18:03 +00:00
|
|
|
color: #000000;
|
2002-02-12 21:34:04 +00:00
|
|
|
padding: 5;
|
2006-08-18 10:35:51 +00:00
|
|
|
position: absolute;
|
2002-02-12 21:34:04 +00:00
|
|
|
}
|
|
|
|
</style>
|
|
|
|
--endquote--
|
|
|
|
|
|
|
|
print <<"--endquote--" unless $::use_dom;
|
|
|
|
<script $::script_type><!--
|
|
|
|
// Dummy Functions to prevent script errors (this browser does not support DOM)
|
|
|
|
function showMessage() { return false }
|
|
|
|
function hideMessage() { return false }
|
|
|
|
//--></script>
|
|
|
|
--endquote--
|
2002-02-01 14:32:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
system(@cvsgraph_cmd, $rcs_filename);
|
|
|
|
|
|
|
|
if (!defined $::FORM{'image'}) {
|
2004-09-15 15:48:18 +00:00
|
|
|
print qq{<img src="cvsgraph.cgi?file=$url_filename&image=1" };
|
2002-02-12 21:34:04 +00:00
|
|
|
print qq{usemap="#revmap" alt="$filename" border="0" onclick="hideMessage()">\n};
|
|
|
|
if ($::use_dom) {
|
|
|
|
require 'cvsblame.pl';
|
|
|
|
&parse_cvs_file($full_rcs_filename);
|
|
|
|
foreach my $rev (keys %::revision_log) {
|
|
|
|
my $author = EmailFromUsername($::revision_author{$rev});
|
|
|
|
my $rev_log = html_quote($::revision_log{$rev});
|
|
|
|
$rev_log =~ s/\n/<br>\n/g;
|
|
|
|
print qq{<div id="rev_$rev" class="log_msg" style="display:none">\n};
|
|
|
|
print qq{<b>$rev</b> };
|
|
|
|
print qq{<<a href="mailto:$author">$author</a>> };
|
|
|
|
print qq{<b>$::revision_ctime{$rev}</b><br>\n};
|
|
|
|
print $rev_log;
|
|
|
|
print qq{</div>\n};
|
|
|
|
}
|
|
|
|
}
|
2002-02-01 14:32:55 +00:00
|
|
|
&print_bottom;
|
|
|
|
}
|