Mercurial > pub > buggler
diff translate.pl @ 6:2a5f38eb25a9
migrated to saxon8 as xslt processor
fixed dependency calculation when a container has a dependency on his grandchild
author | cin |
---|---|
date | Wed, 02 Sep 2015 20:43:38 +0300 |
parents | d2efec56373f |
children | 29309bc8d932 |
line wrap: on
line diff
--- a/translate.pl Tue Sep 01 19:47:30 2015 +0300 +++ b/translate.pl Wed Sep 02 20:43:38 2015 +0300 @@ -4,7 +4,7 @@ use YAML::XS qw(LoadFile Dump); use URI; use XML::Writer; -use IPC::Run qw(run); +use IPC::Run qw(start finish); our @ClassPath = qw( /usr/share/java/xalan-j2-serializer.jar @@ -25,78 +25,109 @@ apikey => $config->{bugzilla}{apikey} ); -my $bugs = $bz->GetBugs( { ids => [ 283, 284 ] } ); +my @fields = qw( + id + summary + creation_time + last_change_time + creator + assigned_to + + status + resolution -my @fields = qw( - id - creation_time - last_change_time - creator - assigned_to - - status - resolution - - priority - severity - url - - blocks - depends_on - cc - - component - product - classification - version - - actual_time - estimated_time - remainig_time - deadline + priority + severity + url + + blocks + depends_on + cc + + component + product + classification + version + + actual_time + estimated_time + remainig_time + deadline ); my %fieldsMap = ( - id => 'bug_id', - creator => 'reporter', - status => 'bug_status', - severity => 'bug_severity', - blocks => 'blocked', - depends_on => 'dependson', - creation_time => 'creation_ts', + summary => 'short_desc', + id => 'bug_id', + creator => 'reporter', + status => 'bug_status', + severity => 'bug_severity', + blocks => 'blocked', + depends_on => 'dependson', + creation_time => 'creation_ts', last_change_time => 'delta_ts' ); -my $writer = XML::Writer->new( OUTPUT => \*STDOUT, ENCODING => 'utf-8' ); +local (*HIN); + +my $proc = start( [ 'saxon8', '-novw', '-', 'bug-list.xsl' ], + '<pipe', \*HIN, '>', \*STDOUT ) + or die "failed to create pipe: $!"; + +my $writer = XML::Writer->new( OUTPUT => \*HIN, ENCODING => 'utf-8' ); $writer->xmlDecl("UTF-8"); $writer->startTag("bugzilla"); -foreach my $bug ( @$bugs ) { - $writer->startTag("bug"); - foreach my $field ( @fields ) { - next unless $bug->{$field}; - - my $tagName = $fieldsMap{$field} || $field; - my @values = ref($bug->{$field}) && ref($bug->{$field}) eq 'ARRAY' ? @{$bug->{$field}} : $bug->{$field}; - - foreach my $v (@values) { - $writer->dataElement($tagName, $v); +my %visited; +my @queue = (283); + +while (@queue) { + @queue = grep not( $visited{$_}++ ), @queue; + + last unless @queue; + + print "#Fetching: ", join( ', ', @queue ), "\n"; + + my $bugs = $bz->GetBugs( { ids => \@queue } ); + + @queue = (); + + foreach my $bug (@$bugs) { + + push @queue, @{ $bug->{depends_on} } + if ( $bug->{depends_on} ); + + $writer->startTag("bug"); + foreach my $field (@fields) { + next unless $bug->{$field}; + + my $tagName = $fieldsMap{$field} || $field; + my @values = + ref( $bug->{$field} ) + && ref( $bug->{$field} ) eq 'ARRAY' + ? @{ $bug->{$field} } + : $bug->{$field}; + + foreach my $v (@values) { + $writer->dataElement( $tagName, $v ); + } } + $writer->endTag(); + } - $writer->endTag(); } $writer->endTag(); - +close HIN; +finish($proc); #xalan( -# -IN => "bug-list2.xml", -# -XSL => "bug-list.xsl", -# -URIRESOLVER => "org.apache.xml.resolver.tools.CatalogResolver", -# -ENTITYRESOLVER => "org.apache.xml.resolver.tools.CatalogResolver", -# -PARAM => (chargeset => "dev") +# in => \*OUT, +# out => \*STDOUT, +# params => [ +# +# ] #); sub xalan {