From: Don Armstrong Date: Tue, 3 Jul 2007 08:20:11 +0000 (-0700) Subject: * Avoid warnings on buggy X-Git-Tag: release/2.6.0~528^2~2 X-Git-Url: https://git.donarmstrong.com/?p=debbugs.git;a=commitdiff_plain;h=1103c0f0e2b75f6e7bc04c0e3432251895d3a705 * Avoid warnings on buggy * Handle non-existant packages and logs without complaining * Don't output warnings on broken email addresses --- diff --git a/Debbugs/Common.pm b/Debbugs/Common.pm index 9317d88..abe041d 100644 --- a/Debbugs/Common.pm +++ b/Debbugs/Common.pm @@ -206,7 +206,10 @@ sub getparsedaddrs { return () unless defined $addr; return wantarray?@{$_parsedaddrs{$addr}}:$_parsedaddrs{$addr}[0] if exists $_parsedaddrs{$addr}; - @{$_parsedaddrs{$addr}} = Mail::Address->parse($addr); + { + no warnings; + @{$_parsedaddrs{$addr}} = Mail::Address->parse($addr); + } return wantarray?@{$_parsedaddrs{$addr}}:$_parsedaddrs{$addr}[0]; } diff --git a/Debbugs/Packages.pm b/Debbugs/Packages.pm index e423bdd..222bd41 100644 --- a/Debbugs/Packages.pm +++ b/Debbugs/Packages.pm @@ -312,6 +312,7 @@ sub get_versions{ my $f_ver = $ver; if ($param{source}) { ($f_ver) = makesourceversions($package,$arch,$ver); + next unless defined $f_ver; } if ($param{time}) { $versions{$f_ver} = max($versions{$f_ver}||0,$version->{$dist}{$arch}{$ver}); diff --git a/Debbugs/Status.pm b/Debbugs/Status.pm index 5d71ebf..7dedda2 100644 --- a/Debbugs/Status.pm +++ b/Debbugs/Status.pm @@ -627,11 +627,15 @@ sub bug_archiveable{ return $cannot_archive if not defined $status->{done} or not length $status->{done}; # If we just are checking if the bug can be archived, we'll not even bother # checking the versioning information if the bug has been -done for less than 28 days. + my $log_file = getbugcomponent($_,'log'); + if (not defined $log_file) { + print STDERR "Cannot archive $param{bug} because the log doesn't exists\n" if $DEBUG; + } if (not $param{days_until} and not $param{ignore_time} and $config{remove_age} > - -M getbugcomponent($param{bug},'log') + -M $log_file ) { - print STDERR "Cannot arhive $param{bug} because of time\n" if $DEBUG; + print STDERR "Cannot archive $param{bug} because of time\n" if $DEBUG; return $cannot_archive; } # At this point, we have to get the versioning information for this bug. @@ -707,7 +711,7 @@ sub bug_archiveable{ return $param{days_until}?0:1; } # 6. at least 28 days have passed since the last action has occured or the bug was closed - my $age = ceil(max(map {$config{remove_age} - -M getbugcomponent($_,'log')} + my $age = ceil(max(map {$config{remove_age} - -M $log_file} $param{bug}, split / /, $status->{mergedwith} ) ); @@ -1087,23 +1091,31 @@ sub buggy { ); } if ($param{version} !~ m{/}) { - $param{version} = makesourceversions($param{package},undef, - $param{version} - ); + my ($version) = makesourceversions($param{package},undef, + $param{version} + ); + $param{version} = $version if defined $version; } # Figure out which source packages we need my %sources; @sources{map {m{(.+)/}; $1} @found} = (1) x @found; @sources{map {m{(.+)/}; $1} @fixed} = (1) x @fixed; - @sources{map {m{(.+)/}; $1} $param{version}} = 1; + @sources{map {m{(.+)/}; $1} $param{version}} = 1 if + $param{version} =~ m{/}; my $version; if (not defined $param{version_cache} or not exists $param{version_cache}{join(',',sort keys %sources)}) { $version = Debbugs::Versions->new(\&Debbugs::Versions::Dpkg::vercmp); foreach my $source (keys %sources) { my $srchash = substr $source, 0, 1; - my $version_fh = IO::File->new("$config{version_packages_dir}/$srchash/$source", 'r') or - warn "Unable to open $config{version_packages_dir}/$srchash/$source: $!" and next; + my $version_fh = IO::File->new("$config{version_packages_dir}/$srchash/$source", 'r'); + if (not defined $version_fh) { + # We only want to warn if it's a package which actually has a maintainer + my $maints = getmaintainers(); + next if not exists $maints->{$source}; + warn "Unable to open $config{version_packages_dir}/$srchash/$source: $!"; + next; + } $version->load($version_fh); } if (defined $param{version_cache}) {