X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Debbugs%2FControl.pm;h=33db8816a2a28f5ac5de974b71cdac7f3eb5ed90;hb=c89a96b3d745f9ae157da11f8c86f45883fbeb5d;hp=6851656f49c6b4d4bde5c4c857cbb8584a2cde0a;hpb=2ca3d4b399934b4ee936f9a3f511b22fbcd48281;p=debbugs.git diff --git a/Debbugs/Control.pm b/Debbugs/Control.pm index 6851656..33db881 100644 --- a/Debbugs/Control.pm +++ b/Debbugs/Control.pm @@ -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)], @@ -99,6 +100,7 @@ BEGIN{ clone => [qw(clone_bug)], archive => [qw(bug_archive bug_unarchive), ], + limit => [qw(check_limit)], log => [qw(append_action_to_log), ], ); @@ -1589,7 +1591,7 @@ sub set_found { } # if the found we are adding matches any fixed # versions, remove them - my @temp = grep m{(^|/)\Q$sver\E}, keys %fixed_versions; + my @temp = grep m{(^|/)\Q$sver\E$}, keys %fixed_versions; delete $fixed_versions{$_} for @temp; $fixed_removed{$_} = 1 for @temp; } @@ -1613,7 +1615,7 @@ sub set_found { # in the case of removal, we only concern ourself with # the version passed, not the source version it maps # to - my @temp = grep m{(^|/)\Q$version\E}, keys %found_versions; + my @temp = grep m{(?:^|/)\Q$version\E$}, keys %found_versions; delete $found_versions{$_} for @temp; $found_removed{$_} = 1 for @temp; } @@ -2020,7 +2022,7 @@ sub set_merged { $new_locks += $n_locks; %data = %{$data}; @data = values %data; - if (not __check_limit(data => [@data], + if (not check_limit(data => [@data], exists $param{limit}?(limit => $param{limit}):(), transcript => $transcript, )) { @@ -2166,7 +2168,7 @@ sub set_merged { $locks--; } __end_control(%info); - for my $change (values %{$changes}, @{$disallowed_changes}) { + for my $change ((map {@{$_}} values %{$changes}), @{$disallowed_changes}) { print {$transcript} "$change->{field} of #$change->{bug} is '$change->{text_orig_value}' not '$change->{text_value}'\n"; } die "Unable to modify bugs so they could be merged"; @@ -2301,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->{$_} } } @@ -2317,6 +2319,17 @@ sub __calculate_merge_status{ @{$merge_status{"${_}_versions"}}{@{$data->{"${_}_versions"}}} = (1) x @{$data->{"${_}_versions"}}; } } + # if there is a non-source qualified version with a corresponding + # source qualified version, we only want to merge the source + # qualified version(s) + for (qw(fixed found)) { + my @unqualified_versions = grep {m{/}?0:1} keys %{$merge_status{"${_}_versions"}}; + for my $unqualified_version (@unqualified_versions) { + if (grep {m{/\Q$unqualified_version\E}} keys %{$merge_status{"${_}_versions"}}) { + delete $merge_status{"${_}_versions"}{$unqualified_version}; + } + } + } return (\%merge_status,$bugs_to_merge); } @@ -2371,6 +2384,10 @@ sub __calculate_merge_changes{ key => 'summary', options => [], }, + outlook => {func => \&outlook, + key => 'outlook', + options => [], + }, affects => {func => \&affects, key => 'package', options => [], @@ -2395,7 +2412,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'){ @@ -2652,23 +2669,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)}; @@ -2678,27 +2738,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})); @@ -2737,38 +2797,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, @@ -3618,7 +3678,7 @@ sub __begin_control { } } } - if (not __check_limit(data => \@data, + if (not check_limit(data => \@data, exists $param{limit}?(limit => $param{limit}):(), transcript => $transcript, )) { @@ -3685,9 +3745,9 @@ sub __end_control { } -=head2 __check_limit +=head2 check_limit - __check_limit(data => \@data, limit => $param{limit}); + check_limit(data => \@data, limit => $param{limit}); Checks to make sure that bugs match any limits; each entry of @data @@ -3704,9 +3764,9 @@ limit to succeed. =cut -sub __check_limit{ +sub check_limit{ my %param = validate_with(params => \@_, - spec => {data => {type => ARRAYREF|SCALAR, + spec => {data => {type => ARRAYREF|HASHREF, }, limit => {type => HASHREF|UNDEF, }, @@ -3798,7 +3858,9 @@ sub __message_body_template{ my $hole_var = {'&bugurl' => sub{"$_[0]: ". 'http://'.$config{cgi_domain}.'/'. - Debbugs::CGI::bug_url($_[0]); + Debbugs::CGI::bug_links(bug => $_[0], + links_only => 1, + ); } };