diff options
author | Byron Jones <bjones@mozilla.com> | 2012-11-23 08:44:30 +0100 |
---|---|---|
committer | Byron Jones <bjones@mozilla.com> | 2012-11-23 08:44:30 +0100 |
commit | 0ecbb88b3d2fe015f2949ba284e3af3ed1407995 (patch) | |
tree | 14a7f224cec167c04e1e482cd0d65ccdfe8eca6c | |
parent | ed17a711ebddc980f89e8290632f566c37bf762f (diff) | |
download | bugzilla-0ecbb88b3d2fe015f2949ba284e3af3ed1407995.tar.gz bugzilla-0ecbb88b3d2fe015f2949ba284e3af3ed1407995.tar.xz |
Bug 814574: movebugs.pl script should validate flags
-rwxr-xr-x | contrib/reorg-tools/movebugs.pl | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/contrib/reorg-tools/movebugs.pl b/contrib/reorg-tools/movebugs.pl index 33156dad7..6d6a53b51 100755 --- a/contrib/reorg-tools/movebugs.pl +++ b/contrib/reorg-tools/movebugs.pl @@ -3,14 +3,13 @@ use strict; use Cwd 'abs_path'; use File::Basename; -BEGIN { - my $root = abs_path(dirname(__FILE__) . '/../..'); - chdir($root); -} -use lib qw(. lib); +use FindBin; +use lib "$FindBin::Bin/../.."; +use lib "$FindBin::Bin/../../lib"; use Bugzilla; use Bugzilla::Constants; +use Bugzilla::FlagType; use Bugzilla::Util; Bugzilla->usage_mode(USAGE_MODE_CMDLINE); @@ -23,8 +22,8 @@ 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 and milestones from the old -product. +The new product must have matching versions, milestones, and flags from the old +product (will be validated by this script). USAGE } @@ -103,6 +102,24 @@ foreach my $milestone (@$ra_milestones) { 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 " . @@ -112,6 +129,10 @@ 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 |