# guesswork, based on Version: pseudo-headers and closing mails that look
# like Debian changelogs. The latter in particular is somewhat heuristic.
-use strict;
+# <@aj> Hackin' on the BTS, Feelin' like it'll take forever; Oh you better
+# hold it's hand, when it dies on names so clever. These are the best
+# bugs of our life. It's up to archive-slash-69, man we were killin'
+# time, we were young and resltess, we needed to unwind. I guess
+# nothin' can last forever - forever, no...
+
+my $config_path = '/etc/debbugs';
+my $lib_path = '/usr/lib/debbugs';
+
+require "$config_path/config";
+require "$lib_path/errorlib";
+
use Debbugs::Log;
use Debbugs::MIME;
-if (@ARGV != 2) {
+if (@ARGV != 1) {
print <<EOF;
-Usage: $0 db-directory versions-directory
+Usage: $0 db-type
EOF
exit 0;
next if $fv =~ /^unavailable/i;
$fv =~ s/;.*//;
$fv =~ s/ *\(.*\)//;
+ # Strip off other random junk at the end of a version.
+ $fv =~ s/ +[A-Za-z].*//;
$ver = $fv;
}
}
}
}
-my ($db, $verdb) = @ARGV[0, 1];
+chdir $gSpoolDir or die "Can't chdir $gSpoolDir: $!";
+
+my $db = $ARGV[0];
opendir DB, $db or die "Can't opendir $db: $!";
-unless (-d $verdb) {
- mkdir $verdb or die "Can't mkdir $verdb: $!";
-}
while (defined(my $dir = readdir DB)) {
next if $dir =~ /^\.\.?$/ or not -d "$db/$dir";
$bug =~ /(..)$/;
my $bughash = $1;
- # For incremental updates.
- #next if -e "$verdb/$bughash/$bug.versions" and
- # (stat "$verdb/$bughash/$bug.versions")[9] >=
- # (stat "$db/$dir/$file")[9];
print "Processing $bug ...\n" if $ENV{DEBBUGS_VERBOSE};
- open STATUS, "$db/$dir/$bug.status" or next;
- <STATUS> for 1 .. 6; # done is field 7
- chomp (my $done = <STATUS>);
- <STATUS>; # mergedwith is field 9
- chomp (my $mergedwith = <STATUS>);
- close STATUS;
+ my ($locks, $status) = lockreadbugmerge($bug, $db);
+ unless (defined $status) {
+ unlockreadbugmerge($locks);
+ next;
+ }
+
+ if (@{$status->{found_versions}} or @{$status->{fixed_versions}}) {
+ unlockreadbugmerge($locks);
+ next;
+ }
+
+ my @merges = ();
+ # Only process the lowest of each set of merged bugs.
+ if (length $status->{mergedwith}) {
+ @merges = sort { $a <=> $b } split ' ', $status->{mergedwith};
+ if ($merges[0] < $bug) {
+ unlockreadbugmerge($locks);
+ next;
+ }
+ }
my ($found_versions, $fixed_versions) = getbuginfo("$db/$dir/$file");
- if (length $mergedwith) {
- for my $merge (split ' ', $mergedwith) {
+ if (length $status->{mergedwith}) {
+ for my $merge (@merges) {
$merge =~ /(..)$/;
my $mergehash = $1;
my ($mfound, $mfixed) =
}
}
- @$fixed_versions = () unless length $done;
+ @$fixed_versions = () unless length $status->{done};
- for my $out ($bug, (split ' ', $mergedwith)) {
- $out =~ /(..)$/;
- my $outhash = $1;
-
- unless (-d "$verdb/$outhash") {
- mkdir "$verdb/$outhash" or die "Can't mkdir $verdb/$outhash: $!";
+ for my $out ($bug, @merges) {
+ if ($out != $bug) {
+ filelock("lock/$out");
+ }
+ my $outstatus = readbug($out, $db);
+ $outstatus->{found_versions} = [@$found_versions];
+ $outstatus->{fixed_versions} = [@$fixed_versions];
+ writebug($out, $outstatus, $db, 2, 'disable bughook');
+ if ($out != $bug) {
+ unfilelock();
}
-
- open VERSIONS, "> $verdb/$outhash/$out.versions"
- or die "Can't open $verdb/$outhash/$out.versions: $!";
- print VERSIONS "Found-in: @$found_versions\n";
- print VERSIONS "Fixed-in: @$fixed_versions\n";
- close VERSIONS;
}
+
+ unlockreadbugmerge($locks);
}
closedir HASH;