Mercurial > pub > buggler
diff translate.pl @ 10:14a966369278
working version of exporting bugs from bugzilla in tj3 format (without bookings)
author | cin |
---|---|
date | Mon, 07 Sep 2015 01:37:11 +0300 |
parents | cc7244ab1b9f |
children | 4eb9fdf4efa9 |
line wrap: on
line diff
--- a/translate.pl Sat Sep 05 22:01:12 2015 +0300 +++ b/translate.pl Mon Sep 07 01:37:11 2015 +0300 @@ -1,21 +1,13 @@ #!/usr/bin/perl -w use IMPL::require { - BzClient => 'Benzin::Bugzilla::XmlRpcClient', - Bug => 'Benzin::Bugzilla::Bug' + BzClient => 'Benzin::Bugzilla::XmlRpcClient', + BugWriter => 'Benzin::Bugzilla::XmlWriter' }; use YAML::XS qw(LoadFile Dump); use XML::Writer; use IPC::Run qw(start finish); -our @ClassPath = qw( - /usr/share/java/xalan-j2-serializer.jar - /usr/share/java/xalan-j2.jar - /usr/share/java/xerces-j2.jar - /usr/share/java/xml-commons-resolver.jar - . -); - my $config = LoadFile("config.yaml"); if ( !( $config->{bugzilla}{url} =~ /\/$/ ) ) { @@ -27,40 +19,30 @@ apikey => $config->{bugzilla}{apikey} ); +my $bugs = $config->{bugzilla}{bugs} or die "No bugs specified"; +$bugs = [$bugs] unless ref $bugs eq 'ARRAY'; + local (*HIN); -my $proc = start( [ 'saxon8', '-novw', '-', 'bug-list.xsl' ], - '<pipe', \*HIN, '>', \*STDOUT ) - or die "failed to create pipe: $!"; +my $proc = start( + [ 'saxon8', '-novw', '-', 'bug-list.xsl' ], + #[ 'cat' ], + '<pipe', \*HIN, '>', \*STDOUT +) or die "failed to create pipe: $!"; + +binmode *HIN, ":encoding(utf-8)"; +my $writer = + BugWriter->new( OUTPUT => *HIN, DATA_INDENT => 2, DATA_MODE => 'on' ); eval { my %visited; - my @queue = (283); - my @fetched; - while (@queue) { - @queue = grep not( $visited{$_}++ ), @queue; - - last unless @queue; - - print "#Fetching: ", join( ', ', @queue ), "\n"; - - my $bugs = $bz->GetBugs( { ids => \@queue } ); - @queue = (); + my $fetched = $bz->GetBugsHierarchy( { ids => [283] } ); - foreach my $bug (@$bugs) { + $bz->PopulateBugsComments($fetched); + $bz->PopulateBugsHistory($fetched); - push @queue, @{ $bug->{depends_on} } - if ( $bug->{depends_on} ); - push @fetched, $bug; - } - } - print Dump( \@fetched ); - - $bz->PopulateBugsWithComments( \@fetched ); - $bz->PopulateBugsHistory( \@fetched ); - - print Dump( [ map $_->GetTimeReports(0.25), @fetched ] ); + $writer->WriteBugList($fetched); }; warn Dump($@) and die $@ if $@;