From 82daf4f8ca9e9250efad84b05e28848df0f99851 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 14 Feb 2013 15:53:34 +0100 Subject: [PATCH] Show dependencies as a tree rather than a list --- src/lib/Hydra/Controller/Build.pm | 57 +++++++++++++++++++++---------- src/root/build.tt | 4 +-- src/root/common.tt | 5 +++ src/root/deps.tt | 49 +++++++++++++++----------- 4 files changed, 74 insertions(+), 41 deletions(-) diff --git a/src/lib/Hydra/Controller/Build.pm b/src/lib/Hydra/Controller/Build.pm index 504c2b66..a16cea9e 100644 --- a/src/lib/Hydra/Controller/Build.pm +++ b/src/lib/Hydra/Controller/Build.pm @@ -306,6 +306,39 @@ sub contents : Chained('build') PathPart Args(1) { } +sub getDependencyGraph { + my ($self, $c, $runtime, $done, $path) = @_; + my $node = $$done{$path}; + + if (!defined $node) { + $path =~ /\/[a-z0-9]+-(.*)$/; + my $name = $1 // $path; + $name =~ s/\.drv$//; + $node = + { path => $path + , name => $name + , buildStep => $runtime + ? findBuildStepByOutPath($self, $c, $path, 0) + : findBuildStepByDrvPath($self, $c, $path, 0) + }; + $$done{$path} = $node; + my @refs; + foreach my $ref (queryReferences($path)) { + next if $ref eq $path; + next unless $runtime || $ref =~ /\.drv$/; + getDependencyGraph($self, $c, $runtime, $done, $ref); + push @refs, $ref; + } + # Show in reverse topological order to flatten the graph. + # Should probably do a proper BFS. + my @sorted = reverse topoSortPaths(@refs); + $node->{refs} = [map { $$done{$_} } @sorted]; + } + + return $node; +} + + sub deps : Chained('build') PathPart('deps') { my ($self, $c) = @_; @@ -316,28 +349,16 @@ sub deps : Chained('build') PathPart('deps') { $c->stash->{available} = all { isValidPath($_) } @outPaths; $c->stash->{drvAvailable} = isValidPath $drvPath; - my @buildtimepaths = $c->stash->{drvAvailable} ? computeFSClosure(0, 0, $drvPath) : (); - my @buildtimedeps = (); - - my @runtimepaths = $c->stash->{available} ? computeFSClosure(0, 0, @outPaths) : (); - my @runtimedeps = (); - - foreach my $p (@buildtimepaths) { - next unless $p =~ /\.drv$/; - my ($buildStep) = findBuildStepByDrvPath($self, $c, $p, 0); - my %dep = ( buildstep => $buildStep, path => $p ); - push(@buildtimedeps, \%dep); + if ($c->stash->{available}) { + my $done = {}; + $c->stash->{runtimeGraph} = [ map { getDependencyGraph($self, $c, 1, $done, $_) } @outPaths ]; } - foreach my $p (@runtimepaths) { - my ($buildStep) = findBuildStepByOutPath($self, $c, $p, 0); - my %dep = ( buildstep => $buildStep, path => $p ); - push(@runtimedeps, \%dep); + if ($c->stash->{drvAvailable}) { + my $done = {}; + $c->stash->{buildTimeGraph} = getDependencyGraph($self, $c, 0, $done, $drvPath); } - $c->stash->{buildtimedeps} = \@buildtimedeps; - $c->stash->{runtimedeps} = \@runtimedeps; - $c->stash->{template} = 'deps.tt'; } diff --git a/src/root/build.tt b/src/root/build.tt index ecd3c90c..3f1ae08d 100644 --- a/src/root/build.tt +++ b/src/root/build.tt @@ -53,9 +53,7 @@ [% ELSE %] Failed: [% HTML.escape(step.errormsg) %] [% END %] - [% IF has_log %] - (log, raw, tail) - [% END %] + [%%] [%+ IF has_log; INCLUDE renderLogLinks url=log; END %] [% END %] diff --git a/src/root/common.tt b/src/root/common.tt index 0f17aeb4..65a6c016 100644 --- a/src/root/common.tt +++ b/src/root/common.tt @@ -475,3 +475,8 @@ [% END %] + + +[% BLOCK renderLogLinks %] +(log, raw, tail) +[% END %] diff --git a/src/root/deps.tt b/src/root/deps.tt index 8a25492d..80c2a92f 100644 --- a/src/root/deps.tt +++ b/src/root/deps.tt @@ -6,40 +6,49 @@ [% jobset = build.jobset %] [% job = build.job %] - -[% IF available %] -

Runtime dependencies

-