]> git.donarmstrong.com Git - debbugs.git/commitdiff
* Avoid warnings on buggy
authorDon Armstrong <don@donarmstrong.com>
Tue, 3 Jul 2007 08:20:11 +0000 (01:20 -0700)
committerDon Armstrong <don@donarmstrong.com>
Tue, 3 Jul 2007 08:20:11 +0000 (01:20 -0700)
 * Handle non-existant packages and logs without complaining
 * Don't output warnings on broken email addresses

Debbugs/Common.pm
Debbugs/Packages.pm
Debbugs/Status.pm

index 9317d880ca6f683eae00bffafe0ce73d17bf71a9..abe041d672874e595882e0a378013f4de4e3da99 100644 (file)
@@ -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];
 }
 
index e423bdd019c8387477d1abfd71d0b4f9a35c7048..222bd41a60b716b8c3e4d0bbcc5608453ee355ae 100644 (file)
@@ -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});
index 5d71ebf57a4494d37c6728e4909aac4469b439d2..7dedda2de548fcb8b098a20b5f4d30012004be1f 100644 (file)
@@ -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}) {