diff options
author | Byron Jones <glob@mozilla.com> | 2015-03-16 17:38:53 +0100 |
---|---|---|
committer | Byron Jones <glob@mozilla.com> | 2015-03-16 17:38:53 +0100 |
commit | 894d016fcad932caa7fae93c171059e9fd7ea2bf (patch) | |
tree | 5f9ad519ff25e6fc7a8336a3dc6d3e42226139b8 /extensions | |
parent | 5365c225d354ef7962b8d54b37c8139693d682ba (diff) | |
download | bugzilla-894d016fcad932caa7fae93c171059e9fd7ea2bf.tar.gz bugzilla-894d016fcad932caa7fae93c171059e9fd7ea2bf.tar.xz |
Bug 1141452: Adjustment on the project flags (blocking-b2g and tracking-b2g)
Diffstat (limited to 'extensions')
-rwxr-xr-x | extensions/BMO/bin/bug_1141452.pl | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/extensions/BMO/bin/bug_1141452.pl b/extensions/BMO/bin/bug_1141452.pl new file mode 100755 index 000000000..ed12e364f --- /dev/null +++ b/extensions/BMO/bin/bug_1141452.pl @@ -0,0 +1,77 @@ +#!/usr/bin/perl +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. + +use strict; +use warnings; + +use FindBin qw($RealBin); +use lib "$RealBin/../../.."; + +BEGIN { + use Bugzilla; + Bugzilla->extensions; +} + +use Bugzilla::Constants qw( USAGE_MODE_CMDLINE ); +use Bugzilla::Extension::TrackingFlags::Flag; +use Bugzilla::User; + +Bugzilla->usage_mode(USAGE_MODE_CMDLINE); +my $dbh = Bugzilla->dbh; + +my $blocking_b2g = Bugzilla::Extension::TrackingFlags::Flag->check({ name => 'cf_blocking_b2g' }); +my $tracking_b2g = Bugzilla::Extension::TrackingFlags::Flag->check({ name => 'cf_tracking_b2g' }); + +die "tracking-b2g does not have a 'backlog' value\n" + unless grep { $_->value eq 'backlog' } @{ $tracking_b2g->values }; + +print "Searching for bugs..\n"; +my $flags = $dbh->selectall_arrayref(<<EOF, { Slice => {} }, $blocking_b2g->flag_id); + SELECT + id, + bug_id + FROM + tracking_flags_bugs + WHERE + tracking_flag_id = ? + AND value = 'backlog' +EOF +die "No suitable bugs found\n" unless @$flags; +printf "About to fix %s bugs\n", scalar(@$flags); +print "Press <Ctrl-C> to stop or <Enter> to continue...\n"; +getc(); + +my $nobody = Bugzilla::User->check({ name => 'nobody@mozilla.org' }); +my $when = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)'); + +$dbh->bz_start_transaction(); +foreach my $flag (@$flags) { + $dbh->do( + "UPDATE tracking_flags_bugs SET tracking_flag_id = ? WHERE id = ?", + undef, + $tracking_b2g->flag_id, $flag->{id}, + ); + $dbh->do( + "UPDATE bugs SET delta_ts = ?, lastdiffed = ? WHERE bug_id = ?", + undef, + $when, $when, $flag->{bug_id}, + ); + $dbh->do( + "INSERT INTO bugs_activity(bug_id, who, bug_when, fieldid, removed, added) VALUES (?, ?, ?, ?, ?, ?)", + undef, + $flag->{bug_id}, $nobody->id, $when, $blocking_b2g->id, 'backlog', '---', + ); + $dbh->do( + "INSERT INTO bugs_activity(bug_id, who, bug_when, fieldid, removed, added) VALUES (?, ?, ?, ?, ?, ?)", + undef, + $flag->{bug_id}, $nobody->id, $when, $tracking_b2g->id, '---', 'backlog', + ); +} +$dbh->bz_commit_transaction(); + +print "Done.\n"; |