]> git.donarmstrong.com Git - debbugs.git/blobdiff - Debbugs/Control.pm
Allow the default sendmail options to be specified in the config file;
[debbugs.git] / Debbugs / Control.pm
index 5fdba0650304707f64db1103e13ffb01bd03978d..d994170bb0f24fa6c5f72cd525ebb505556f64a2 100644 (file)
@@ -107,7 +107,7 @@ BEGIN{
 
 use Debbugs::Config qw(:config);
 use Debbugs::Common qw(:lock buglog :misc get_hashname);
-use Debbugs::Status qw(bug_archiveable :read :hook writebug splitpackages split_status_fields);
+use Debbugs::Status qw(bug_archiveable :read :hook writebug splitpackages split_status_fields get_bug_status);
 use Debbugs::CGI qw(html_escape);
 use Debbugs::Log qw(:misc);
 use Debbugs::Recipients qw(:add);
@@ -319,10 +319,10 @@ sub set_blocks {
            join(', ',grep {$_ !~ /^\d+$/} make_list($param{block}));
     }
     my $mode = 'set';
-    if (exists $param{add}) {
+    if ($param{add}) {
        $mode = 'add';
     }
-    elsif (exists $param{remove}) {
+    elsif ($param{remove}) {
        $mode = 'remove';
     }
 
@@ -351,7 +351,7 @@ sub set_blocks {
            $ok_blockers{$blocker} = 1;
            my @merged_bugs;
            push @merged_bugs, make_list($data->{mergedwith});
-           $ok_blockers{@merged_bugs} = (1) x @merged_bugs if @merged_bugs;
+           @ok_blockers{@merged_bugs} = (1) x @merged_bugs if @merged_bugs;
        }
        else {
            $bad_blockers{$blocker} = 1;
@@ -440,7 +440,7 @@ sub set_blocks {
        push @changed, 'removed blocking bug(s) of '.$data->{bug_num}.': '.english_join([keys %removed_blockers]) if keys %removed_blockers;
        $action = ucfirst(join ('; ',@changed)) if @changed;
        if (not @changed) {
-           print {$transcript} "Ignoring request to alter tags of bug #$data->{bug_num} to the same tags previously set\n"
+           print {$transcript} "Ignoring request to alter blocking bugs of bug #$data->{bug_num} to the same blocks previously set\n"
                unless __internal_request();
            next;
        }
@@ -2697,6 +2697,7 @@ sub __begin_control {
     }
     if (not __check_limit(data => \@data,
                          exists $param{limit}?(limit => $param{limit}):(),
+                         transcript => $transcript,
                         )) {
        die "limit failed for bugs: ".join(', ',map {$_->{bug_num}} @data);
     }
@@ -2784,6 +2785,9 @@ sub __check_limit{
                                                  },
                                         limit => {type => HASHREF|UNDEF,
                                                  },
+                                        transcript  => {type => SCALARREF|HANDLE,
+                                                        optional => 1,
+                                                       },
                                        },
                             );
     my @data = make_list($param{data});
@@ -2792,21 +2796,31 @@ sub __check_limit{
        not keys %{$param{limit}}) {
        return 1;
     }
+    my $transcript = globify_scalar(exists $param{transcript}?$param{transcript}:undef);
+    my $going_to_fail = 0;
     for my $data (@data) {
+       $data = split_status_fields(get_bug_status(bug => $data->{bug_num},
+                                                  status => dclone($data),
+                                                 ));
        for my $field (keys %{$param{limit}}) {
            next unless exists $param{limit}{$field};
            my $match = 0;
-           for my $limit (make_list($param{limit}{$field})) {
+           my @data_fields = make_list($data->{$field});
+LIMIT:     for my $limit (make_list($param{limit}{$field})) {
                if (not ref $limit) {
-                   if ($data->{$field} eq $limit) {
-                       $match = 1;
-                       last;
+                   for my $data_field (@data_fields) {
+                       if ($data_field eq $limit) {
+                           $match = 1;
+                           last LIMIT;
+                       }
                    }
                }
                elsif (ref($limit) eq 'Regexp') {
-                   if ($data->{$field} =~ $limit) {
-                       $match = 1;
-                       last;
+                   for my $data_field (@data_fields) {
+                       if ($data_field =~ $limit) {
+                           $match = 1;
+                           last LIMIT;
+                       }
                    }
                }
                else {
@@ -2814,11 +2828,14 @@ sub __check_limit{
                }
            }
            if (not $match) {
-               return 0;
+               $going_to_fail = 1;
+               print {$transcript} qq($field: ).join(', ',map{qq("$_")} make_list($data->{$field})).
+                   "' does not match at least one of ".
+                   join(', ',map {ref($_)?'(regex)':qq("$_")} make_list($param{limit}{$field}))."\n";
            }
        }
     }
-    return 1;
+    return $going_to_fail?0:1;
 }