[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 2/3] cs-bisection-step: Make hyperlinks in SVG revision graph



Make various elements in the output into hyperlinks and hence document
that the SVG version of the graph is best to use.

AFAICT dot does not provide a way to put literal SVG elements into its
output.  So we postprocess it.  Luckily we produced the input to dot
so we know a lot about what the output will look like.

In theory it would be better to feed the SVG into an XML parser and do
this editing at the ESIS level, via XSLT.  However, I don't understand
XSLT, and this regexp-based version will work until the authors of dot
decide to change the output syntax.  If they do, the hyperlinking will
go away, but everything else will still work.  I think this approach
will be less effort overall.  This is particularly true as even using
XSLT would involve us knowing how dot's output is structured, and
changes to the syntax of the dot output are not very likely unless the
dot authors also change the semantics.

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 README.bisection  |    5 +++++
 cs-bisection-step |   36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)

diff --git a/README.bisection b/README.bisection
index ca3405c..8ea3d3e 100644
--- a/README.bisection
+++ b/README.bisection
@@ -137,6 +137,11 @@ Revision Graph
 The revision graph page shows the osstest bisector's view of the
 situation.
 
+The SVG version of the graph is best if your browser supports it.  In
+that graph the individual revisions and flight result notations are
+hyperlinks (even though they may not be marked as such in your
+browser).
+
 Each node in the graph corresponds to a tuple of revisions: one
 revision for each of the relevant trees.  Each edge changes the
 revision of one of the trees.  (osstest has constructed this graph by
diff --git a/cs-bisection-step b/cs-bisection-step
index bd5a27e..841a46a 100755
--- a/cs-bisection-step
+++ b/cs-bisection-step
@@ -1030,6 +1030,42 @@ END
             system_checked("dot", "-T$fmt", "-o$graphfile.$fmt",
                           "$graphfile.dot");
         }
+       open SVGI, "$graphfile.svg" or die "$graphfile.svg $!";
+       open SVGO, ">", "$graphfile.svg.new" or die "$graphfile.svg.new $!";
+       while (<SVGI>) {
+           if (m/^\<text/) {
+               if (m/(?<=\>)[0-9a-f]{12}(?:,[0-9a-f]{12})*(?=\<)/) {
+                   my ($l,$r) = ($`,$'); #');
+                   my @commits = split /\,/, $&;
+                   my @ocommits;
+                   for (my $i=0; $i<@commits; $i++) {
+                       my $url = "$treeinfos[$i]{Url}#$commits[$i]";
+                       push @ocommits, "<a xlink:href=\"".
+                           encode_entities($url).
+                           "\">".
+                           $commits[$i].
+                           "</a>";
+                   }
+                   $_ = $l.(join ",", @ocommits).$r;
+               } elsif (m/(?<=\>)\d+:[-a-z]+(?: \d+:[-a-z]+)*(?=\<)/) {
+                   my ($l,$r) = ($`,$'); #');
+                   my @flights = split / /, $&;
+                   foreach my $f (@flights) {
+                       $f =~ m/^\d+(?=:)/;
+                       $f = "<a xlink:href=\"".
+                           encode_entities("$c{ReportHtmlPubBaseUrl}/$&").
+                           "\">".
+                           $f."</a>";
+                   }
+                   $_ = $l.(join " ", @flights).$r;
+               }
+           }
+           print SVGO or die $!;
+       }
+       close SVGO or die $!;
+       rename "$graphfile.svg.new", "$graphfile.svg"
+           or die "$graphfile.svg $!";
+
         1;
     }) {
        my $gsize = $c{BisectionRevisonGraphSize};
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.