]> git.donarmstrong.com Git - debbugs.git/blobdiff - Debbugs/Bugs.pm
merge changes from dla source
[debbugs.git] / Debbugs / Bugs.pm
index 848931f79b8fcca9799324a814630ee2d77666a8..9bfd4ae3c620d0ccc9678212f5ddd18bf783d5e3 100644 (file)
@@ -90,6 +90,8 @@ for limited regular expressions, and/or more complex expressions.
 
 =item owner -- owner of the bug
 
+=item correspondent -- address of someone who sent mail to the log
+
 =item dist -- distribution (I don't know about this one yet)
 
 =item bugs -- list of bugs to search within
@@ -177,6 +179,9 @@ sub get_bugs{
                                          dist      => {type => SCALAR|ARRAYREF,
                                                        optional => 1,
                                                       },
+                                         correspondent => {type => SCALAR|ARRAYREF,
+                                                           optional => 1,
+                                                          },
                                          function  => {type => CODEREF,
                                                        optional => 1,
                                                       },
@@ -290,7 +295,7 @@ sub newest_bug {
      my $next_number = <$nn_fh>;
      close $nn_fh;
      chomp $next_number;
-     return $next_number+0;
+     return $next_number-1;
 }
 
 =head2 bug_filter
@@ -299,14 +304,16 @@ sub newest_bug {
 
 Allows filtering bugs on commonly used criteria
 
+
+
 =cut
 
 sub bug_filter {
      my %param = validate_with(params => \@_,
-                              spec   => {bug => {type  => SCALAR,
-                                                 regex => qr/^\d+$/,
-                                                },
-                                         status => {type => HASHREF,
+                              spec   => {bug    => {type => ARRAYREF|SCALAR,
+                                                    optional => 1,
+                                                   },
+                                         status => {type => HASHREF|ARRAYREF,
                                                     optional => 1,
                                                    },
                                          seen_merged => {type => HASHREF,
@@ -334,6 +341,9 @@ sub bug_filter {
         not defined $param{seen_merged}) {
          croak "repeat_merged false requires seen_merged to be passed";
      }
+     if (not exists $param{bug} and not exists $param{status}) {
+        croak "one of bug or status must be passed";
+     }
 
      if (not exists $param{status}) {
          my $location = getbuglocation($param{bug}, 'summary');
@@ -402,6 +412,9 @@ sub get_bugs_by_idx{
                                          bugs      => {type => SCALAR|ARRAYREF,
                                                        optional => 1,
                                                       },
+                                         correspondent => {type => SCALAR|ARRAYREF,
+                                                           optional => 1,
+                                                          },
                                          usertags  => {type => HASHREF,
                                                        optional => 1,
                                                       },
@@ -415,20 +428,13 @@ sub get_bugs_by_idx{
      my @packages = __handle_pkg_src_and_maint(map {exists $param{$_}?($_,$param{$_}):()}
                                               qw(package src maint)
                                              );
-     my %usertag_bugs;
-     if (exists $param{tag} and exists $param{usertags}) {
-         # This complex slice makes a hash with the bugs which have the
-          # usertags passed in $param{tag} set.
-         @usertag_bugs{make_list(@{$param{usertags}}{make_list($param{tag})})
-                       } = (1) x make_list(@{$param{usertags}}{make_list($param{tag})});
-     }
      if (exists $param{package} or
         exists $param{src} or
         exists $param{maint}) {
          delete @param{qw(maint src)};
          $param{package} = [@packages];
      }
-     my $keys = keys(%param) - 1;
+     my $keys = grep {$_ !~ /^(archive|usertags|bugs)$/} keys(%param);
      die "Need at least 1 key to search by" unless $keys;
      my $arc = $param{archive} ? '-arc':'';
      my %idx;
@@ -440,13 +446,20 @@ sub get_bugs_by_idx{
               or die "Unable to open $index: $!";
          my %bug_matching = ();
          for my $search (make_list($param{$key})) {
-              next unless defined $idx{$search};
-              for my $bug (keys %{$idx{$search}}) {
+              for my $bug (keys %{$idx{$search}||{}}) {
                    next if $bug_matching{$bug};
                    # increment the number of searches that this bug matched
                    $bugs{$bug}++;
                    $bug_matching{$bug}=1;
               }
+              if ($search ne lc($search)) {
+                   for my $bug (keys %{$idx{lc($search)}||{}}) {
+                        next if $bug_matching{$bug};
+                        # increment the number of searches that this bug matched
+                        $bugs{$bug}++;
+                        $bug_matching{$bug}=1;
+                   }
+              }
          }
          if ($key eq 'tag' and exists $param{usertags}) {
               for my $bug (make_list(grep {defined $_ } @{$param{usertags}}{make_list($param{tag})})) {
@@ -498,10 +511,13 @@ sub get_bugs_flatfile{
                                          tag       => {type => SCALAR|ARRAYREF,
                                                        optional => 1,
                                                       },
+                                         owner     => {type => SCALAR|ARRAYREF,
+                                                       optional => 1,
+                                                      },
+                                         correspondent => {type => SCALAR|ARRAYREF,
+                                                           optional => 1,
+                                                          },
 # not yet supported
-#                                        owner     => {type => SCALAR|ARRAYREF,
-#                                                      optional => 1,
-#                                                     },
 #                                        dist      => {type => SCALAR|ARRAYREF,
 #                                                      optional => 1,
 #                                                     },
@@ -544,11 +560,23 @@ sub get_bugs_flatfile{
          delete @param{qw(maint src)};
          $param{package} = [@packages];
      }
+     my $grep_bugs = 0;
+     my %bugs;
+     if (exists $param{bugs}) {
+         $bugs{$_} = 1 for make_list($param{bugs});
+         $grep_bugs = 1;
+     }
+     if (exists $param{owner} or exists $param{correspondent}) {
+         $bugs{$_} = 1 for get_bugs_by_idx(exists $param{correspondent}?(correspondent => $param{correspondent}):(),
+                                           exists $param{owner}?(owner => $param{owner}):(),
+                                          );
+         $grep_bugs = 1;
+     }
      my @bugs;
      while (<$flatfile>) {
          next unless m/^(\S+)\s+(\d+)\s+(\d+)\s+(\S+)\s+\[\s*([^]]*)\s*\]\s+(\w+)\s+(.*)$/;
          my ($pkg,$bug,$time,$status,$submitter,$severity,$tags) = ($1,$2,$3,$4,$5,$6,$7);
-         next if exists $param{bugs} and not grep {$bug == $_} make_list($param{bugs});
+         next if $grep_bugs and not exists $bugs{$bug};
          if (exists $param{package}) {
               my @packages = splitpackages($pkg);
               next unless grep { my $pkg_list = $_;
@@ -670,6 +698,7 @@ my %field_match = (
     },
     'severity' => \&__exact_field_match,
     'pending' => \&__exact_field_match,
+    'package' => \&__exact_field_match,
     'originator' => \&__contains_field_match,
     'forwarded' => \&__contains_field_match,
     'owner' => \&__contains_field_match,