summaryrefslogtreecommitdiffstats
path: root/contrib/reorg-tools
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/reorg-tools')
-rw-r--r--contrib/reorg-tools/README9
-rwxr-xr-xcontrib/reorg-tools/convert_date_time_date.pl62
-rwxr-xr-xcontrib/reorg-tools/fix_all_open_status_queries.pl144
-rwxr-xr-xcontrib/reorg-tools/fixgroupqueries.pl123
-rwxr-xr-xcontrib/reorg-tools/fixqueries.pl136
-rwxr-xr-xcontrib/reorg-tools/migrate_crash_signatures.pl132
-rwxr-xr-xcontrib/reorg-tools/migrate_orange_bugs.pl158
-rwxr-xr-xcontrib/reorg-tools/move_dupes_to_invalid.pl101
-rwxr-xr-xcontrib/reorg-tools/move_flag_types.pl172
-rwxr-xr-xcontrib/reorg-tools/move_os.pl81
-rwxr-xr-xcontrib/reorg-tools/movebugs.pl182
-rwxr-xr-xcontrib/reorg-tools/movecomponent.pl154
-rwxr-xr-xcontrib/reorg-tools/reassign_open_bugs.pl87
-rwxr-xr-xcontrib/reorg-tools/reset_default_user.pl145
-rwxr-xr-xcontrib/reorg-tools/syncflags.pl88
-rwxr-xr-xcontrib/reorg-tools/syncmsandversions.pl122
16 files changed, 0 insertions, 1896 deletions
diff --git a/contrib/reorg-tools/README b/contrib/reorg-tools/README
deleted file mode 100644
index 4e5d6eb4d..000000000
--- a/contrib/reorg-tools/README
+++ /dev/null
@@ -1,9 +0,0 @@
-Upstreaming attempt: https://bugzilla.mozilla.org/show_bug.cgi?id=616499
-
-Included in this directory is a group of tools we've used for moving components
-around in a Bugzilla 3.2 install on bugzilla.mozilla.org.
-
-They may require tweaking if you use them on your own install. Putting them
-here to make it easier to collaborate on them and keep them up-to-date.
-Hopefully Bugzilla upstream will be able to just do this from the web UI
-eventually.
diff --git a/contrib/reorg-tools/convert_date_time_date.pl b/contrib/reorg-tools/convert_date_time_date.pl
deleted file mode 100755
index a2e9bfffc..000000000
--- a/contrib/reorg-tools/convert_date_time_date.pl
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/usr/bin/perl -w
-# 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 Cwd 'abs_path';
-use File::Basename;
-use FindBin;
-use lib "$FindBin::Bin/../..";
-use lib "$FindBin::Bin/../../lib";
-
-use Bugzilla;
-use Bugzilla::Constants;
-
-sub usage() {
- print <<USAGE;
-Usage: convert_date_time_date.pl <column>
-
-E.g.: convert_date_time_date.pl cf_due_date
-Converts a datetime field (FIELD_TYPE_DATETIME) to a date field type
-(FIELD_TYPE_DATE).
-
-Note: Any time portion will be lost but the date portion will be preserved.
-USAGE
-}
-
-#############################################################################
-# MAIN CODE
-#############################################################################
-
-Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
-
-if (scalar @ARGV < 1) {
- usage();
- exit();
-}
-
-my $column = shift;
-
-print <<EOF;
-Converting bugs.${column} from FIELD_TYPE_DATETIME to FIELD_TYPE_DATE.
-
-Note: Any time portion will be lost but the date portion will be preserved.
-
-Press <Ctrl-C> to stop or <Enter> to continue...
-EOF
-getc();
-
-Bugzilla->dbh->bz_alter_column('bugs', $column, { TYPE => 'DATE' });
-Bugzilla->dbh->do("UPDATE fielddefs SET type = ? WHERE name = ?",
- undef, FIELD_TYPE_DATE, $column);
-
-# It's complex to determine which items now need to be flushed from memcached.
-# As this is expected to be a rare event, we just flush the entire cache.
-Bugzilla->memcached->clear_all();
-
-print "\ndone.\n";
diff --git a/contrib/reorg-tools/fix_all_open_status_queries.pl b/contrib/reorg-tools/fix_all_open_status_queries.pl
deleted file mode 100755
index 7c8d8be68..000000000
--- a/contrib/reorg-tools/fix_all_open_status_queries.pl
+++ /dev/null
@@ -1,144 +0,0 @@
-#!/usr/bin/perl -w
-# 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 lib qw(. lib);
-
-use Bugzilla;
-use Bugzilla::Constants;
-use Bugzilla::Status;
-use Bugzilla::Util;
-
-sub usage() {
- print <<USAGE;
-Usage: fix_all_open_status_queries.pl <new_open_status>
-
-E.g.: fix_all_open_status_queries.pl READY
-This will add a new open state to user queries which currently look for
-all open bugs by listing every open status in their query criteria.
-For users who only look for bug_status=__open__, they will get the new
-open status automatically.
-USAGE
-}
-
-sub do_namedqueries {
- my ($new_status) = @_;
- my $dbh = Bugzilla->dbh;
- my $replace_count = 0;
-
- my $query = $dbh->selectall_arrayref("SELECT id, query FROM namedqueries");
-
- if ($query) {
- $dbh->bz_start_transaction();
-
- my $sth = $dbh->prepare("UPDATE namedqueries SET query = ? WHERE id = ?");
-
- foreach my $row (@$query) {
- my ($id, $old_query) = @$row;
- my $new_query = all_open_states($new_status, $old_query);
- if ($new_query) {
- trick_taint($new_query);
- $sth->execute($new_query, $id);
- $replace_count++;
- }
- }
-
- $dbh->bz_commit_transaction();
- }
-
- print "namedqueries: $replace_count replacements made.\n";
-}
-
-# series
-sub do_series {
- my ($new_status) = @_;
- my $dbh = Bugzilla->dbh;
- my $replace_count = 0;
-
- my $query = $dbh->selectall_arrayref("SELECT series_id, query FROM series");
-
- if ($query) {
- $dbh->bz_start_transaction();
-
- my $sth = $dbh->prepare("UPDATE series SET query = ? WHERE series_id = ?");
-
- foreach my $row (@$query) {
- my ($series_id, $old_query) = @$row;
- my $new_query = all_open_states($new_status, $old_query);
- if ($new_query) {
- trick_taint($new_query);
- $sth->execute($new_query, $series_id);
- $replace_count++;
- }
- }
-
- $dbh->bz_commit_transaction();
- }
-
- print "series: $replace_count replacements made.\n";
-}
-
-sub all_open_states {
- my ($new_status, $query) = @_;
-
- my @open_states = Bugzilla::Status::BUG_STATE_OPEN();
- my $cgi = Bugzilla::CGI->new($query);
- my @query_states = $cgi->param('bug_status');
-
- my ($removed, $added) = diff_arrays(\@query_states, \@open_states);
-
- if (scalar @$added == 1 && $added->[0] eq $new_status) {
- push(@query_states, $new_status);
- $cgi->param('bug_status', @query_states);
- return $cgi->canonicalise_query();
- }
-
- return '';
-}
-
-sub validate_status {
- my ($status) = @_;
- my $dbh = Bugzilla->dbh;
- my $exists = $dbh->selectrow_array("SELECT 1 FROM bug_status
- WHERE value = ?",
- undef, $status);
- return $exists ? 1 : 0;
-}
-
-#############################################################################
-# MAIN CODE
-#############################################################################
-# This is a pure command line script.
-Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
-
-if (scalar @ARGV < 1) {
- usage();
- exit(1);
-}
-
-my ($new_status) = @ARGV;
-
-$new_status = uc($new_status);
-
-if (!validate_status($new_status)) {
- print "Invalid status: $new_status\n\n";
- usage();
- exit(1);
-}
-
-print "Adding new status '$new_status'.\n\n";
-
-do_namedqueries($new_status);
-do_series($new_status);
-
-# It's complex to determine which items now need to be flushed from memcached.
-# As this is expected to be a rare event, we just flush the entire cache.
-Bugzilla->memcached->clear_all();
-
-exit(0);
diff --git a/contrib/reorg-tools/fixgroupqueries.pl b/contrib/reorg-tools/fixgroupqueries.pl
deleted file mode 100755
index 0bd64cd40..000000000
--- a/contrib/reorg-tools/fixgroupqueries.pl
+++ /dev/null
@@ -1,123 +0,0 @@
-#!/usr/bin/perl -w
-# -*- Mode: perl; indent-tabs-mode: nil -*-
-#
-# The contents of this file are subject to the Mozilla Public
-# License Version 1.1 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# The Original Code is the Bugzilla Bug Tracking System.
-#
-# The Initial Developer of the Original Code is Netscape Communications
-# Corporation. Portions created by Netscape are
-# Copyright (C) 1998 Netscape Communications Corporation. All
-# Rights Reserved.
-#
-# Contributor(s): Gervase Markham <gerv@gerv.net>
-
-use strict;
-
-use lib qw(. lib);
-
-use Bugzilla;
-use Bugzilla::Constants;
-use Bugzilla::Util;
-
-sub usage() {
- print <<USAGE;
-Usage: fixgroupqueries.pl <oldvalue> <newvalue>
-
-E.g.: fixgroupqueries.pl w-security webtools-security
-will change all occurrences of "w-security" to "webtools-security" in the
-appropriate places in the namedqueries.
-
-Note that all parameters are case-sensitive.
-USAGE
-}
-
-sub do_namedqueries($$) {
- my ($old, $new) = @_;
- $old = url_quote($old);
- $new = url_quote($new);
-
- my $dbh = Bugzilla->dbh;
-
- my $replace_count = 0;
- my $query = $dbh->selectall_arrayref("SELECT id, query FROM namedqueries");
- if ($query) {
- my $sth = $dbh->prepare("UPDATE namedqueries SET query = ?
- WHERE id = ?");
-
- foreach my $row (@$query) {
- my ($id, $query) = @$row;
- if (($query =~ /field\d+-\d+-\d+=bug_group/) &&
- ($query =~ /(?:^|&|;)value\d+-\d+-\d+=$old(?:;|&|$)/)) {
- $query =~ s/((?:^|&|;)value\d+-\d+-\d+=)$old(;|&|$)/$1$new$2/;
- $sth->execute($query, $id);
- $replace_count++;
- }
- }
- }
-
- print "namedqueries: $replace_count replacements made.\n";
-}
-
-# series
-sub do_series($$) {
- my ($old, $new) = @_;
- $old = url_quote($old);
- $new = url_quote($new);
-
- my $dbh = Bugzilla->dbh;
- #$dbh->bz_start_transaction();
-
- my $replace_count = 0;
- my $query = $dbh->selectall_arrayref("SELECT series_id, query
- FROM series");
- if ($query) {
- my $sth = $dbh->prepare("UPDATE series SET query = ?
- WHERE series_id = ?");
- foreach my $row (@$query) {
- my ($series_id, $query) = @$row;
-
- if (($query =~ /field\d+-\d+-\d+=bug_group/) &&
- ($query =~ /(?:^|&|;)value\d+-\d+-\d+=$old(?:;|&|$)/)) {
- $query =~ s/((?:^|&|;)value\d+-\d+-\d+=)$old(;|&|$)/$1$new$2/;
- $sth->execute($query, $series_id);
- $replace_count++;
- }
- }
- }
-
- #$dbh->bz_commit_transaction();
- print "series: $replace_count replacements made.\n";
-}
-
-#############################################################################
-# MAIN CODE
-#############################################################################
-# This is a pure command line script.
-Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
-
-if (scalar @ARGV < 2) {
- usage();
- exit();
-}
-
-my ($old, $new) = @ARGV;
-
-print "Changing all instances of '$old' to '$new'.\n\n";
-
-#do_namedqueries($old, $new);
-do_series($old, $new);
-
-# It's complex to determine which items now need to be flushed from memcached.
-# As this is expected to be a rare event, we just flush the entire cache.
-Bugzilla->memcached->clear_all();
-
-exit(0);
diff --git a/contrib/reorg-tools/fixqueries.pl b/contrib/reorg-tools/fixqueries.pl
deleted file mode 100755
index 221213058..000000000
--- a/contrib/reorg-tools/fixqueries.pl
+++ /dev/null
@@ -1,136 +0,0 @@
-#!/usr/bin/perl -w
-# -*- Mode: perl; indent-tabs-mode: nil -*-
-#
-# The contents of this file are subject to the Mozilla Public
-# License Version 1.1 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# The Original Code is the Bugzilla Bug Tracking System.
-#
-# The Initial Developer of the Original Code is Netscape Communications
-# Corporation. Portions created by Netscape are
-# Copyright (C) 1998 Netscape Communications Corporation. All
-# Rights Reserved.
-#
-# Contributor(s): Gervase Markham <gerv@gerv.net>
-
-use strict;
-
-use lib qw(. lib);
-
-use Bugzilla;
-use Bugzilla::Constants;
-use Bugzilla::Util;
-
-sub usage() {
- print <<USAGE;
-Usage: fixqueries.pl <parameter> <oldvalue> <newvalue>
-
-E.g.: fixqueries.pl product FoodReplicator SeaMonkey
-will change all occurrences of "FoodReplicator" to "Seamonkey" in the
-appropriate places in the namedqueries, series and series_categories tables.
-
-Note that all parameters are case-sensitive.
-USAGE
-}
-
-sub do_namedqueries($$$) {
- my ($field, $old, $new) = @_;
- $old = url_quote($old);
- $new = url_quote($new);
-
- my $dbh = Bugzilla->dbh;
- #$dbh->bz_start_transaction();
-
- my $replace_count = 0;
- my $query = $dbh->selectall_arrayref("SELECT id, query FROM namedqueries");
- if ($query) {
- my $sth = $dbh->prepare("UPDATE namedqueries SET query = ?
- WHERE id = ?");
-
- foreach my $row (@$query) {
- my ($id, $query) = @$row;
- if ($query =~ /(?:^|&|;)$field=$old(?:&|$|;)/) {
- $query =~ s/((?:^|&|;)$field=)$old(;|&|$)/$1$new$2/;
- $sth->execute($query, $id);
- $replace_count++;
- }
- }
- }
-
- #$dbh->bz_commit_transaction();
- print "namedqueries: $replace_count replacements made.\n";
-}
-
-# series
-sub do_series($$$) {
- my ($field, $old, $new) = @_;
- $old = url_quote($old);
- $new = url_quote($new);
-
- my $dbh = Bugzilla->dbh;
- #$dbh->bz_start_transaction();
-
- my $replace_count = 0;
- my $query = $dbh->selectall_arrayref("SELECT series_id, query
- FROM series");
- if ($query) {
- my $sth = $dbh->prepare("UPDATE series SET query = ?
- WHERE series_id = ?");
- foreach my $row (@$query) {
- my ($series_id, $query) = @$row;
-
- if ($query =~ /(?:^|&|;)$field=$old(?:&|$|;)/) {
- $query =~ s/((?:^|&|;)$field=)$old(;|&|$)/$1$new$2/;
- $replace_count++;
- }
-
- $sth->execute($query, $series_id);
- }
- }
-
- #$dbh->bz_commit_transaction();
- print "series: $replace_count replacements made.\n";
-}
-
-# series_categories
-sub do_series_categories($$) {
- my ($old, $new) = @_;
- my $dbh = Bugzilla->dbh;
-
- $dbh->do("UPDATE series_categories SET name = ? WHERE name = ?",
- undef,
- ($new, $old));
-}
-
-#############################################################################
-# MAIN CODE
-#############################################################################
-# This is a pure command line script.
-Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
-
-if (scalar @ARGV < 3) {
- usage();
- exit();
-}
-
-my ($field, $old, $new) = @ARGV;
-
-print "Changing all instances of '$old' to '$new'.\n\n";
-
-do_namedqueries($field, $old, $new);
-do_series($field, $old, $new);
-do_series_categories($old, $new);
-
-# It's complex to determine which items now need to be flushed from memcached.
-# As this is expected to be a rare event, we just flush the entire cache.
-Bugzilla->memcached->clear_all();
-
-exit(0);
-
diff --git a/contrib/reorg-tools/migrate_crash_signatures.pl b/contrib/reorg-tools/migrate_crash_signatures.pl
deleted file mode 100755
index 4323c1d01..000000000
--- a/contrib/reorg-tools/migrate_crash_signatures.pl
+++ /dev/null
@@ -1,132 +0,0 @@
-#!/usr/bin/perl
-# -*- Mode: perl; indent-tabs-mode: nil -*-
-#
-# The contents of this file are subject to the Mozilla Public
-# License Version 1.1 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# The Initial Developer of the Original Code is Mozilla Foundation.
-# Portions created by the Initial Developer are Copyright (C) 2011 the
-# Initial Developer. All Rights Reserved.
-#
-#===============================================================================
-#
-# FILE: migrate_crash_signatures.pl
-#
-# USAGE: ./migrate_crash_signatures.pl
-#
-# DESCRIPTION: Migrate current summary data on matched bugs to the
-# new cf_crash_signature custom fields.
-#
-# OPTIONS: No params, then performs dry-run without updating the database.
-# If a true value is passed as single argument, then the database
-# is updated.
-# REQUIREMENTS: None
-# BUGS: 577724
-# NOTES: None
-# AUTHOR: David Lawrence (dkl@mozilla.com),
-# COMPANY: Mozilla Corproation
-# VERSION: 1.0
-# CREATED: 05/31/2011 03:57:52 PM
-# REVISION: 1
-#===============================================================================
-
-use strict;
-use warnings;
-
-use lib qw(. lib);
-
-use Bugzilla;
-use Bugzilla::Constants;
-use Bugzilla::Util;
-
-use Data::Dumper;
-
-Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
-
-my $UPDATE_DB = shift; # Pass true value as single argument to perform database update
-
-my $dbh = Bugzilla->dbh;
-
-# User to make changes as
-my $user_id = $dbh->selectrow_array(
- "SELECT userid FROM profiles WHERE login_name='nobody\@mozilla.org'");
-$user_id or die "Can't find user ID for 'nobody\@mozilla.org'\n";
-
-my $field_id = $dbh->selectrow_array(
- "SELECT id FROM fielddefs WHERE name = 'cf_crash_signature'");
-$field_id or die "Can't find field ID for 'cf_crash_signature' field\n";
-
-# Search criteria
-# a) crash or topcrash keyword,
-# b) not have [notacrash] in whiteboard,
-# c) have a properly formulated [@ ...]
-
-# crash and topcrash keyword ids
-my $crash_keyword_id = $dbh->selectrow_array(
- "SELECT id FROM keyworddefs WHERE name = 'crash'");
-$crash_keyword_id or die "Can't find keyword id for 'crash'\n";
-
-my $topcrash_keyword_id = $dbh->selectrow_array(
- "SELECT id FROM keyworddefs WHERE name = 'topcrash'");
-$topcrash_keyword_id or die "Can't find keyword id for 'topcrash'\n";
-
-# main search query
-my $bugs = $dbh->selectall_arrayref("
- SELECT bugs.bug_id, bugs.short_desc
- FROM bugs LEFT JOIN keywords ON bugs.bug_id = keywords.bug_id
- WHERE (keywords.keywordid = ? OR keywords.keywordid = ?)
- AND bugs.status_whiteboard NOT REGEXP '\\\\[notacrash\\\\]'
- AND bugs.short_desc REGEXP '\\\\[@.+\\\\]'
- AND (bugs.cf_crash_signature IS NULL OR bugs.cf_crash_signature = '')
- ORDER BY bugs.bug_id",
- {'Slice' => {}}, $crash_keyword_id, $topcrash_keyword_id);
-
-my $bug_count = scalar @$bugs;
-$bug_count or die "No bugs were found in matching search criteria.\n";
-
-print "Migrating $bug_count bugs to new crash signature field\n";
-
-$dbh->bz_start_transaction() if $UPDATE_DB;
-
-foreach my $bug (@$bugs) {
- my $bug_id = $bug->{'bug_id'};
- my $summary = $bug->{'short_desc'};
-
- print "Updating bug $bug_id ...";
-
- my @signatures;
- while ($summary =~ /(\[\@(?:\[.*\]|[^\[])*\])/g) {
- push(@signatures, $1);
- }
-
- if (@signatures && $UPDATE_DB) {
- my $timestamp = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)');
- $dbh->do("UPDATE bugs SET cf_crash_signature = ? WHERE bug_id = ?",
- undef, join("\n", @signatures), $bug_id);
- $dbh->do("INSERT INTO bugs_activity(bug_id, who, bug_when, fieldid, removed, added) " .
- "VALUES (?, ?, ?, ?, '', ?)",
- undef, $bug_id, $user_id, $timestamp, $field_id, join("\n", @signatures));
- $dbh->do("UPDATE bugs SET delta_ts = ?, lastdiffed = ? WHERE bug_id = ?",
- undef, $timestamp, $timestamp, $bug_id);
- }
- elsif (@signatures) {
- print Dumper(\@signatures);
- }
-
- print "done.\n";
-}
-
-if ($UPDATE_DB) {
- $dbh->bz_commit_transaction();
-
- # It's complex to determine which items now need to be flushed from memcached.
- # As this is expected to be a rare event, we just flush the entire cache.
- Bugzilla->memcached->clear_all();
-}
diff --git a/contrib/reorg-tools/migrate_orange_bugs.pl b/contrib/reorg-tools/migrate_orange_bugs.pl
deleted file mode 100755
index 4902464a3..000000000
--- a/contrib/reorg-tools/migrate_orange_bugs.pl
+++ /dev/null
@@ -1,158 +0,0 @@
-#!/usr/bin/perl -wT
-# 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.
-#===============================================================================
-#
-# FILE: migrate_orange_bugs.pl
-#
-# USAGE: ./migrate_orange_bugs.pl [--remove]
-#
-# DESCRIPTION: Add intermittent-keyword to bugs with [orange] stored in
-# whiteboard field. If --remove, then also remove the [orange]
-# value from whiteboard.
-#
-# OPTIONS: Without --doit, does a dry-run without updating the database.
-# If --doit is passed, then the database is updated.
-# --remove will remove [orange] from the whiteboard.
-# REQUIREMENTS: None
-# BUGS: 791758
-# NOTES: None
-# AUTHOR: David Lawrence (dkl@mozilla.com),
-# COMPANY: Mozilla Corproation
-# VERSION: 1.0
-# CREATED: 10/31/2012
-# REVISION: 1
-#===============================================================================
-
-use strict;
-
-use lib qw(. lib);
-
-use Bugzilla;
-use Bugzilla::Constants;
-use Bugzilla::Field;
-use Bugzilla::User;
-use Bugzilla::Keyword;
-
-use Getopt::Long;
-use Term::ANSIColor qw(colored);
-
-Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
-
-my ($remove_whiteboard, $help, $doit);
-GetOptions("r|remove" => \$remove_whiteboard,
- "h|help" => \$help, 'doit' => \$doit);
-
-sub usage {
- my $error = shift || "";
- print colored(['red'], $error) if $error;
- print <<USAGE;
-Usage: migrate_orange_bugs.pl [--remove|-r] [--help|-h] [--doit]
-
-E.g.: migrate_orange_bugs.pl --remove --doit
-This script will add the intermittent-failure keyword to any bugs that
-contant [orange] in the status whiteboard. If the --remove option is
-given, then [orange] will be removed from the whiteboard as well.
-
-Pass --doit to make the database changes permanent.
-USAGE
- exit(1);
-}
-
-# Exit if help was requested
-usage() if $help;
-
-# User to make changes as
-my $user_id = login_to_id('nobody@mozilla.org');
-$user_id or usage("Can't find user ID for 'nobody\@mozilla.org'\n");
-
-my $keywords_field_id = get_field_id('keywords');
-$keywords_field_id or usage("Can't find field ID for 'keywords' field\n");
-
-my $whiteboard_field_id = get_field_id('status_whiteboard');
-$whiteboard_field_id or usage("Can't find field ID for 'whiteboard' field\n");
-
-# intermittent-keyword id (assumes already created)
-my $keyword_obj = Bugzilla::Keyword->new({ name => 'intermittent-failure' });
-$keyword_obj or usage("Can't find keyword id for 'intermittent-failure'\n");
-my $keyword_id = $keyword_obj->id;
-
-my $dbh = Bugzilla->dbh;
-
-my $bugs = $dbh->selectall_arrayref("
- SELECT DISTINCT bugs.bug_id, bugs.status_whiteboard
- FROM bugs WHERE bugs.status_whiteboard LIKE '%[orange]%'
- OR bugs.status_whiteboard LIKE '%[tb-orange]%'",
- {'Slice' => {}});
-
-my $bug_count = scalar @$bugs;
-$bug_count or usage("No bugs were found in matching search criteria.\n");
-
-print colored(['green'], "Processing $bug_count [orange] bugs\n");
-
-$dbh->bz_start_transaction() if $doit;
-
-foreach my $bug (@$bugs) {
- my $bug_id = $bug->{'bug_id'};
- my $whiteboard = $bug->{'status_whiteboard'};
-
- print "Checking bug $bug_id ... ";
-
- my $timestamp = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)');
-
- my $keyword_present = $dbh->selectrow_array("
- SELECT bug_id FROM keywords WHERE bug_id = ? AND keywordid = ?",
- undef, $bug_id, $keyword_id);
-
- if (!$keyword_present) {
- print "adding keyword ... ";
-
- if ($doit) {
- $dbh->do("INSERT INTO keywords (bug_id, keywordid) VALUES (?, ?)",
- undef, $bug_id, $keyword_id);
- $dbh->do("INSERT INTO bugs_activity(bug_id, who, bug_when, fieldid, removed, added) " .
- "VALUES (?, ?, ?, ?, '', 'intermittent-failure')",
- undef, $bug_id, $user_id, $timestamp, $keywords_field_id);
- $dbh->do("UPDATE bugs SET delta_ts = ?, lastdiffed = ? WHERE bug_id = ?",
- undef, $timestamp, $timestamp, $bug_id);
- }
- }
-
- if ($remove_whiteboard) {
- print "removing whiteboard ... ";
-
- if ($doit) {
- my $old_whiteboard = $whiteboard;
- $whiteboard =~ s/\[(tb-)?orange\]//ig;
-
- $dbh->do("UPDATE bugs SET status_whiteboard = ? WHERE bug_id = ?",
- undef, $whiteboard, $bug_id);
- $dbh->do("INSERT INTO bugs_activity(bug_id, who, bug_when, fieldid, removed, added) " .
- "VALUES (?, ?, ?, ?, ?, ?)",
- undef, $bug_id, $user_id, $timestamp, $whiteboard_field_id, $old_whiteboard, $whiteboard);
- $dbh->do("UPDATE bugs SET delta_ts = ?, lastdiffed = ? WHERE bug_id = ?",
- undef, $timestamp, $timestamp, $bug_id);
- }
- }
-
- print "done.\n";
-}
-
-$dbh->bz_commit_transaction() if $doit;
-
-if ($doit) {
- # It's complex to determine which items now need to be flushed from memcached.
- # As this is expected to be a rare event, we just flush the entire cache.
- Bugzilla->memcached->clear_all();
-
- print colored(['green'], "DATABASE WAS UPDATED\n");
-}
-else {
- print colored(['red'], "DATABASE WAS NOT UPDATED\n");
-}
-
-exit(0);
diff --git a/contrib/reorg-tools/move_dupes_to_invalid.pl b/contrib/reorg-tools/move_dupes_to_invalid.pl
deleted file mode 100755
index 25106ce9c..000000000
--- a/contrib/reorg-tools/move_dupes_to_invalid.pl
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/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 '$RealBin';
-use lib "$RealBin/../..", "$RealBin/../../lib";
-
-use Bugzilla;
-use Bugzilla::User;
-use Bugzilla::Constants;
-use Bugzilla::Util qw(detaint_natural);
-use Bugzilla::Install::Util qw(indicate_progress);
-
-use Pod::Usage;
-
-BEGIN { Bugzilla->extensions(); }
-
-Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
-
-pod2usage(1) unless @ARGV;
-
-my $dbh = Bugzilla->dbh;
-
-# Allow nobody@mozilla.org to edit bugs
-my $user = Bugzilla::User->check({ name => 'nobody@mozilla.org' });
-Bugzilla->set_user($user);
-$user->{'groups'} = [ Bugzilla::Group->new({ name => 'editbugs' }) ];
-
-my $timestamp = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)');
-
-foreach my $dupe_of_bug (@ARGV) {
- detaint_natural($dupe_of_bug) || pod2usage(1);
- my $duped_bugs = $dbh->selectcol_arrayref("
- SELECT DISTINCT dupe FROM duplicates WHERE dupe_of = ?",
- undef, $dupe_of_bug);
- my $bug_count = @$duped_bugs;
-
- die "There are no duplicate bugs to move for bug $dupe_of_bug.\n"
- if $bug_count == 0;
-
- print STDERR <<EOF;
-Moving $bug_count duplicate bugs from bug $dupe_of_bug to the 'Invalid Bugs' product.
-
-Press <Ctrl-C> to stop or <Enter> to continue...
-EOF
- getc();
-
- $dbh->bz_start_transaction;
- my $count = 0;
- foreach my $duped_bug_id (@$duped_bugs) {
- # Change product to "Invalid Bugs" and component to "General"
- # Change resolution to "INVALID" instead of duplicate
- # Change version to "unspecified" and milestone to "---"
- # Reset assignee to default
- # Reset QA contact to default
- my $bug_obj = Bugzilla::Bug->new($duped_bug_id);
- my $params = {
- product => 'Invalid Bugs',
- component => 'General',
- resolution => 'INVALID',
- version => 'unspecified',
- target_milestone => '---',
- reset_assigned_to => 1,
- reset_qa_contact => 1
- };
- $params->{bug_status} = 'RESOLVED' if $bug_obj->status->is_open;
- $bug_obj->set_all($params);
- $bug_obj->update($timestamp);
-
- $dbh->do("UPDATE bugs SET delta_ts = ?, lastdiffed = ? WHERE bug_id = ?",
- undef, $timestamp, $timestamp, $duped_bug_id);
-
- $count++;
- indicate_progress({ current => $count, total => $bug_count, every => 1 });
- }
-
- Bugzilla::Hook::process('reorg_move_bugs', { bug_ids => [ $dupe_of_bug, @$duped_bugs ] });
-
- $dbh->bz_commit_transaction();
-}
-
-# It's complex to determine which items now need to be flushed from memcached.
-# As this is expected to be a rare event, we just flush the entire cache.
-Bugzilla->memcached->clear_all();
-
-__END__
-
-=head1 NAME
-
-move_dupes_to_invalid.pl - Script used to move dupes of a given bug to the 'Invalid Bugs' product.
-
-=head1 SYNOPSIS
-
- move_dupes_to_invalid.pl <bug_id> [<bug_id> ...]
diff --git a/contrib/reorg-tools/move_flag_types.pl b/contrib/reorg-tools/move_flag_types.pl
deleted file mode 100755
index 7b7fe2081..000000000
--- a/contrib/reorg-tools/move_flag_types.pl
+++ /dev/null
@@ -1,172 +0,0 @@
-#!/usr/bin/perl
-# -*- Mode: perl; indent-tabs-mode: nil -*-
-#
-# The contents of this file are subject to the Mozilla Public
-# License Version 1.1 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# The Initial Developer of the Original Code is Mozilla Foundation
-# Portions created by the Initial Developer are Copyright (C) 2011 the
-# Initial Developer. All Rights Reserved.
-#
-#===============================================================================
-#
-# FILE: move_flag_types.pl
-#
-# USAGE: ./move_flag_types.pl
-#
-# DESCRIPTION: Move current set flag from one type_id to another
-# based on product and optionally component.
-#
-# OPTIONS: ---
-# REQUIREMENTS: ---
-# BUGS: ---
-# NOTES: ---
-# AUTHOR: David Lawrence (:dkl), dkl@mozilla.com
-# COMPANY: Mozilla Foundation
-# VERSION: 1.0
-# CREATED: 08/22/2011 05:18:06 PM
-# REVISION: ---
-#===============================================================================
-
-=head1 NAME
-
-move_flag_types.pl - Move currently set flags from one type id to another based
-on product and optionally component.
-
-=head1 SYNOPSIS
-
-This script will move bugs matching a specific product (and optionally a component)
-from one flag type id to another if the bug has the flag set to either +, -, or ?.
-
-./move_flag_types.pl --old-id 4 --new-id 720 --product Firefox --component Installer
-
-=head1 OPTIONS
-
-=over
-
-=item B<--help|-h|?>
-
-Print a brief help message and exits.
-
-=item B<--oldid|-o>
-
-Old flag type id. Use editflagtypes.cgi to determine the type id from the URL.
-
-=item B<--newid|-n>
-
-New flag type id. Use editflagtypes.cgi to determine the type id from the URL.
-
-=item B<--product|-p>
-
-The product that the bugs most be assigned to.
-
-=item B<--component|-c>
-
-Optional: The component of the given product that the bugs must be assigned to.
-
-=item B<--doit|-d>
-
-Without this argument, changes are not actually committed to the database.
-
-=back
-
-=cut
-
-use strict;
-use warnings;
-
-use lib '.';
-
-use Bugzilla;
-use Getopt::Long;
-use Pod::Usage;
-
-my %params;
-GetOptions(\%params, 'help|h|?', 'oldid|o=s', 'newid|n=s',
- 'product|p=s', 'component|c:s', 'doit|d') or pod2usage(1);
-
-if ($params{'help'} || !$params{'oldid'}
- || !$params{'newid'} || !$params{'product'}) {
- pod2usage({ -message => "Missing required argument",
- -exitval => 1 });
-}
-
-# Set defaults
-$params{'doit'} ||= 0;
-$params{'component'} ||= '';
-
-my $dbh = Bugzilla->dbh;
-
-# Get the flag names
-my $old_flag_name = $dbh->selectrow_array(
- "SELECT name FROM flagtypes WHERE id = ?",
- undef, $params{'oldid'});
-my $new_flag_name = $dbh->selectrow_array(
- "SELECT name FROM flagtypes WHERE id = ?",
- undef, $params{'newid'});
-
-# Find the product id
-my $product_id = $dbh->selectrow_array(
- "SELECT id FROM products WHERE name = ?",
- undef, $params{'product'});
-
-# Find the component id if not __ANY__
-my $component_id;
-if ($params{'component'}) {
- $component_id = $dbh->selectrow_array(
- "SELECT id FROM components WHERE name = ? AND product_id = ?",
- undef, $params{'component'}, $product_id);
-}
-
-my @query_args = ($params{'oldid'});
-
-my $flag_query = "SELECT flags.id AS flag_id, flags.bug_id AS bug_id
- FROM flags JOIN bugs ON flags.bug_id = bugs.bug_id
- WHERE flags.type_id = ? ";
-
-if ($component_id) {
- # No need to compare against product_id as component_id is already
- # tied to a specific product
- $flag_query .= "AND bugs.component_id = ?";
- push(@query_args, $component_id);
-}
-else {
- # All bugs for a product regardless of component
- $flag_query .= "AND bugs.product_id = ?";
- push(@query_args, $product_id);
-}
-
-my $flags = $dbh->selectall_arrayref($flag_query, undef, @query_args);
-
-if (@$flags) {
- print "Moving '" . scalar @$flags . "' flags " .
- "from $old_flag_name (" . $params{'oldid'} . ") " .
- "to $new_flag_name (" . $params{'newid'} . ")...\n";
-
- if (!$params{'doit'}) {
- print "Pass the argument --doit or -d to permanently make changes to the database.\n";
- }
- else {
- my $flag_update_sth = $dbh->prepare("UPDATE flags SET type_id = ? WHERE id = ?");
-
- foreach my $flag (@$flags) {
- my ($flag_id, $bug_id) = @$flag;
- print "Bug: $bug_id Flag: $flag_id\n";
- $flag_update_sth->execute($params{'newid'}, $flag_id);
- }
- }
-
- # It's complex to determine which items now need to be flushed from memcached.
- # As this is expected to be a rare event, we just flush the entire cache.
- Bugzilla->memcached->clear_all();
-}
-else {
- print "No flags to move\n";
-}
diff --git a/contrib/reorg-tools/move_os.pl b/contrib/reorg-tools/move_os.pl
deleted file mode 100755
index 96b58d616..000000000
--- a/contrib/reorg-tools/move_os.pl
+++ /dev/null
@@ -1,81 +0,0 @@
-#!/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 5.10.1;
-use strict;
-use warnings;
-
-use FindBin '$RealBin';
-use lib "$RealBin/../..", "$RealBin/../../lib";
-
-use Bugzilla;
-use Bugzilla::Field;
-use Bugzilla::Constants;
-
-use Getopt::Long qw( :config gnu_getopt );
-use Pod::Usage;
-
-Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
-
-my ($from_os, $to_os);
-GetOptions('from=s' => \$from_os, 'to=s' => \$to_os);
-
-pod2usage(1) unless defined $from_os && defined $to_os;
-
-
-my $check_from_os = Bugzilla::Field::Choice->type('op_sys')->match({ value => $from_os });
-my $check_to_os = Bugzilla::Field::Choice->type('op_sys')->match({ value => $to_os });
-die "Cannot move $from_os because it does not exist\n"
- unless @$check_from_os == 1;
-die "Cannot move $from_os because $to_os doesn't exist.\n"
- unless @$check_to_os == 1;
-
-my $dbh = Bugzilla->dbh;
-my $timestamp = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)');
-my $bug_ids = $dbh->selectcol_arrayref(q{SELECT bug_id FROM bugs WHERE bugs.op_sys = ?}, undef, $from_os);
-my $field = Bugzilla::Field->check({ name => 'op_sys', cache => 1 });
-my $nobody = Bugzilla::User->check({ name => 'nobody@mozilla.org', cache => 1 });
-
-my $bug_count = @$bug_ids;
-if ($bug_count == 0) {
- warn "There are no bugs to move.\n";
- exit 1;
-}
-
-print STDERR <<EOF;
-About to move $bug_count bugs from $from_os to $to_os.
-
-Press <Ctrl-C> to stop or <Enter> to continue...
-EOF
-getc();
-
-$dbh->bz_start_transaction;
-foreach my $bug_id (@$bug_ids) {
- warn "Moving $bug_id...\n";
-
- $dbh->do(q{INSERT INTO bugs_activity(bug_id, who, bug_when, fieldid, removed, added)
- VALUES (?, ?, ?, ?, ?, ?)},
- undef, $bug_id, $nobody->id, $timestamp, $field->id, $from_os, $to_os);
- $dbh->do(q{UPDATE bugs SET op_sys = ?, delta_ts = ?, lastdiffed = ? WHERE bug_id = ?},
- undef, $to_os, $timestamp, $timestamp, $bug_id);
-}
-$dbh->bz_commit_transaction;
-
-# It's complex to determine which items now need to be flushed from memcached.
-# As this is expected to be a rare event, we just flush the entire cache.
-Bugzilla->memcached->clear_all();
-
-__END__
-
-=head1 NAME
-
-move_os.pl - move the os on all bugs with a particular os to a new os
-
-=head1 SYNOPSIS
-
- move_os.pl --from 'Windows 8 Metro' --to 'Windows 8.1'
diff --git a/contrib/reorg-tools/movebugs.pl b/contrib/reorg-tools/movebugs.pl
deleted file mode 100755
index 7ffca3615..000000000
--- a/contrib/reorg-tools/movebugs.pl
+++ /dev/null
@@ -1,182 +0,0 @@
-#!/usr/bin/perl -w
-use strict;
-
-use Cwd 'abs_path';
-use File::Basename;
-use FindBin;
-use lib "$FindBin::Bin/../..";
-use lib "$FindBin::Bin/../../lib";
-
-use Bugzilla;
-use Bugzilla::Constants;
-use Bugzilla::FlagType;
-use Bugzilla::Hook;
-use Bugzilla::Util;
-
-Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
-
-if (scalar @ARGV < 4) {
- die <<USAGE;
-Usage: movebugs.pl <old-product> <old-component> <new-product> <new-component>
-
-Eg. movebugs.pl mozilla.org bmo bugzilla.mozilla.org admin
-Will move all bugs in the mozilla.org:bmo component to the
-bugzilla.mozilla.org:admin component.
-
-The new product must have matching versions, milestones, and flags from the old
-product (will be validated by this script).
-USAGE
-}
-
-my ($old_product, $old_component, $new_product, $new_component) = @ARGV;
-
-my $dbh = Bugzilla->dbh;
-
-my $old_product_id = $dbh->selectrow_array(
- "SELECT id FROM products WHERE name=?",
- undef, $old_product);
-$old_product_id
- or die "Can't find product ID for '$old_product'.\n";
-
-my $old_component_id = $dbh->selectrow_array(
- "SELECT id FROM components WHERE name=? AND product_id=?",
- undef, $old_component, $old_product_id);
-$old_component_id
- or die "Can't find component ID for '$old_component'.\n";
-
-my $new_product_id = $dbh->selectrow_array(
- "SELECT id FROM products WHERE name=?",
- undef, $new_product);
-$new_product_id
- or die "Can't find product ID for '$new_product'.\n";
-
-my $new_component_id = $dbh->selectrow_array(
- "SELECT id FROM components WHERE name=? AND product_id=?",
- undef, $new_component, $new_product_id);
-$new_component_id
- or die "Can't find component ID for '$new_component'.\n";
-
-my $product_field_id = $dbh->selectrow_array(
- "SELECT id FROM fielddefs WHERE name = 'product'");
-$product_field_id
- or die "Can't find field ID for 'product' field\n";
-my $component_field_id = $dbh->selectrow_array(
- "SELECT id FROM fielddefs WHERE name = 'component'");
-$component_field_id
- or die "Can't find field ID for 'component' field\n";
-
-my $user_id = $dbh->selectrow_array(
- "SELECT userid FROM profiles WHERE login_name='nobody\@mozilla.org'");
-$user_id
- or die "Can't find user ID for 'nobody\@mozilla.org'\n";
-
-$dbh->bz_start_transaction();
-
-# build list of bugs
-my $ra_ids = $dbh->selectcol_arrayref(
- "SELECT bug_id FROM bugs WHERE product_id=? AND component_id=?",
- undef, $old_product_id, $old_component_id);
-my $bug_count = scalar @$ra_ids;
-$bug_count
- or die "No bugs were found in '$old_component'\n";
-my $where_sql = 'bug_id IN (' . join(',', @$ra_ids) . ')';
-
-# check versions
-my @missing_versions;
-my $ra_versions = $dbh->selectcol_arrayref(
- "SELECT DISTINCT version FROM bugs WHERE $where_sql");
-foreach my $version (@$ra_versions) {
- my $has_version = $dbh->selectrow_array(
- "SELECT 1 FROM versions WHERE product_id=? AND value=?",
- undef, $new_product_id, $version);
- push @missing_versions, $version unless $has_version;
-}
-
-# check milestones
-my @missing_milestones;
-my $ra_milestones = $dbh->selectcol_arrayref(
- "SELECT DISTINCT target_milestone FROM bugs WHERE $where_sql");
-foreach my $milestone (@$ra_milestones) {
- my $has_milestone = $dbh->selectrow_array(
- "SELECT 1 FROM milestones WHERE product_id=? AND value=?",
- undef, $new_product_id, $milestone);
- push @missing_milestones, $milestone unless $has_milestone;
-}
-
-# check flags
-my @missing_flags;
-my $ra_old_types = $dbh->selectcol_arrayref(
- "SELECT DISTINCT type_id
- FROM flags
- INNER JOIN flagtypes ON flagtypes.id = flags.type_id
- WHERE $where_sql");
-my $ra_new_types =
- Bugzilla::FlagType::match({ product_id => $new_product_id,
- component_id => $new_component_id });
-foreach my $old_type (@$ra_old_types) {
- unless (grep { $_->id == $old_type } @$ra_new_types) {
- my $flagtype = Bugzilla::FlagType->new($old_type);
- push @missing_flags, $flagtype->name . ' (' . $flagtype->target_type . ')';
- }
-}
-
-# show missing
-my $missing_error = '';
-if (@missing_versions) {
- $missing_error .= "'$new_product' is missing the following version(s):\n " .
- join("\n ", @missing_versions) . "\n";
-}
-if (@missing_milestones) {
- $missing_error .= "'$new_product' is missing the following milestone(s):\n " .
- join("\n ", @missing_milestones) . "\n";
-}
-if (@missing_flags) {
- $missing_error .= "'$new_product'::'$new_component' is missing the following flag(s):\n " .
- join("\n ", @missing_flags) . "\n";
-}
-die $missing_error if $missing_error;
-
-# confirmation
-print <<EOF;
-About to move $bug_count bugs
-From '$old_product' : '$old_component'
-To '$new_product' : '$new_component'
-
-Press <Ctrl-C> to stop or <Enter> to continue...
-EOF
-getc();
-
-print "Moving $bug_count bugs from $old_product:$old_component to $new_product:$new_component\n";
-
-# update bugs
-$dbh->do(
- "UPDATE bugs SET product_id=?, component_id=? WHERE $where_sql",
- undef, $new_product_id, $new_component_id);
-
-# touch bugs
-$dbh->do("UPDATE bugs SET delta_ts=NOW() WHERE $where_sql");
-$dbh->do("UPDATE bugs SET lastdiffed=NOW() WHERE $where_sql");
-
-# update bugs_activity
-$dbh->do(
- "INSERT INTO bugs_activity(bug_id, who, bug_when, fieldid, removed, added)
- SELECT bug_id, ?, delta_ts, ?, ?, ? FROM bugs WHERE $where_sql",
- undef,
- $user_id, $product_field_id, $old_product, $new_product);
-$dbh->do(
- "INSERT INTO bugs_activity(bug_id, who, bug_when, fieldid, removed, added)
- SELECT bug_id, ?, delta_ts, ?, ?, ? FROM bugs WHERE $where_sql",
- undef,
- $user_id, $component_field_id, $old_component, $new_component);
-
-Bugzilla::Hook::process('reorg_move_bugs', { bug_ids => $ra_ids } );
-
-$dbh->bz_commit_transaction();
-
-foreach my $bug_id (@$ra_ids) {
- Bugzilla->memcached->clear({ table => 'bugs', id => $bug_id });
-}
-
-# It's complex to determine which items now need to be flushed from memcached.
-# As this is expected to be a rare event, we just flush the entire cache.
-Bugzilla->memcached->clear_all();
diff --git a/contrib/reorg-tools/movecomponent.pl b/contrib/reorg-tools/movecomponent.pl
deleted file mode 100755
index cb07b84fc..000000000
--- a/contrib/reorg-tools/movecomponent.pl
+++ /dev/null
@@ -1,154 +0,0 @@
-#!/usr/bin/perl -w
-# 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 FindBin '$RealBin';
-use lib "$RealBin/../..", "$RealBin/../../lib";
-
-use Bugzilla;
-use Bugzilla::Component;
-use Bugzilla::Constants;
-use Bugzilla::Field;
-use Bugzilla::Hook;
-use Bugzilla::Product;
-use Bugzilla::Util;
-
-Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
-
-if (scalar @ARGV < 3) {
- die <<USAGE;
-Usage: movecomponent.pl <oldproduct> <newproduct> <component>
-
-E.g.: movecomponent.pl ReplicationEngine FoodReplicator SeaMonkey
-will move the component "SeaMonkey" from the product "ReplicationEngine"
-to the product "FoodReplicator".
-
-Important: You must make sure the milestones and versions of the bugs in the
-component are available in the new product. See syncmsandversions.pl.
-
-USAGE
-}
-
-my ($old_product_name, $new_product_name, $component_name) = @ARGV;
-my $old_product = Bugzilla::Product->check({ name => $old_product_name });
-my $new_product = Bugzilla::Product->check({ name => $new_product_name });
-my $component = Bugzilla::Component->check({ product => $old_product, name => $component_name });
-my $field_id = get_field_id('product');
-
-my $dbh = Bugzilla->dbh;
-
-# check versions
-my @missing_versions;
-my $ra_versions = $dbh->selectcol_arrayref(
- "SELECT DISTINCT version FROM bugs WHERE component_id = ?",
- undef, $component->id);
-foreach my $version (@$ra_versions) {
- my $has_version = $dbh->selectrow_array(
- "SELECT 1 FROM versions WHERE product_id = ? AND value = ?",
- undef, $new_product->id, $version);
- push @missing_versions, $version unless $has_version;
-}
-
-# check milestones
-my @missing_milestones;
-my $ra_milestones = $dbh->selectcol_arrayref(
- "SELECT DISTINCT target_milestone FROM bugs WHERE component_id = ?",
- undef, $component->id);
-foreach my $milestone (@$ra_milestones) {
- my $has_milestone = $dbh->selectrow_array(
- "SELECT 1 FROM milestones WHERE product_id=? AND value=?",
- undef, $new_product->id, $milestone);
- push @missing_milestones, $milestone unless $has_milestone;
-}
-
-my $missing_error = '';
-if (@missing_versions) {
- $missing_error .= "'$new_product_name' is missing the following version(s):\n " .
- join("\n ", @missing_versions) . "\n";
-}
-if (@missing_milestones) {
- $missing_error .= "'$new_product_name' is missing the following milestone(s):\n " .
- join("\n ", @missing_milestones) . "\n";
-}
-die $missing_error if $missing_error;
-
-# confirmation
-print <<EOF;
-About to move the component '$component_name'
-From '$old_product_name'
-To '$new_product_name'
-
-Press <Ctrl-C> to stop or <Enter> to continue...
-EOF
-getc();
-
-print "Moving '$component_name' from '$old_product_name' to '$new_product_name'...\n\n";
-$dbh->bz_start_transaction();
-
-my $ra_ids = $dbh->selectcol_arrayref(
- "SELECT bug_id FROM bugs WHERE product_id=? AND component_id=?",
- undef, $old_product->id, $component->id);
-
-# Bugs table
-$dbh->do("UPDATE bugs SET product_id = ? WHERE component_id = ?",
- undef,
- ($new_product->id, $component->id));
-
-# Flags tables
-fix_flags('flaginclusions', $new_product, $component);
-fix_flags('flagexclusions', $new_product, $component);
-
-# Components
-$dbh->do("UPDATE components SET product_id = ? WHERE id = ?",
- undef,
- ($new_product->id, $component->id));
-
-Bugzilla::Hook::process('reorg_move_component', {
- old_product => $old_product,
- new_product => $new_product,
- component => $component,
-} );
-
-# Mark bugs as touched
-$dbh->do("UPDATE bugs SET delta_ts = NOW()
- WHERE component_id = ?", undef, $component->id);
-$dbh->do("UPDATE bugs SET lastdiffed = NOW()
- WHERE component_id = ?", undef, $component->id);
-
-# Update bugs_activity
-my $userid = 1; # nobody@mozilla.org
-
-$dbh->do("INSERT INTO bugs_activity(bug_id, who, bug_when, fieldid, removed,
- added)
- SELECT bug_id, ?, delta_ts, ?, ?, ?
- FROM bugs WHERE component_id = ?",
- undef,
- ($userid, $field_id, $old_product_name, $new_product_name, $component->id));
-
-Bugzilla::Hook::process('reorg_move_bugs', { bug_ids => $ra_ids } );
-
-$dbh->bz_commit_transaction();
-
-# It's complex to determine which items now need to be flushed from memcached.
-# As this is expected to be a rare event, we just flush the entire cache.
-Bugzilla->memcached->clear_all();
-
-sub fix_flags {
- my ($table, $new_product, $component) = @_;
- my $dbh = Bugzilla->dbh;
-
- my $type_ids = $dbh->selectcol_arrayref("SELECT DISTINCT type_id FROM $table WHERE component_id = ?",
- undef,
- $component->id);
- $dbh->do("DELETE FROM $table WHERE component_id = ?", undef, $component->id);
- foreach my $type_id (@$type_ids) {
- $dbh->do("INSERT INTO $table (type_id, product_id, component_id) VALUES (?, ?, ?)",
- undef, ($type_id, $new_product->id, $component->id));
- }
-}
diff --git a/contrib/reorg-tools/reassign_open_bugs.pl b/contrib/reorg-tools/reassign_open_bugs.pl
deleted file mode 100755
index 6496f9a95..000000000
--- a/contrib/reorg-tools/reassign_open_bugs.pl
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/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 5.10.1;
-use strict;
-use warnings;
-
-use FindBin '$RealBin';
-use lib "$RealBin/../..", "$RealBin/../../lib";
-
-use Bugzilla;
-use Bugzilla::User;
-use Bugzilla::Constants;
-
-use Getopt::Long qw( :config gnu_getopt );
-use Pod::Usage;
-
-# Load extensions for monkeypatched $user->clear_last_statistics_ts()
-BEGIN { Bugzilla->extensions(); }
-
-Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
-
-my ($from, $to);
-GetOptions(
- "from|f=s" => \$from,
- "to|t=s" => \$to,
-);
-
-pod2usage(1) unless defined $from && defined $to;
-
-my $dbh = Bugzilla->dbh;
-
-my $timestamp = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)');
-my $field = Bugzilla::Field->check({ name => 'assigned_to', cache => 1 });
-my $from_user = Bugzilla::User->check({ name => $from, cache => 1 });
-my $to_user = Bugzilla::User->check({ name => $to, cache => 1 });
-
-my $bugs = $dbh->selectcol_arrayref(q{SELECT bug_id
- FROM bugs
- LEFT JOIN bug_status
- ON bug_status.value = bugs.bug_status
- WHERE bug_status.is_open = 1
- AND bugs.assigned_to = ?}, undef, $from_user->id);
-my $bug_count = @$bugs;
-if ($bug_count == 0) {
- warn "There are no bugs to move.\n";
- exit 1;
-}
-
-print STDERR <<EOF;
-About to move $bug_count bugs from $from to $to.
-
-Press <Ctrl-C> to stop or <Enter> to continue...
-EOF
-getc();
-
-$dbh->bz_start_transaction;
-foreach my $bug_id (@$bugs) {
- warn "Updating bug $bug_id\n";
- $dbh->do(q{INSERT INTO bugs_activity(bug_id, who, bug_when, fieldid, removed, added)
- VALUES (?, ?, ?, ?, ?, ?)},
- undef, $bug_id, $to_user->id, $timestamp, $field->id, $from_user->login, $to_user->login);
- $dbh->do(q{UPDATE bugs SET assigned_to = ?, delta_ts = ?, lastdiffed = ? WHERE bug_id = ?},
- undef, $to_user->id, $timestamp, $timestamp, $bug_id);
-}
-$from_user->clear_last_statistics_ts();
-$to_user->clear_last_statistics_ts();
-$dbh->bz_commit_transaction;
-
-# It's complex to determine which items now need to be flushed from memcached.
-# As this is expected to be a rare event, we just flush the entire cache.
-Bugzilla->memcached->clear_all();
-
-__END__
-
-=head1 NAME
-
-reassign-open-bugs.pl - reassign all open bugs from one user to another.
-
-=head1 SYNOPSIS
-
- reassign-open-bugs.pl --from general@js.bugs --to nobody@mozilla.org
diff --git a/contrib/reorg-tools/reset_default_user.pl b/contrib/reorg-tools/reset_default_user.pl
deleted file mode 100755
index 173d03849..000000000
--- a/contrib/reorg-tools/reset_default_user.pl
+++ /dev/null
@@ -1,145 +0,0 @@
-#!/usr/bin/perl -wT
-# 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 lib '.';
-
-use Bugzilla;
-use Bugzilla::Constants;
-use Bugzilla::User;
-use Bugzilla::Field;
-use Bugzilla::Util qw(trick_taint);
-
-use Getopt::Long;
-
-Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
-
-my $dbh = Bugzilla->dbh;
-
-my $field_name = "";
-my $product = "";
-my $component = "";
-my $help = "";
-my %user_cache = ();
-
-my $result = GetOptions('field=s' => \$field_name,
- 'product=s' => \$product,
- 'component=s' => \$component,
- 'help|h' => \$help);
-
-sub usage {
- print <<USAGE;
-Usage: reset_default_user.pl --field <fieldname> --product <product> [--component <component>] [--help]
-
-This script will load all bugs matching the product, and optionally component,
-and reset the default user value back to the default value for the component.
-Valid field names are assigned_to and qa_contact.
-USAGE
-}
-
-if (!$product || $help
- || ($field_name ne 'assigned_to' && $field_name ne 'qa_contact'))
-{
- usage();
- exit(1);
-}
-
-# We will need these for entering into bugs_activity
-my $who = Bugzilla::User->new({ name => 'nobody@mozilla.org' });
-my $field = Bugzilla::Field->new({ name => $field_name });
-
-trick_taint($product);
-my $product_id = $dbh->selectrow_array(
- "SELECT id FROM products WHERE name = ?",
- undef, $product);
-$product_id or die "Can't find product ID for '$product'.\n";
-
-my $component_id;
-my $default_user_id;
-if ($component) {
- trick_taint($component);
- my $colname = $field->name eq 'qa_contact'
- ? 'initialqacontact'
- : 'initialowner';
- ($component_id, $default_user_id) = $dbh->selectrow_array(
- "SELECT id, $colname FROM components " .
- "WHERE name = ? AND product_id = ?",
- undef, $component, $product_id);
- $component_id or die "Can't find component ID for '$component'.\n";
- $user_cache{$default_user_id} ||= Bugzilla::User->new($default_user_id);
-}
-
-# build list of bugs
-my $bugs_query = "SELECT bug_id, qa_contact, component_id " .
- "FROM bugs WHERE product_id = ?";
-my @args = ($product_id);
-
-if ($component_id) {
- $bugs_query .= " AND component_id = ? AND qa_contact != ?";
- push(@args, $component_id, $default_user_id);
-}
-
-my $bugs = $dbh->selectall_arrayref($bugs_query, {Slice => {}}, @args);
-my $bug_count = scalar @$bugs;
-$bug_count
- or die "No bugs were found.\n";
-
-# confirmation
-print <<EOF;
-About to reset $field_name for $bug_count bugs.
-
-Press <Ctrl-C> to stop or <Enter> to continue...
-EOF
-getc();
-
-$dbh->bz_start_transaction();
-
-foreach my $bug (@$bugs) {
- my $bug_id = $bug->{bug_id};
- my $old_user_id = $bug->{$field->name};
- my $old_comp_id = $bug->{component_id};
-
- # If only changing one component, we already have the default user id
- my $new_user_id;
- if ($default_user_id) {
- $new_user_id = $default_user_id;
- }
- else {
- my $colname = $field->name eq 'qa_contact'
- ? 'initialqacontact'
- : 'initialowner';
- $new_user_id = $dbh->selectrow_array(
- "SELECT $colname FROM components WHERE id = ?",
- undef, $old_comp_id);
- }
-
- if ($old_user_id != $new_user_id) {
- print "Resetting " . $field->name . " for bug $bug_id ...";
-
- # Use the cached version if already exists
- my $old_user = $user_cache{$old_user_id} ||= Bugzilla::User->new($old_user_id);
- my $new_user = $user_cache{$new_user_id} ||= Bugzilla::User->new($new_user_id);
-
- my $timestamp = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)');
-
- $dbh->do("UPDATE bugs SET " . $field->name . " = ? WHERE bug_id = ?",
- undef, $new_user_id, $bug_id);
- $dbh->do("INSERT INTO bugs_activity(bug_id, who, bug_when, fieldid, removed, added) " .
- "VALUES (?, ?, ?, ?, ?, ?)",
- undef, $bug_id, $who->id, $timestamp, $field->id, $old_user->login, $new_user->login);
- $dbh->do("UPDATE bugs SET delta_ts = ?, lastdiffed = ? WHERE bug_id = ?",
- undef, $timestamp, $timestamp, $bug_id);
-
- Bugzilla->memcached->clear({ table => 'bugs', id => $bug_id });
-
- print "done.\n";
- }
-}
-
-$dbh->bz_commit_transaction();
diff --git a/contrib/reorg-tools/syncflags.pl b/contrib/reorg-tools/syncflags.pl
deleted file mode 100755
index 8e039f7bb..000000000
--- a/contrib/reorg-tools/syncflags.pl
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/usr/bin/perl -w
-# -*- Mode: perl; indent-tabs-mode: nil -*-
-#
-# The contents of this file are subject to the Mozilla Public
-# License Version 1.1 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# The Original Code is the Bugzilla Bug Tracking System.
-#
-# The Initial Developer of the Original Code is Netscape Communications
-# Corporation. Portions created by Netscape are
-# Copyright (C) 1998 Netscape Communications Corporation. All
-# Rights Reserved.
-#
-# Contributor(s): Gervase Markham <gerv@gerv.net>
-
-# See also https://bugzilla.mozilla.org/show_bug.cgi?id=119569
-
-use strict;
-
-use lib qw(. lib);
-
-use Bugzilla;
-use Bugzilla::Constants;
-
-sub usage() {
- print <<USAGE;
-Usage: syncflags.pl <srcproduct> <tgtproduct>
-
-E.g.: syncflags.pl FoodReplicator SeaMonkey
-will copy any flag inclusions (only) for the product "FoodReplicator"
-so matching inclusions exist for the product "SeaMonkey". This script is
-normally used prior to moving components from srcproduct to tgtproduct.
-USAGE
-
- exit(1);
-}
-
-#############################################################################
-# MAIN CODE
-#############################################################################
-
-# This is a pure command line script.
-Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
-
-if (scalar @ARGV < 2) {
- usage();
- exit();
-}
-
-my ($srcproduct, $tgtproduct) = @ARGV;
-
-my $dbh = Bugzilla->dbh;
-
-# Find product IDs
-my $srcprodid = $dbh->selectrow_array("SELECT id FROM products WHERE name = ?",
- undef, $srcproduct);
-if (!$srcprodid) {
- print "Can't find product ID for '$srcproduct'.\n";
- exit(1);
-}
-
-my $tgtprodid = $dbh->selectrow_array("SELECT id FROM products WHERE name = ?",
- undef, $tgtproduct);
-if (!$tgtprodid) {
- print "Can't find product ID for '$tgtproduct'.\n";
- exit(1);
-}
-
-$dbh->do("INSERT INTO flaginclusions(component_id, type_id, product_id)
- SELECT fi1.component_id, fi1.type_id, ? FROM flaginclusions fi1
- LEFT JOIN flaginclusions fi2
- ON fi1.type_id = fi2.type_id
- AND fi2.product_id = ?
- WHERE fi1.product_id = ?
- AND fi2.type_id IS NULL",
- undef,
- $tgtprodid, $tgtprodid, $srcprodid);
-
-# It's complex to determine which items now need to be flushed from memcached.
-# As this is expected to be a rare event, we just flush the entire cache.
-Bugzilla->memcached->clear_all();
diff --git a/contrib/reorg-tools/syncmsandversions.pl b/contrib/reorg-tools/syncmsandversions.pl
deleted file mode 100755
index 20e88252e..000000000
--- a/contrib/reorg-tools/syncmsandversions.pl
+++ /dev/null
@@ -1,122 +0,0 @@
-#!/usr/bin/perl -w
-# -*- Mode: perl; indent-tabs-mode: nil -*-
-#
-# The contents of this file are subject to the Mozilla Public
-# License Version 1.1 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# The Original Code is the Bugzilla Bug Tracking System.
-#
-# The Initial Developer of the Original Code is Netscape Communications
-# Corporation. Portions created by Netscape are
-# Copyright (C) 1998 Netscape Communications Corporation. All
-# Rights Reserved.
-#
-# Contributor(s): Gervase Markham <gerv@gerv.net>
-
-# See also https://bugzilla.mozilla.org/show_bug.cgi?id=119569
-
-use strict;
-
-use lib qw(. lib);
-
-use Bugzilla;
-use Bugzilla::Constants;
-
-sub usage() {
- print <<USAGE;
-Usage: syncmsandversions.pl <srcproduct> <tgtproduct>
-
-E.g.: syncmsandversions.pl FoodReplicator SeaMonkey
-will copy any versions and milstones in the product "FoodReplicator"
-which do not exist in product "SeaMonkey" into it. This script is normally
-used prior to moving components from srcproduct to tgtproduct.
-USAGE
-
- exit(1);
-}
-
-#############################################################################
-# MAIN CODE
-#############################################################################
-
-# This is a pure command line script.
-Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
-
-if (scalar @ARGV < 2) {
- usage();
- exit();
-}
-
-my ($srcproduct, $tgtproduct) = @ARGV;
-
-my $dbh = Bugzilla->dbh;
-
-# Find product IDs
-my $srcprodid = $dbh->selectrow_array("SELECT id FROM products WHERE name = ?",
- undef, $srcproduct);
-if (!$srcprodid) {
- print "Can't find product ID for '$srcproduct'.\n";
- exit(1);
-}
-
-my $tgtprodid = $dbh->selectrow_array("SELECT id FROM products WHERE name = ?",
- undef, $tgtproduct);
-if (!$tgtprodid) {
- print "Can't find product ID for '$tgtproduct'.\n";
- exit(1);
-}
-
-$dbh->bz_start_transaction();
-
-$dbh->do("
- INSERT INTO milestones(value, sortkey, isactive, product_id)
- SELECT m1.value, m1.sortkey, m1.isactive, ?
- FROM milestones m1
- LEFT JOIN milestones m2 ON m1.value = m2.value
- AND m2.product_id = ?
- WHERE m1.product_id = ?
- AND m2.value IS NULL
- ",
- undef,
- $tgtprodid, $tgtprodid, $srcprodid);
-
-$dbh->do("
- INSERT INTO versions(value, isactive, product_id)
- SELECT v1.value, v1.isactive, ?
- FROM versions v1
- LEFT JOIN versions v2 ON v1.value = v2.value
- AND v2.product_id = ?
- WHERE v1.product_id = ?
- AND v2.value IS NULL
- ",
- undef,
- $tgtprodid, $tgtprodid, $srcprodid);
-
-$dbh->do("
- INSERT INTO group_control_map (group_id, product_id, entry, membercontrol,
- othercontrol, canedit, editcomponents,
- editbugs, canconfirm)
- SELECT g1.group_id, ?, g1.entry, g1.membercontrol, g1.othercontrol,
- g1.canedit, g1.editcomponents, g1.editbugs, g1.canconfirm
- FROM group_control_map g1
- LEFT JOIN group_control_map g2 ON g1.product_id = ?
- AND g2.product_id = ?
- AND g1.group_id = g2.group_id
- WHERE g1.product_id = ?
- AND g2.group_id IS NULL
- ",
- undef,
- $tgtprodid, $srcprodid, $tgtprodid, $srcprodid);
-
-$dbh->bz_commit_transaction();
-
-# It's complex to determine which items now need to be flushed from memcached.
-# As this is expected to be a rare event, we just flush the entire cache.
-Bugzilla->memcached->clear_all();