spec => {bug_num => {type => SCALAR,
optional => 1,
},
- logfh => {type => SCALAR,
+ logfh => {type => HANDLE,
optional => 1,
},
log_name => {type => SCALAR,
that file. Throws exceptions using die(), so you may want to wrap this in an
eval().
+Uses exactly the same options as Debbugs::Log::new
+
=cut
-sub read_log_records (*)
+sub read_log_records
{
- my $logfh = shift;
+ my %param;
+ if (@_ == 1) {
+ ($param{logfh}) = @_;
+ }
+ else {
+ %param = validate_with(params => \@_,
+ spec => {bug_num => {type => SCALAR,
+ optional => 1,
+ },
+ logfh => {type => HANDLE,
+ optional => 1,
+ },
+ log_name => {type => SCALAR,
+ optional => 1,
+ },
+ }
+ );
+ }
+ if (grep({exists $param{$_} and defined $param{$_}} qw(bug_num logfh log_name)) ne 1) {
+ croak "Exactly one of bug_num, logfh, or log_name must be passed and must be defined";
+ }
my @records;
- my $reader = Debbugs::Log->new($logfh);
+ my $reader = Debbugs::Log->new(%param);
while (defined(my $record = $reader->read_record())) {
push @records, $record;
}
}
for (qw(to cc bcc)) {
if ($param{$_}) {
- return @{$final_recipients{$_}};
+ if (exists $final_recipients{$_}) {
+ return @{$final_recipients{$_}||[]};
+ }
+ return ();
}
}
return %final_recipients;
# Add log last modified time
$data{log_modified} = (stat($log))[9];
$data{location} = $location;
- $data{archived} = $location eq 'archive';
+ $data{archived} = (defined($location) and ($location eq 'archive'))?1:0;
$data{bug_num} = $param{bug};
return \%data;
$output = q(<span>Owned by: ).package_links(owner=>$status{owner}).q(;</span>);
}
$output;
-}
-<span>Severity: {my $output = $status{severity};
+}<span>Severity: {my $output = $status{severity};
if (isstrongseverity($status{severity})) {
$output = q(<em class="severity">).$status{severity}.q(</em>);
}
$output .= q(<span>Merged with ).join(qq(,\n),bug_links(bug=>$status{mergedwith_array})).qq(;</span>\n);
}
$output;
-}
-{my $output = '';
+}{my $output = '';
if (@{$status{found_versions}} or @{$status{fixed_versions}}) {
$output .= '<a href="'.
version_url(package => $status{package},
$output .= qq(</a>);
}
$output;
-}
-{ my $output = '';
+}{ my $output = '';
+ if (length($status{forwarded})) {
+ $output = "<span><strong>Forwarded</strong> to " .
+ join(', ',
+ map {maybelink($_)}
+ split /\,\s+/,$status{forwarded}
+ ).";</span>\n";
+ }
+ $output;
+}{ my $output = '';
if (length($status{done})) {
$output .= q(<span><strong>Done:</strong> ).html_escape($status{done}).q(;</span> )
}
$output;
-}
-{ my $output = '';
+}{ my $output = '';
if (@{$status{blockedby_array}}) {
$output .= q(<span>Fix blocked by ).
join(q(, ),