X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Debbugs%2FControl.pm;h=c681916ab98f515fe784c08e51a88b65c8d75a4c;hb=86651d1b3a63c99071943bf26b0d822324ce55a0;hp=924e7d4de5518c7e49fc80caf8fc9ef18aa6b207;hpb=73937d35513a2fc3cb249dec379ce4e6db3c5979;p=debbugs.git diff --git a/Debbugs/Control.pm b/Debbugs/Control.pm index 924e7d4..c681916 100644 --- a/Debbugs/Control.pm +++ b/Debbugs/Control.pm @@ -99,6 +99,7 @@ BEGIN{ clone => [qw(clone_bug)], archive => [qw(bug_archive bug_unarchive), ], + limit => [qw(check_limit)], log => [qw(append_action_to_log), ], ); @@ -108,7 +109,7 @@ BEGIN{ } use Debbugs::Config qw(:config); -use Debbugs::Common qw(:lock buglog :misc get_hashname sort_versions); +use Debbugs::Common qw(:lock buglog :misc get_hashname sort_versions :utf8); use Debbugs::Status qw(bug_archiveable :read :hook writebug new_bug splitpackages split_status_fields get_bug_status); use Debbugs::CGI qw(html_escape); use Debbugs::Log qw(:misc :write); @@ -132,6 +133,7 @@ use POSIX qw(strftime); use Storable qw(dclone nfreeze); use List::Util qw(first max); +use Encode qw(encode_utf8); use Carp; @@ -459,8 +461,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 blocking bugs of bug #$data->{bug_num} to the same blocks previously set\n" - unless __internal_request(); + print {$transcript} "Ignoring request to alter blocking bugs of bug #$data->{bug_num} to the same blocks previously set\n"; next; } $data->{blockedby} = join(' ',keys %blockers); @@ -696,8 +697,7 @@ sub set_tag { push @changed, 'removed tag(s) '.english_join([keys %tag_removed]) if keys %tag_removed; $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" - unless __internal_request(); + print {$transcript} "Ignoring request to alter tags of bug #$data->{bug_num} to the same tags previously set\n"; next; } $action .= '.'; @@ -953,8 +953,8 @@ sub set_done { for my $data (@data) { my $old_data = dclone($data); my $hash = get_hashname($data->{bug_num}); - my $report_fh = IO::File->new("db-h/$hash/$data->{bug_num}.report",'r') or - die "Unable to open original report db-h/$hash/$data->{bug_num}.report for reading: $!"; + my $report_fh = IO::File->new("$config{spool_dir}/db-h/$hash/$data->{bug_num}.report",'r') or + die "Unable to open original report $config{spool_dir}/db-h/$hash/$data->{bug_num}.report for reading: $!"; my $orig_report; { local $/; @@ -998,7 +998,7 @@ sub set_done { headers => [To => $data->{submitter}, Subject => "$config{ubug}#$data->{bug_num} ". - "closed by $param{requester} ($param{request_subject})", + "closed by $param{requester} ".(defined $param{request_subject}?"($param{request_subject})":""), ], ) ], @@ -1109,8 +1109,7 @@ sub set_submitter { (not defined $data->{originator} or not length $data->{originator})) or (defined $param{submitter} and defined $data->{originator} and $param{submitter} eq $data->{originator})) { - print {$transcript} "Ignoring request to change the submitter of bug#$data->{bug_num} to the same value\n" - unless __internal_request(); + print {$transcript} "Ignoring request to change the submitter of bug#$data->{bug_num} to the same value\n"; next; } else { @@ -1222,8 +1221,7 @@ sub set_forwarded { if (__all_undef_or_equal($param{forwarded},$data->{forwarded}) or (not defined $param{forwarded} and defined $data->{forwarded} and not length $data->{forwarded})) { - print {$transcript} "Ignoring request to change the forwarded-to-address of bug#$data->{bug_num} to the same value\n" - unless __internal_request(); + print {$transcript} "Ignoring request to change the forwarded-to-address of bug#$data->{bug_num} to the same value\n"; next; } else { @@ -1311,8 +1309,7 @@ sub set_title { print {$debug} "Going to change bug title\n"; if (defined $data->{subject} and length($data->{subject}) and $data->{subject} eq $param{title}) { - print {$transcript} "Ignoring request to change the title of bug#$data->{bug_num} to the same title\n" - unless __internal_request(); + print {$transcript} "Ignoring request to change the title of bug#$data->{bug_num} to the same title\n"; next; } else { @@ -1416,8 +1413,7 @@ sub set_package { print {$debug} "Going to change assigned package\n"; if (defined $data->{package} and length($data->{package}) and $data->{package} eq $new_package) { - print {$transcript} "Ignoring request to reassign bug #$data->{bug_num} to the same package\n" - unless __internal_request(); + print {$transcript} "Ignoring request to reassign bug #$data->{bug_num} to the same package\n"; next; } else { @@ -1581,6 +1577,12 @@ sub set_found { if (not @svers) { @svers = $version; } + else { + if (exists $found_versions{$version}) { + delete $found_versions{$version}; + $found_removed{$version} = 1; + } + } for my $sver (@svers) { if (not exists $found_versions{$sver}) { $found_versions{$sver} = 1; @@ -1649,8 +1651,7 @@ sub set_found { $action .= " and reopened" } if (not $reopened and not @changed) { - print {$transcript} "Ignoring request to alter found versions of bug #$data->{bug_num} to the same values previously set\n" - unless __internal_request(); + print {$transcript} "Ignoring request to alter found versions of bug #$data->{bug_num} to the same values previously set\n"; next; } $action .= '.'; @@ -1793,6 +1794,12 @@ sub set_fixed { if (not @svers) { @svers = $version; } + else { + if (exists $fixed_versions{$version}) { + $fixed_removed{$version} = 1; + delete $fixed_versions{$version}; + } + } for my $sver (@svers) { if (not exists $fixed_versions{$sver}) { $fixed_versions{$sver} = 1; @@ -1858,8 +1865,7 @@ sub set_fixed { $action .= " and reopened" } if (not $reopened and not @changed) { - print {$transcript} "Ignoring request to alter fixed versions of bug #$data->{bug_num} to the same values previously set\n" - unless __internal_request(); + print {$transcript} "Ignoring request to alter fixed versions of bug #$data->{bug_num} to the same values previously set\n"; next; } $action .= '.'; @@ -2015,7 +2021,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, )) { @@ -2084,66 +2090,69 @@ sub set_merged { croak "Did not alter merged bugs"; } } - my ($change_bug) = keys %{$changes}; - $bug_changed{$change_bug}++; - print {$transcript} __bug_info($data{$change_bug}) if - $param{show_bug_info} and not __internal_request(1); - $bug_info_shown{$change_bug} = 1; - __allow_relocking($param{locks},[keys %data]); - for my $change (@{$changes->{$change_bug}}) { - if ($change->{field} eq 'blockedby' or $change->{field} eq 'blocks') { - my %target_blockedby; - @target_blockedby{@{$change->{func_value}}} = (1) x @{$change->{func_value}}; - my %unhandled_targets = %target_blockedby; - my @blocks_to_remove; - for my $key (split / /,$change->{orig_value}) { - delete $unhandled_targets{$key}; - next if exists $target_blockedby{$key}; - set_blocks(bug => $change->{field} eq 'blocks' ? $key : $change->{bug}, - block => $change->{field} eq 'blocks' ? $change->{bug} : $key, - remove => 1, - hash_slice(%param, - keys %common_options, - keys %append_action_options), - ); + my @bugs_to_change = keys %{$changes}; + for my $change_bug (@bugs_to_change) { + next unless exists $changes->{$change_bug}; + $bug_changed{$change_bug}++; + print {$transcript} __bug_info($data{$change_bug}) if + $param{show_bug_info} and not __internal_request(1); + $bug_info_shown{$change_bug} = 1; + __allow_relocking($param{locks},[keys %data]); + for my $change (@{$changes->{$change_bug}}) { + if ($change->{field} eq 'blockedby' or $change->{field} eq 'blocks') { + my %target_blockedby; + @target_blockedby{@{$change->{func_value}}} = (1) x @{$change->{func_value}}; + my %unhandled_targets = %target_blockedby; + my @blocks_to_remove; + for my $key (split / /,$change->{orig_value}) { + delete $unhandled_targets{$key}; + next if exists $target_blockedby{$key}; + set_blocks(bug => $change->{field} eq 'blocks' ? $key : $change->{bug}, + block => $change->{field} eq 'blocks' ? $change->{bug} : $key, + remove => 1, + hash_slice(%param, + keys %common_options, + keys %append_action_options), + ); + } + for my $key (keys %unhandled_targets) { + set_blocks(bug => $change->{field} eq 'blocks' ? $key : $change->{bug}, + block => $change->{field} eq 'blocks' ? $change->{bug} : $key, + add => 1, + hash_slice(%param, + keys %common_options, + keys %append_action_options), + ); + } } - for my $key (keys %unhandled_targets) { - set_blocks(bug => $change->{field} eq 'blocks' ? $key : $change->{bug}, - block => $change->{field} eq 'blocks' ? $change->{bug} : $key, - add => 1, - hash_slice(%param, - keys %common_options, - keys %append_action_options), - ); + else { + $change->{function}->(bug => $change->{bug}, + $change->{key}, $change->{func_value}, + exists $change->{options}?@{$change->{options}}:(), + hash_slice(%param, + keys %common_options, + keys %append_action_options), + ); } } - else { - $change->{function}->(bug => $change->{bug}, - $change->{key}, $change->{func_value}, - exists $change->{options}?@{$change->{options}}:(), - hash_slice(%param, - keys %common_options, - keys %append_action_options), - ); - } + __disallow_relocking($param{locks}); + my ($data,$n_locks) = + __lock_and_load_merged_bugs(bugs_to_load => [keys %merging], + data => \@data, + locks => $param{locks}, + debug => $debug, + reload_all => 1, + ); + $new_locks += $n_locks; + $locks += $n_locks; + %data = %{$data}; + @data = values %data; + ($merge_status,$bugs_to_merge) = + __calculate_merge_status(\@data,\%data,$param{bug},$merge_status); + ($disallowed_changes,$changes) = + __calculate_merge_changes(\@data,$merge_status,\%param); + $attempts = max(values %bug_changed); } - __disallow_relocking($param{locks}); - my ($data,$n_locks) = - __lock_and_load_merged_bugs(bugs_to_load => [keys %merging], - data => \@data, - locks => $param{locks}, - debug => $debug, - reload_all => 1, - ); - $new_locks += $n_locks; - $locks += $n_locks; - %data = %{$data}; - @data = values %data; - ($merge_status,$bugs_to_merge) = - __calculate_merge_status(\@data,\%data,$param{bug},$merge_status); - ($disallowed_changes,$changes) = - __calculate_merge_changes(\@data,$merge_status,\%param); - $attempts = max(values %bug_changed); } if ($param{show_bug_info} and not __internal_request(1)) { for my $data (sort {$a->{bug_num} <=> $b->{bug_num}} @data) { @@ -2152,12 +2161,16 @@ sub set_merged { } } if (keys %{$changes} or @{$disallowed_changes}) { - print {$transcript} "Unable to modify bugs so that they could be merged\n"; + print {$transcript} "After four attempts, the following changes were unable to be made:\n"; for (1..$new_locks) { unfilelock($param{locks}); $locks--; } __end_control(%info); + for my $change (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"; return; } @@ -2394,6 +2407,19 @@ sub __calculate_merge_changes{ next if join(' ', sort @{$data->{$field}}) eq join(' ',sort keys %{$merge_status->{$field}}); } + elsif ($field eq 'done') { + # for done, we only care if the bug is done or not + # done, not the value it's set to. + if (defined $merge_status->{$field} and length $merge_status->{$field} and + defined $data->{$field} and length $data->{$field}) { + next; + } + elsif ((not defined $merge_status->{$field} or not length $merge_status->{$field}) and + (not defined $data->{$field} or not length $data->{$field}) + ) { + next; + } + } elsif ($merge_status->{$field} eq $data->{$field}) { next; } @@ -2568,8 +2594,7 @@ sub affects { } } if (not length $action) { - print {$transcript} "Ignoring request to set affects of bug $data->{bug_num} to the same value previously set\n" - unless __internal_request(); + print {$transcript} "Ignoring request to set affects of bug $data->{bug_num} to the same value previously set\n"; next; } my $old_data = dclone($data); @@ -2730,8 +2755,7 @@ sub summary { 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" - unless __internal_request(); + print {$transcript} "Ignoring request to change the summary of bug $param{bug} to the same value\n"; next; } if (length $summary) { @@ -2876,7 +2900,7 @@ sub clone_bug { for my $bug (split ' ', $data->{blocks}) { for my $new_bug (@new_bugs) { set_blocks(bug => $new_bug, - blocks => $bug, + block => $bug, hash_slice(%param, keys %common_options, keys %append_action_options), @@ -2887,7 +2911,7 @@ sub clone_bug { for my $bug (split ' ', $data->{blockedby}) { for my $new_bug (@new_bugs) { set_blocks(bug => $bug, - blocks => $new_bug, + block => $new_bug, hash_slice(%param, keys %common_options, keys %append_action_options), @@ -2948,8 +2972,7 @@ sub owner { print {$debug} "Owner is currently '$data->{owner}' for bug $data->{bug_num}\n"; if (not defined $param{owner} or not length $param{owner}) { if (not defined $data->{owner} or not length $data->{owner}) { - print {$transcript} "Ignoring request to unset the owner of bug #$data->{bug_num} which was not set\n" - unless __internal_request(); + print {$transcript} "Ignoring request to unset the owner of bug #$data->{bug_num} which was not set\n"; next; } $param{owner} = ''; @@ -3060,7 +3083,6 @@ sub bug_archive { print {$transcript} "Bug $param{bug} cannot be archived\n"; die "Bug $param{bug} cannot be archived"; } - print {$debug} "$param{bug} considering\n"; if (not $param{archive_unarchived} and not exists $data[0]{unarchived} ) { @@ -3335,7 +3357,7 @@ sub append_action_to_log{ $nd{$key} = $new_data->{$key}; # $data_diff .= html_escape("$Debbugs::Status::fields{$key}: $new_data->{$key}")."\n"; } - $data_diff .= html_escape(Data::Dumper->Dump([\%nd],[qw(new_data)])); + $data_diff .= html_escape(Data::Dumper->Dump([encode_utf8_structure(\%nd)],[qw(new_data)])); $data_diff .= "-->\n"; $data_diff .= "\n"; } my $msg = join('', (exists $param{command} ? - "\n":"" + "\n":"" ), (length $param{requester} ? - "\n":"" + "\n":"" ), (length $param{request_addr} ? - "\n":"" + "\n":"" ), "\n", $data_diff, - "".html_escape($param{action})."\n"); + "".html_escape(encode_utf8($param{action}))."\n"); if (length $param{requester}) { - $msg .= "Request was from ".html_escape($param{requester})."\n"; + $msg .= "Request was from ".html_escape(encode_utf8($param{requester}))."\n"; } if (length $param{request_addr}) { - $msg .= "to ".html_escape($param{request_addr}).""; + $msg .= "to ".html_escape(encode_utf8($param{request_addr})).""; } if (length $param{desc}) { - $msg .= ":
\n$param{desc}\n"; + $msg .= ":
\n".encode_utf8($param{desc})."\n"; } else { $msg .= ".\n"; @@ -3574,7 +3596,8 @@ sub __begin_control { ); my $new_locks; my ($debug,$transcript) = __handle_debug_transcript(@_); - print {$debug} "$param{bug} considering\n"; + print {$debug} "considering bug $param{bug} for ".(exists $param{command}?$param{command}:scalar caller())."\n"; +# print {$debug} Data::Dumper->Dump([[caller(1)],\%param],[qw(caller param)])."\n"; $lockhash = $param{locks} if exists $param{locks}; my @data = (); my $old_die = $SIG{__DIE__}; @@ -3596,7 +3619,7 @@ sub __begin_control { } } } - if (not __check_limit(data => \@data, + if (not check_limit(data => \@data, exists $param{limit}?(limit => $param{limit}):(), transcript => $transcript, )) { @@ -3663,9 +3686,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 @@ -3682,7 +3705,7 @@ limit to succeed. =cut -sub __check_limit{ +sub check_limit{ my %param = validate_with(params => \@_, spec => {data => {type => ARRAYREF|SCALAR, }, @@ -3776,7 +3799,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, + ); } };