| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WWW::Bugzilla::BugTree; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
210544
|
use strict; |
|
|
3
|
|
|
|
|
23
|
|
|
|
3
|
|
|
|
|
74
|
|
|
4
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
93
|
|
|
5
|
3
|
|
|
3
|
|
1278
|
use Ref::Util qw( is_arrayref ); |
|
|
3
|
|
|
|
|
4338
|
|
|
|
3
|
|
|
|
|
183
|
|
|
6
|
3
|
|
|
3
|
|
51
|
use 5.012; |
|
|
3
|
|
|
|
|
9
|
|
|
7
|
3
|
|
|
3
|
|
1543
|
use Moo; |
|
|
3
|
|
|
|
|
28382
|
|
|
|
3
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Fetch a tree of bugzilla bugs blocking a bug |
|
10
|
|
|
|
|
|
|
our $VERSION = '0.08'; # VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has ua => ( |
|
14
|
|
|
|
|
|
|
is => 'ro', |
|
15
|
|
|
|
|
|
|
lazy => 1, |
|
16
|
|
|
|
|
|
|
default => sub { |
|
17
|
|
|
|
|
|
|
require LWP::UserAgent; |
|
18
|
|
|
|
|
|
|
my $ua = LWP::UserAgent->new; |
|
19
|
|
|
|
|
|
|
$ua->env_proxy; |
|
20
|
|
|
|
|
|
|
$ua; |
|
21
|
|
|
|
|
|
|
}, |
|
22
|
|
|
|
|
|
|
); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $default_url = $ENV{BUG_TREE_URL} // "https://landfill.bugzilla.org/bugzilla-4.2-branch"; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has url => ( |
|
28
|
|
|
|
|
|
|
is => 'ro', |
|
29
|
|
|
|
|
|
|
lazy => 1, |
|
30
|
|
|
|
|
|
|
default => sub { |
|
31
|
|
|
|
|
|
|
require URI; |
|
32
|
|
|
|
|
|
|
URI->new($default_url); |
|
33
|
|
|
|
|
|
|
}, |
|
34
|
|
|
|
|
|
|
coerce => sub { |
|
35
|
|
|
|
|
|
|
ref $_[0] ? $_[0] : do { require URI; URI->new($_[0] // $default_url) }, |
|
36
|
|
|
|
|
|
|
}, |
|
37
|
|
|
|
|
|
|
); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has _cache => ( |
|
40
|
|
|
|
|
|
|
is => 'ro', |
|
41
|
|
|
|
|
|
|
default => sub { { } }, |
|
42
|
|
|
|
|
|
|
init_arg => undef, |
|
43
|
|
|
|
|
|
|
); |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub fetch |
|
47
|
|
|
|
|
|
|
{ |
|
48
|
0
|
|
|
0
|
1
|
|
my($self, $bug_id) = @_; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
return $self->_cache->{$bug_id} |
|
51
|
0
|
0
|
|
|
|
|
if exists $self->_cache->{$bug_id}; |
|
52
|
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my $url = $self->url->clone; |
|
54
|
0
|
|
|
|
|
|
$url->path((do { my $path = $url->path; $path =~ s{/$}{}; $path }) . "/show_bug.cgi"); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
$url->query_form( |
|
56
|
|
|
|
|
|
|
id => $bug_id, |
|
57
|
|
|
|
|
|
|
ctype => 'xml', |
|
58
|
|
|
|
|
|
|
); |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
my $res = $self->ua->get($url); |
|
61
|
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
die $url . " " . $res->status_line |
|
63
|
|
|
|
|
|
|
unless $res->is_success; |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
require WWW::Bugzilla::BugTree::Bug; |
|
66
|
0
|
|
|
|
|
|
my $b = WWW::Bugzilla::BugTree::Bug->new( |
|
67
|
|
|
|
|
|
|
url => $url, |
|
68
|
|
|
|
|
|
|
res => $res, |
|
69
|
|
|
|
|
|
|
id => $bug_id, |
|
70
|
|
|
|
|
|
|
); |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
$self->_cache->{$bug_id} = $b; |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
my $dependson = $b->as_hashref->{bug}->{dependson}; |
|
75
|
0
|
0
|
|
|
|
|
$dependson = [] unless defined $dependson; |
|
76
|
0
|
0
|
|
|
|
|
$dependson = [ $dependson ] |
|
77
|
|
|
|
|
|
|
unless is_arrayref $dependson; |
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
@{ $b->children } = map { $self->fetch($_) } sort @$dependson; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
$b; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub clear_cache |
|
86
|
|
|
|
|
|
|
{ |
|
87
|
0
|
|
|
0
|
1
|
|
my($self) = @_; |
|
88
|
0
|
|
|
|
|
|
%{ $self->_cache } = (); |
|
|
0
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |