| 1 |
#!/usr/bin/perl |
#!/usr/bin/perl |
| 2 |
# Last-Modified: <Sun Aug 3 13:11:34 2008> |
# Last-Modified: <Sun Aug 3 16:19:54 2008> |
| 3 |
|
|
| 4 |
use strict; |
use strict; |
| 5 |
use warnings; |
use warnings; |
| 152 |
# Delete all bugs we are going to import |
# Delete all bugs we are going to import |
| 153 |
for my $bug (@modified_bugs) { |
for my $bug (@modified_bugs) { |
| 154 |
map { |
map { |
| 155 |
$dbh->prepare("DELETE FROM $_ WHERE id = $bug")->execute() |
$dbh->prepare("DELETE FROM $_ WHERE id = $bug")->execute() or die $! |
| 156 |
} qw{bugs bug_merged_with bug_found_in bug_fixed_in}; |
} qw{bugs_archived bugs_unarchived bug_merged_with bug_found_in bug_fixed_in bug_tags}; |
| 157 |
} |
} |
| 158 |
print "Bugs deleted\n"; |
print "Bugs deleted\n"; |
| 159 |
|
|
| 162 |
|
|
| 163 |
# XXX What if a bug is in location 'db' (which currently doesn't exist) |
# XXX What if a bug is in location 'db' (which currently doesn't exist) |
| 164 |
my $location = $src_config{archived} ? 'archive' : 'db_h'; |
my $location = $src_config{archived} ? 'archive' : 'db_h'; |
| 165 |
|
my $table = $src_config{archived} ? 'bugs_archived' : 'bugs_unarchived'; |
| 166 |
# Read all bugs |
# Read all bugs |
| 167 |
foreach my $bug_nr (@modified_bugs) { |
foreach my $bug_nr (@modified_bugs) { |
| 168 |
#next unless $bug_nr =~ /00$/; |
next unless $bug_nr =~ /00$/; |
| 169 |
# Fetch bug using Debbugs |
# Fetch bug using Debbugs |
| 170 |
# Bugs which were once archived and have been unarchived again will appear in get_bugs(archive => 1). |
# Bugs which were once archived and have been unarchived again will appear in get_bugs(archive => 1). |
| 171 |
# However, those bugs are not to be found in location 'archive', so we detect them, and skip them |
# However, those bugs are not to be found in location 'archive', so we detect them, and skip them |
| 177 |
map { $bug{$_} = $dbh->quote($bug{$_}) } qw(subject originator owner pending); |
map { $bug{$_} = $dbh->quote($bug{$_}) } qw(subject originator owner pending); |
| 178 |
my @found_versions = map { $dbh->quote($_) } @{$bug{found_versions}}; |
my @found_versions = map { $dbh->quote($_) } @{$bug{found_versions}}; |
| 179 |
my @fixed_versions = map { $dbh->quote($_) } @{$bug{fixed_versions}}; |
my @fixed_versions = map { $dbh->quote($_) } @{$bug{fixed_versions}}; |
| 180 |
|
my @tags = map {$dbh->quote($_) } split / /, $bug{keywords}; |
| 181 |
|
|
| 182 |
# log_modified and date are not necessarily set. If they are not available, they |
# log_modified and date are not necessarily set. If they are not available, they |
| 183 |
# are assumed to be epoch (i.e. bug #4170) |
# are assumed to be epoch (i.e. bug #4170) |
| 232 |
|
|
| 233 |
|
|
| 234 |
# Insert data into bugs table |
# Insert data into bugs table |
| 235 |
my $query = "INSERT INTO bugs VALUES ($bug_nr, '$bug{package}', $source, $bug{date}, \ |
my $query = "INSERT INTO $table VALUES ($bug_nr, '$bug{package}', $source, $bug{date}, \ |
| 236 |
E$bug{pending}, '$bug{severity}', '$bug{keywords}', E$bug{originator}, E$bug{owner}, \ |
E$bug{pending}, '$bug{severity}', E$bug{originator}, E$bug{owner}, \ |
| 237 |
E$bug{subject}, $bug{log_modified}, $present_in_stable, |
E$bug{subject}, $bug{log_modified}, $present_in_stable, |
| 238 |
$present_in_testing, $present_in_unstable, " . ($src_config{archived} ? 'True' : 'False') . ")"; |
$present_in_testing, $present_in_unstable)"; |
| 239 |
# Execute insertion |
# Execute insertion |
| 240 |
my $sth = $dbh->prepare($query); |
my $sth = $dbh->prepare($query); |
| 241 |
$sth->execute() or die $!; |
$sth->execute() or die $!; |
| 253 |
$query = "INSERT INTO bug_merged_with VALUES ($bug_nr, $mergee)"; |
$query = "INSERT INTO bug_merged_with VALUES ($bug_nr, $mergee)"; |
| 254 |
$dbh->prepare($query)->execute() or die $!; |
$dbh->prepare($query)->execute() or die $!; |
| 255 |
} |
} |
| 256 |
|
foreach my $tag (without_duplicates(@tags)) { |
| 257 |
|
$query = "INSERT INTO bug_tags VALUES ($bug_nr, $tag)"; |
| 258 |
|
$dbh->prepare($query)->execute() or die $!; |
| 259 |
|
} |
| 260 |
} |
} |
| 261 |
|
|
| 262 |
$dbh->commit(); |
$dbh->commit(); |