From 49ac4e07d266ab55285e6c497cab5d17c56e8fcf Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Sat, 7 Apr 2007 16:18:02 +0000 Subject: Bug 102622: Dependency graphs should be able to be limited by "relationship" - Patch by Frédéric Buclin r=wicked a=LpSolit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- showdependencygraph.cgi | 58 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 19 deletions(-) (limited to 'showdependencygraph.cgi') diff --git a/showdependencygraph.cgi b/showdependencygraph.cgi index 77259182f..92b6bd450 100755 --- a/showdependencygraph.cgi +++ b/showdependencygraph.cgi @@ -106,9 +106,10 @@ if (lsearch(\@valid_rankdirs, $rankdir) < 0) { $rankdir = 'LR'; } +my $display = $cgi->param('display') || 'tree'; my $webdotdir = bz_locations()->{'webdotdir'}; -if (!defined $cgi->param('id') && !defined $cgi->param('doall')) { +if (!defined $cgi->param('id') && $display ne 'doall') { ThrowCodeError("missing_bug_id"); } @@ -125,7 +126,7 @@ node [URL="${urlbase}show_bug.cgi?id=\\N", style=filled, color=lightgrey] my %baselist; -if ($cgi->param('doall')) { +if ($display eq 'doall') { my $dependencies = $dbh->selectall_arrayref( "SELECT blocked, dependson FROM dependencies"); @@ -135,29 +136,48 @@ if ($cgi->param('doall')) { } } else { foreach my $i (split('[\s,]+', $cgi->param('id'))) { - $i = trim($i); ValidateBugID($i); $baselist{$i} = 1; } my @stack = keys(%baselist); - my $sth = $dbh->prepare( - q{SELECT blocked, dependson - FROM dependencies - WHERE blocked = ? or dependson = ?}); - foreach my $id (@stack) { - my $dependencies = $dbh->selectall_arrayref($sth, undef, ($id, $id)); - foreach my $dependency (@$dependencies) { - my ($blocked, $dependson) = @$dependency; - if ($blocked != $id && !exists $seen{$blocked}) { - push @stack, $blocked; - } - if ($dependson != $id && !exists $seen{$dependson}) { - push @stack, $dependson; + if ($display eq 'web') { + my $sth = $dbh->prepare(q{SELECT blocked, dependson + FROM dependencies + WHERE blocked = ? OR dependson = ?}); + + foreach my $id (@stack) { + my $dependencies = $dbh->selectall_arrayref($sth, undef, ($id, $id)); + foreach my $dependency (@$dependencies) { + my ($blocked, $dependson) = @$dependency; + if ($blocked != $id && !exists $seen{$blocked}) { + push @stack, $blocked; + } + if ($dependson != $id && !exists $seen{$dependson}) { + push @stack, $dependson; + } + AddLink($blocked, $dependson, $fh); + } + } + } + # This is the default: a tree instead of a spider web. + else { + my @blocker_stack = @stack; + foreach my $id (@blocker_stack) { + my $blocker_ids = Bugzilla::Bug::EmitDependList('blocked', 'dependson', $id); + foreach my $blocker_id (@$blocker_ids) { + push(@blocker_stack, $blocker_id) unless $seen{$blocker_id}; + AddLink($id, $blocker_id, $fh); + } + } + my @dependent_stack = @stack; + foreach my $id (@dependent_stack) { + my $dep_bug_ids = Bugzilla::Bug::EmitDependList('dependson', 'blocked', $id); + foreach my $dep_bug_id (@$dep_bug_ids) { + push(@dependent_stack, $dep_bug_id) unless $seen{$dep_bug_id}; + AddLink($dep_bug_id, $id, $fh); } - - AddLink($blocked, $dependson, $fh); } } @@ -294,7 +314,7 @@ foreach my $f (@files) my @bugs = grep(detaint_natural($_), split(/[\s,]+/, $cgi->param('id'))); $vars->{'bug_id'} = join(', ', @bugs); $vars->{'multiple_bugs'} = ($cgi->param('id') =~ /[ ,]/); -$vars->{'doall'} = $cgi->param('doall'); +$vars->{'display'} = $display; $vars->{'rankdir'} = $rankdir; $vars->{'showsummary'} = $cgi->param('showsummary'); -- cgit v1.2.3-24-g4f1b