Bug 24496: Adds a parameter "noresolveonopenblockers" which when enabled,…

Bug 24496: Adds a parameter "noresolveonopenblockers" which when enabled, prevents bugs from being closed if there are any bugs blocking it which are still open. Patch by Andreas Höfler <andreas.hoefler@bearingpoint.com> r= justdave, a= myk
parent 3d59b2bd
......@@ -1169,7 +1169,14 @@ Reason: %reason%
type => 't',
default => '',
},
);
{
name => 'noresolveonopenblockers',
desc => 'Don\'t allow bugs to be resolved as fixed if they have unresolved dependencies.',
type => 'b',
default => 0,
},
);
1;
......@@ -1069,6 +1069,38 @@ sub GetBugLink {
}
}
# CountOpenDependencies counts the number of open dependent bugs for a
# list of bugs and returns a list of bug_id's and their dependency count
# It takes one parameter:
# - A list of bug numbers whose dependencies are to be checked
sub CountOpenDependencies {
my (@bug_list) = @_;
my @dependencies;
# Make sure any unfetched data from a currently running query
# is saved off rather than overwritten
PushGlobalSQLState();
SendSQL("SELECT blocked, count(bug_status) " .
"FROM bugs, dependencies " .
"WHERE blocked IN (" . (join "," , @bug_list) . ") " .
"AND bug_id = dependson " .
"AND bug_status IN ('" . (join "','", OpenStates()) . "') " .
"GROUP BY blocked ");
while (MoreSQLData()) {
my ($bug_id, $dependencies) = FetchSQLData();
push(@dependencies, { bug_id => $bug_id,
dependencies => $dependencies });
}
# All done with this sidetrip
PopGlobalSQLState();
return @dependencies;
}
sub GetLongDescriptionAsText {
my ($id, $start, $end) = (@_);
my $result = "";
......
......@@ -890,6 +890,17 @@ SWITCH: for ($::FORM{'knob'}) {
ThrowUserError("resolving_remaining_time");
}
}
# don't resolve as fixed while still unresolved blocking bugs
if (Param("noresolveonopenblockers") && ($::FORM{'resolution'} eq 'FIXED')) {
my @dependencies = CountOpenDependencies(@idlist);
if (scalar @dependencies > 0) {
ThrowUserError("still_unresolved_bugs",
{ dependencies => \@dependencies,
dependency_count => scalar @dependencies });
}
}
# Check here, because its the only place we require the resolution
CheckFormField(\%::FORM, 'resolution', \@::settable_resolution);
ChangeStatus('RESOLVED');
......
......@@ -666,6 +666,32 @@
Sorry - sidebar.cgi currently only supports Mozilla based web browsers.
<a href="http://www.mozilla.org">Upgrade today</a>. :-)
[% ELSIF error == "still_unresolved_bugs" %]
[% IF dependency_count == 1 %]
[% terms.Bug %]# <a href="show_bug.cgi?id=[% dependencies.0.bug_id %]">[% dependencies.0.bug_id %]</a>
has still [% dependencies.0.dependencies FILTER html %] unresolved
[% IF dependencies.0.dependencies == 1 %]
dependency
[% ELSE %]
dependencies
[% END %]. Show
<a href="showdependencytree.cgi?id=[% dependencies.0.bug_id %]">Dependency Tree</a>.
[% ELSE %]
There are [% dependency_count %] open [% terms.bugs %] which
have unresolved dependencies.
<br>
[% FOREACH bug = dependencies %]
[% terms.Bug %]# <a href="show_bug.cgi?id=[% bug.bug_id %]">[% bug.bug_id %]</a>
has [% bug.dependencies FILTER html %] open
[% IF bug.dependencies == 1 %]
dependency.
[% ELSE %]
dependencies.
[% END %]
(<a href="showdependencytree.cgi?id=[% bug.bug_id %]">Dependency Tree</a>)<br>
[% END %]
[% END %]
[% ELSIF error == "too_many_votes_for_bug" %]
[% title = "Illegal Vote" %]
You may only use at most [% max FILTER html %] votes for a single
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment