]> git.donarmstrong.com Git - debbugs.git/commitdiff
support setting limit in scripts/service
authorDon Armstrong <don@donarmstrong.com>
Fri, 19 Jun 2009 03:14:58 +0000 (20:14 -0700)
committerDon Armstrong <don@donarmstrong.com>
Fri, 19 Jun 2009 03:14:58 +0000 (20:14 -0700)
scripts/service

index 31f353ce2332c262432be887df60fb47f51e7d63..035ae819a64c39a7d90d2d82831041b12e669afa 100755 (executable)
@@ -122,6 +122,9 @@ print {$transcript} "Processing commands for $controlrequestaddr:\n\n";
 my $dl = 0;
 my %affected_packages;
 my %recipients;
+# this is the hashref which is passed to all control calls
+my %limit = ();
+
 
 my @common_control_options =
     (($dl > 0 ? (debug => $transcript):()),
@@ -135,6 +138,7 @@ my @common_control_options =
      message           => \@log,
      affected_packages => \%affected_packages,
      recipients        => \%recipients,
+     limit             => \%limit,
     );
 
 my $state= 'idle';
@@ -1080,12 +1084,38 @@ END
        my @pkgs = split /\s+/, $1;
        if (scalar(@pkgs) > 0) {
                %limit_pkgs = map { ($_, 1) } @pkgs;
+               $limit{package} = [@pkgs];
                print {$transcript} "Ignoring bugs not assigned to: " .
                        join(" ", keys(%limit_pkgs)) . "\n\n";
        } else {
                %limit_pkgs = ();
                print {$transcript} "Not ignoring any bugs.\n\n";
        }
+    } elsif (m/^limit\:?\s+(\S.*\S)\s*$/) {
+       $ok++;
+       my ($field,@options) = split /\s+/, $1;
+       $field = lc($field);
+       if ($field =~ /^(?:clear|unset|blank)$/) {
+           %limit = ();
+           print {$transcript} "Limit cleared.\n\n";
+       }
+       elsif (exists $Debbugs::Status::fields{$field} ) {
+           # %limit can actually contain regexes, but because they're
+           # not evaluated in Safe, DO NOT allow them through without
+           # fixing this.
+           $limit{$field} = [@options];
+           print {$transcript} "Limiting to bugs with field '$field' containing at least one of ".join(', ',map {qq('$_')} @options)."\n";
+           print {$transcript} "Limit currently set to ";
+           for my $limit_field (keys %limit) {
+               print {$transcript} "  '$limit_field':".join(', ',map {qq('$_')} @options)."\n";
+           }
+           print {$transcript} "\n";
+       }
+       else {
+           print {$transcript} "Limit key $field not understood. Stopping processing here.\n\n";
+           $errors++;
+           last;
+       }
     } elsif (m/^affects?\s+\#?(-?\d+)(?:\s+((?:[=+-])?)\s*(\S.*)?)?\s*$/i) {
        $ok++;
         $ref = $1;