]> git.donarmstrong.com Git - debbugs.git/commitdiff
Add support for outlook in control
authorDon Armstrong <don@donarmstrong.com>
Sat, 14 Jul 2012 21:37:56 +0000 (14:37 -0700)
committerDon Armstrong <don@donarmstrong.com>
Sat, 14 Jul 2012 21:37:56 +0000 (14:37 -0700)
Debbugs/Control.pm
Debbugs/Control/Service.pm
Debbugs/Status.pm
t/06_mail_handling.t

index 592c31572f9c0906e3fbf7789e7bd9057890a4f9..237bcd63736fb563abdbb77c92a71e453fe0ccd9 100644 (file)
@@ -87,6 +87,7 @@ BEGIN{
                     severity => [qw(set_severity)],
                     affects => [qw(affects)],
                     summary => [qw(summary)],
+                    outlook => [qw(outlook)],
                     owner   => [qw(owner)],
                     title   => [qw(set_title)],
                     forward => [qw(set_forwarded)],
@@ -2302,7 +2303,7 @@ sub __calculate_merge_status{
        # look like. However, if merge is set, tags, fixed and found
        # are merged.
        if ($data->{bug_num} == $master_bug) {
-           for (qw(package forwarded severity blocks blockedby done owner summary affects)) {
+           for (qw(package forwarded severity blocks blockedby done owner summary outlook affects)) {
                $merge_status{$_} = $data->{$_}
            }
        }
@@ -2372,6 +2373,10 @@ sub __calculate_merge_changes{
                           key  => 'summary',
                           options => [],
                          },
+            outlook   => {func => \&outlook,
+                          key  => 'outlook',
+                          options => [],
+                         },
             affects   => {func => \&affects,
                           key  => 'package',
                           options => [],
@@ -2396,7 +2401,7 @@ sub __calculate_merge_changes{
                                allowed => 1,
                               },
            );
-       for my $field (qw(forwarded severity blocks blockedby done owner summary affects package fixed_versions found_versions keywords)) {
+       for my $field (qw(forwarded severity blocks blockedby done owner summary outlook affects package fixed_versions found_versions keywords)) {
            # if the ideal bug already has the field set properly, we
            # continue on.
            if ($field eq 'keywords'){
@@ -2653,23 +2658,66 @@ Otherwise, sets summary to the value passed.
 
 
 sub summary {
-    my %param = validate_with(params => \@_,
+    # outlook and summary are exactly the same, basically
+    return _summary('summary',@_);
+}
+
+=head1 OUTLOOK FUNCTIONS
+
+=head2 outlook
+
+     eval {
+           outlook(bug          => $ref,
+                   transcript   => $transcript,
+                   ($dl > 0 ? (debug => $transcript):()),
+                   requester    => $header{from},
+                   request_addr => $controlrequestaddr,
+                   message      => \@log,
+                    affected_packages => \%affected_packages,
+                   recipients   => \%recipients,
+                   outlook      => undef,
+                   );
+       };
+       if ($@) {
+           $errors++;
+           print {$transcript} "Failed to mark $ref with outlook foo: $@";
+       }
+
+Handles all setting of outlook fields
+
+If outlook is undef, unsets the outlook
+
+If outlook is 0, sets the outlook to the first paragraph contained in
+the message passed.
+
+If outlook is a positive integer, sets the outlook to the message specified.
+
+Otherwise, sets outlook to the value passed.
+
+=cut
+
+
+sub outlook {
+    return _summary('outlook',@_);
+}
+
+sub _summary {
+    my ($cmd,@params) = @_;
+    my %param = validate_with(params => \@params,
                              spec   => {bug => {type   => SCALAR,
                                                 regex  => qr/^\d+$/,
                                                },
                                         # specific options here
-                                        summary => {type => SCALAR|UNDEF,
-                                                    default => 0,
-                                                   },
+                                        $cmd , {type => SCALAR|UNDEF,
+                                                default => 0,
+                                               },
                                         %common_options,
                                         %append_action_options,
                                        },
                             );
-# croak "summary must be numeric or undef" if
-#      defined $param{summary} and not $param{summary} =~ /^\d+/;
     my %info =
        __begin_control(%param,
-                       command  => 'summary'
+                       command  => $cmd,
                       );
     my ($debug,$transcript) =
        @info{qw(debug transcript)};
@@ -2679,27 +2727,27 @@ sub summary {
     my $summary = '';
     my $summary_msg = '';
     my $action = '';
-    if (not defined $param{summary}) {
+    if (not defined $param{$cmd}) {
         # do nothing
-        print {$debug} "Removing summary fields\n";
-        $action = 'Removed summary';
+        print {$debug} "Removing $cmd fields\n";
+        $action = "Removed $cmd";
     }
-    elsif ($param{summary} =~ /^\d+$/) {
+    elsif ($param{$cmd} =~ /^\d+$/) {
         my $log = [];
         my @records = Debbugs::Log::read_log_records(bug_num => $param{bug});
-        if ($param{summary} == 0) {
+        if ($param{$cmd} == 0) {
              $log = $param{message};
              $summary_msg = @records + 1;
         }
         else {
-             if (($param{summary} - 1 ) > $#records) {
-                  die "Message number '$param{summary}' exceeds the maximum message '$#records'";
+             if (($param{$cmd} - 1 ) > $#records) {
+                  die "Message number '$param{$cmd}' exceeds the maximum message '$#records'";
              }
-             my $record = $records[($param{summary} - 1 )];
+             my $record = $records[($param{$cmd} - 1 )];
              if ($record->{type} !~ /incoming-recv|recips/) {
-                  die "Message number '$param{summary}' is a invalid message type '$record->{type}'";
+                  die "Message number '$param{$cmd}' is a invalid message type '$record->{type}'";
              }
-             $summary_msg = $param{summary};
+             $summary_msg = $param{$cmd};
              $log = [$record->{text}];
         }
         my $p_o = Debbugs::MIME::parse(join('',@{$log}));
@@ -2738,38 +2786,38 @@ sub summary {
              next if $in_pseudoheaders;
              $paragraph .= $line ." \n";
         }
-        print {$debug} "Summary is going to be '$paragraph'\n";
+        print {$debug} ucfirst($cmd)." is going to be '$paragraph'\n";
         $summary = $paragraph;
         $summary =~ s/[\n\r]/ /g;
         if (not length $summary) {
-             die "Unable to find summary message to use";
+             die "Unable to find $cmd message to use";
         }
         # trim off a trailing spaces
         $summary =~ s/\ *$//;
     }
     else {
-       $summary = $param{summary};
+       $summary = $param{$cmd};
     }
     for my $data (@data) {
-        print {$debug} "Going to change summary\n";
+        print {$debug} "Going to change $cmd\n";
         if (((not defined $summary or not length $summary) and
-             (not defined $data->{summary} or not length $data->{summary})) or
-            $summary eq $data->{summary}) {
-            print {$transcript} "Ignoring request to change the summary of bug $param{bug} to the same value\n";
+             (not defined $data->{$cmd} or not length $data->{$cmd})) or
+            $summary eq $data->{$cmd}) {
+            print {$transcript} "Ignoring request to change the $cmd of bug $param{bug} to the same value\n";
             next;
         }
         if (length $summary) {
-             if (length $data->{summary}) {
-                  $action = "Summary replaced with message bug $param{bug} message $summary_msg";
+             if (length $data->{$cmd}) {
+                  $action = ucfirst($cmd)." replaced with message bug $param{bug} message $summary_msg";
              }
              else {
-                  $action = "Summary recorded from message bug $param{bug} message $summary_msg";
+                  $action = ucfirst($cmd)." recorded from message bug $param{bug} message $summary_msg";
              }
         }
         my $old_data = dclone($data);
-        $data->{summary} = $summary;
+        $data->{$cmd} = $summary;
         append_action_to_log(bug => $data->{bug_num},
-                             command => 'summary',
+                             command => $cmd,
                              old_data => $old_data,
                              new_data => $data,
                              get_lock => 0,
index 239f6539977ffea193d0276178d71bfaadec4dad..fcd5d70b7805d8ab56feae46fafca63fd0dda386 100644 (file)
@@ -149,6 +149,7 @@ my %control_grammar =
      limit => qr/(?i)^limit\:?\s+(\S.*\S)\s*$/,
      affects => qr/(?i)^affects?\s+\#?(-?\d+)(?:\s+((?:[=+-])?)\s*(\S.*)?)?\s*$/,
      summary => qr/(?i)^summary\s+\#?(-?\d+)\s*(\d+|)\s*$/,
+     outlook => qr/(?i)^outlook\s+\#?(-?\d+)\s*(\d+|)\s*$/,
      owner => qr/(?i)^owner\s+\#?(-?\d+)\s+((?:\S.*\S)|\!)\s*$/,
      noowner => qr/(?i)^noowner\s+\#?(-?\d+)\s*$/,
      unarchive => qr/(?i)^unarchive\s+#?(\d+)$/,
@@ -655,6 +656,19 @@ sub control_line {
            print {$transcript} "Failed to give $ref a summary: ".cleanup_eval_fail($@,$debug)."\n";
        }
 
+    } elsif ($ctl eq 'outlook') {
+       my $outlook_msg = length($matches[1])?$matches[1]:undef;
+       eval {
+           outlook(@{$param{common_control_options}},
+                   bug          => $ref,
+                   outlook      => $outlook_msg,
+                  );
+       };
+       if ($@) {
+           $errors++;
+           print {$transcript} "Failed to give $ref a outlook: ".cleanup_eval_fail($@,$debug)."\n";
+       }
+
     } elsif ($ctl eq 'owner') {
        my $newowner = $matches[1];
        if ($newowner eq '!') {
index cf6918aa86136325b46444df25a7bd946421ff13..9416a31ba3ce9e26adc6f0ef2cdbccf376c6d5c5 100644 (file)
@@ -108,6 +108,7 @@ our %fields = (originator     => 'submitter',
               blockedby      => 'blocked-by',
              unarchived     => 'unarchived',
              summary        => 'summary',
+             outlook        => 'outlook',
              affects        => 'affects',
              );
 
index 1cc842c2b378716e57a2dcd5bf032f47b427bff3..cc37feb35ede4248c3b70f52b59ea86f68dfa2ed 100644 (file)
@@ -1,7 +1,7 @@
 # -*- mode: cperl;-*-
 # $Id: 05_mail.t,v 1.1 2005/08/17 21:46:17 don Exp $
 
-use Test::More tests => 117;
+use Test::More tests => 123;
 
 use warnings;
 use strict;
@@ -259,6 +259,16 @@ my @control_commands =
                       status_key => 'summary',
                       status_value => '',
                      },
+      outlook      => {command => 'outlook',
+                      value   => '5',
+                      status_key => 'outlook',
+                      status_value => 'This is a silly bug',
+                     },
+      nooutlook    => {command => 'outlook',
+                      value   => '',
+                      status_key => 'outlook',
+                      status_value => '',
+                     },
       affects      => {command => 'affects',
                       value   => 'foo',
                       status_key => 'affects',