From 65aeb54b2937560d2eb4ca46ad9a58c636afb361 Mon Sep 17 00:00:00 2001 From: "terry%mozilla.org" <> Date: Thu, 27 May 1999 21:13:40 +0000 Subject: Added dependencies, so that you can mark which bugs depend on which other ones. --- showdependencygraph.cgi | 165 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100755 showdependencygraph.cgi (limited to 'showdependencygraph.cgi') diff --git a/showdependencygraph.cgi b/showdependencygraph.cgi new file mode 100755 index 000000000..1e3a02e2a --- /dev/null +++ b/showdependencygraph.cgi @@ -0,0 +1,165 @@ +#!/usr/bonsaitools/bin/perl -w +# -*- Mode: perl; indent-tabs-mode: nil -*- +# +# The contents of this file are subject to the Mozilla 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/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 Bugzilla Bug Tracking System. +# +# 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): Terry Weissman + +use diagnostics; +use strict; + +require "CGI.pl"; + +my $id = $::FORM{'id'}; +my $urlbase = Param("urlbase"); + +my %seen; +my %edgesdone; + +sub AddLink { + my ($blocked, $dependson) = (@_); + my $key = "$blocked,$dependson"; + if (!exists $edgesdone{$key}) { + $edgesdone{$key} = 1; + print DOT "$blocked -> $dependson\n"; + $seen{$blocked} = 1; + $seen{$dependson} = 1; + } +} + + +print "Content-type: text/html\n\n"; +PutHeader("Dependency graph", "Dependency graph", $id); + +if (defined $id) { + ConnectToDatabase(); + + mkdir("data/webdot", 0777); + + my $filename = "data/webdot/$$.dot"; + open(DOT, ">$filename") || die "Can't create $filename"; + print DOT "digraph G {"; + print DOT qq{ +graph [URL="${urlbase}query.cgi"] +node [URL="${urlbase}show_bug.cgi?id=\\N", style=filled, color=lightgrey] +}; + my %baselist; + + foreach my $i (split('[\s,]+', $::FORM{'id'})) { + $i = trim($i); + if ($i ne "") { + $baselist{$i} = 1; + } + } + + if ($::FORM{'doall'}) { + SendSQL("select blocked, dependson from dependencies"); + + while (MoreSQLData()) { + my ($blocked, $dependson) = (FetchSQLData()); + AddLink($blocked, $dependson); + } + } else { + my @stack = keys(%baselist); + while (@stack) { + my $id = shift @stack; + SendSQL("select blocked, dependson from dependencies where blocked = $id or dependson = $id"); + while (MoreSQLData()) { + my ($blocked, $dependson) = (FetchSQLData()); + if ($blocked != $id && !exists $seen{$blocked}) { + push @stack, $blocked; + } + if ($dependson != $id && !exists $seen{$dependson}) { + push @stack, $dependson; + } + AddLink($blocked, $dependson); + } + } + } + + foreach my $k (keys(%seen)) { + my $summary = ""; + my $stat; + if ($::FORM{'showsummary'}) { + SendSQL("select bug_status, short_desc from bugs where bug_id = $k"); + ($stat, $summary) = (FetchSQLData()); + } else { + SendSQL("select bug_status from bugs where bug_id = $k"); + $stat = FetchOneColumn(); + } + my @params; +# print DOT "$k [URL" . qq{="${urlbase}show_bug.cgi?id=$k"}; + if ($summary ne "") { + $summary =~ s/([\\\"])/\\$1/g; + push(@params, qq{label="$k\\n$summary"}); + } + if (exists $baselist{$k}) { + push(@params, "shape=box"); + } + my $opened = ($stat eq "NEW" || $stat eq "ASSIGNED" || + $stat eq "REOPENED"); + if ($opened) { + push(@params, "color=green"); + } + if (@params) { + print DOT "$k [" . join(',', @params) . "]\n"; + } else { + print DOT "$k\n"; + } + } + + + print DOT "}\n"; + close DOT; + chmod 0777, $filename; + + my $url = PerformSubsts(Param("webdotbase")) . $filename; + + print qq{
\n}; + + # Cleanup any old .dot files created from previous runs. + my $since = time() - 24 * 60 * 60; + foreach my $f (glob("data/webdot/*.dot")) { + if (ModTime($f) < $since) { + unlink $f; + } + } +} else { + $::FORM{'id'} = ""; + $::FORM{'doall'} = 0; + $::FORM{'showsummary'} = 0; +} + +print " +
+ + + + + + + +
Bug numbers:Show every bug in the system with +dependencies
Show the summary of all bugs +
+ +
+ "; + +navigation_header(); -- cgit v1.2.3-24-g4f1b