]> git.donarmstrong.com Git - debbugs.git/commitdiff
- Implement versioning aware archiving support (closes: #419693)
authorDon Armstrong <don@donarmstrong.com>
Sat, 9 Jun 2007 23:10:47 +0000 (16:10 -0700)
committerDon Armstrong <don@donarmstrong.com>
Sat, 9 Jun 2007 23:10:47 +0000 (16:10 -0700)
Debbugs/Config.pm
Debbugs/Packages.pm
Debbugs/Status.pm
debian/changelog

index 9134718e9508a9221575fb2d75993dd6727e2b7d..6b8639fcc57fb097131a06ae6f3fb3ee2a9bac8c 100644 (file)
@@ -450,39 +450,43 @@ set_default(\%config,'version_packages_dir',$config{spool_dir}.'/../versions/pkg
 =item version_time_index
 
 Location of the version/time index file. Defaults to
-spool_dir/../versions/idx/versions_time.idx
+spool_dir/../versions/idx/versions_time.idx if spool_dir/../versions
+exists; otherwise defaults to undef.
 
 =cut
 
 
-set_default(\%config,'version_time_index',$config{spool_dir}.'../versions/idx/versions_time.idx');
+set_default(\%config,'version_time_index', -d $config{spool_dir}.'/../versions' ? $config{spool_dir}.'/../versions/indices/versions_time.idx' : undef);
 
 =item version_index
 
 Location of the version index file. Defaults to
-spool_dir/../versions/idx/versions.idx
+spool_dir/../versions/indices/versions.idx if spool_dir/../versions
+exists; otherwise defaults to undef.
 
 =cut
 
-set_default(\%config,'version_index',$config{spool_dir}.'../versions/idx/versions.idx');
+set_default(\%config,'version_index',-d $config{spool_dir}.'/../versions' ? $config{spool_dir}.'/../versions/indices/versions.idx' : undef);
 
 =item binary_source_map
 
 Location of the binary -> source map. Defaults to
-spool_dir/../versions/idx/binsrc.idx
+spool_dir/../versions/indices/bin2src.idx if spool_dir/../versions
+exists; otherwise defaults to undef.
 
 =cut
 
-set_default(\%config,'binary_source_map',$config{spool_dir}.'../versions/idx/binsrc.idx');
+set_default(\%config,'binary_source_map',-d $config{spool_dir}.'/../versions' ? $config{spool_dir}.'/../versions/indices/binsrc.idx' : undef);
 
 =item source_binary_map
 
 Location of the source -> binary map. Defaults to
-spool_dir/../versions/idx/srcbin.idx
+spool_dir/../versions/indices/src2bin.idx if spool_dir/../versions
+exists; otherwise defaults to undef.
 
 =cut
 
-set_default(\%config,'source_binary_map',$config{spool_dir}.'../versions/idx/srcbin.idx');
+set_default(\%config,'source_binary_map',-d $config{spool_dir}.'/../versions' ? $config{spool_dir}.'/../versions/indices/srcbin.idx' : undef);
 
 
 
index 750bff252ebdf2dc521b905bed971e176881ba99..190d4b46abc9943c62852a7a6d4a9b64f20c77e4 100644 (file)
@@ -37,6 +37,8 @@ use Storable qw(dclone);
 use Params::Validate qw(validate_with :types);
 use Debbugs::Common qw(make_list);
 
+use List::Util qw(min max);
+
 $MLDBM::DumpMeth = 'portable';
 $MLDBM::RemoveTaint = 1;
 
@@ -135,37 +137,38 @@ sub binarytosource {
     # need an extra cache for speed here.
     return () unless defined $gBinarySourceMap;
 
-    if (tied %_binarytosource or
-           tie %_binarytosource, 'MLDBM',
-               $gBinarySourceMap, O_RDONLY) {
-       # avoid autovivification
-       my $binary = $_binarytosource{$binname};
-       return () unless defined $binary;
-       my %binary = %{$binary};
-       if (exists $binary{$binver}) {
-           if (defined $binarch) {
-               my $src = $binary{$binver}{$binarch};
-               return () unless defined $src; # not on this arch
-               # Copy the data to avoid tiedness problems.
-               return dclone($src);
-           } else {
-               # Get (srcname, srcver) pairs for all architectures and
-               # remove any duplicates. This involves some slightly tricky
-               # multidimensional hashing; sorry. Fortunately there'll
-               # usually only be one pair returned.
-               my %uniq;
-               for my $ar (keys %{$binary{$binver}}) {
-                   my $src = $binary{$binver}{$ar};
-                   next unless defined $src;
-                   $uniq{$src->[0]}{$src->[1]} = 1;
-               }
-               my @uniq;
-               for my $sn (sort keys %uniq) {
-                   push @uniq, [$sn, $_] for sort keys %{$uniq{$sn}};
-               }
-               return @uniq;
-           }
-       }
+    if (not tied %_binarytosource) {
+        tie %_binarytosource, MLDBM => $gBinarySourceMap, O_RDONLY or
+             die "Unable to open $gBinarySourceMap for reading";
+    }
+
+    # avoid autovivification
+    my $binary = $_binarytosource{$binname};
+    return () unless defined $binary;
+    my %binary = %{$binary};
+    if (exists $binary{$binver}) {
+        if (defined $binarch) {
+             my $src = $binary{$binver}{$binarch};
+             return () unless defined $src; # not on this arch
+             # Copy the data to avoid tiedness problems.
+             return dclone($src);
+        } else {
+             # Get (srcname, srcver) pairs for all architectures and
+             # remove any duplicates. This involves some slightly tricky
+             # multidimensional hashing; sorry. Fortunately there'll
+             # usually only be one pair returned.
+             my %uniq;
+             for my $ar (keys %{$binary{$binver}}) {
+                  my $src = $binary{$binver}{$ar};
+                  next unless defined $src;
+                  $uniq{$src->[0]}{$src->[1]} = 1;
+             }
+             my @uniq;
+             for my $sn (sort keys %uniq) {
+                  push @uniq, [$sn, $_] for sort keys %{$uniq{$sn}};
+             }
+             return @uniq;
+        }
     }
 
     # No $gBinarySourceMap, or it didn't have an entry for this name and
@@ -188,20 +191,22 @@ our %_sourcetobinary;
 sub sourcetobinary {
     my ($srcname, $srcver) = @_;
 
-    if (tied %_sourcetobinary or
-           tie %_sourcetobinary, 'MLDBM',
-               $gSourceBinaryMap, O_RDONLY) {
-       # avoid autovivification
-       my $source = $_sourcetobinary{$srcname};
-       return () unless defined $source;
-       my %source = %{$source};
-       if (exists $source{$srcver}) {
-           my $bin = $source{$srcver};
-           return () unless defined $bin;
-           return @$bin;
-       }
+    if (not tied %_sourcetobinary) {
+        tie %_sourcetobinary, MLDBM => $gSourceBinaryMap, O_RDONLY or
+             die "Unable top open $gSourceBinaryMap for reading";
     }
 
+
+
+    # avoid autovivification
+    my $source = $_sourcetobinary{$srcname};
+    return () unless defined $source;
+    my %source = %{$source};
+    if (exists $source{$srcver}) {
+        my $bin = $source{$srcver};
+        return () unless defined $bin;
+        return @$bin;
+    }
     # No $gSourceBinaryMap, or it didn't have an entry for this name and
     # version. Try $gPackageSource (unversioned) instead.
     my @srcpkgs = getsrcpkgs($srcname);
@@ -306,7 +311,7 @@ sub get_versions{
                                ) {
                         my $f_ver = $ver;
                         if ($param{source}) {
-                             $f_ver = makesourceversions($package,$arch,$ver)
+                             ($f_ver) = makesourceversions($package,$arch,$ver);
                         }
                         if ($param{time}) {
                              $versions{$f_ver} = max($versions{$f_ver}||0,$version->{$dist}{$arch}{$ver});
index c9c9d3e06935ec56e5c689f3b2265e1e2582ee83..36cea42cb5a1e08dd77cfbc4d3dae5a137714fb1 100644 (file)
@@ -44,6 +44,8 @@ use Debbugs::Versions;
 use Debbugs::Versions::Dpkg;
 use POSIX qw(ceil);
 
+use List::Util qw(min max);
+
 
 BEGIN{
      $VERSION = 1.00;
@@ -593,14 +595,16 @@ sub bug_archiveable{
 
      # There must be fixed_versions for us to look at the versioning
      # information
+     my $min_fixed_time = time;
+     my $min_archive_days = 0;
      if (@{$status->{fixed_versions}}) {
          my %dist_tags;
          @dist_tags{@{$config{removal_distribution_tags}}} =
               (1) x @{$config{removal_distribution_tags}};
          my %dists;
-         @dists{@{$config{removal_default_distribution_tags}}} = 
+         @dists{@{$config{removal_default_distribution_tags}}} =
               (1) x @{$config{removal_default_distribution_tags}};
-         for my $tag (split ' ', $status->{tags}) {
+         for my $tag (split ' ', ($status->{tags}||'')) {
               next unless $dist_tags{$tag};
               $dists{$tag} = 1;
          }
@@ -610,6 +614,8 @@ sub bug_archiveable{
                                            source => 1,
                                           );
          @source_versions{@sourceversions} = (1) x @sourceversions;
+         # If the bug has not been fixed in the versions actually
+         # distributed, then it cannot be archived.
          if ('found' eq max_buggy(bug => $param{bug},
                                   sourceversions => [keys %source_versions],
                                   found          => $status->{found_versions},
@@ -621,12 +627,33 @@ sub bug_archiveable{
          }
          # Since the bug has at least been fixed in the architectures
          # that matters, we check to see how long it has been fixed.
-         
+
+         # To do this, we order the times from most recent to oldest;
+         # when we come to the first found version, we stop.
+         # If we run out of versions, we only report the time of the
+         # last one.
+         my %time_versions = get_versions(package => $status->{package},
+                                          dist    => [keys %dists],
+                                          source  => 1,
+                                          time    => 1,
+                                         );
+         for my $version (sort {$time_versions{$b} <=> $time_versions{$a}} keys %time_versions) {
+              my $buggy = buggy(bug => $param{bug},
+                                version        => $version,
+                                found          => $status->{found_versions},
+                                fixed          => $status->{fixed_versions},
+                                version_cache  => $version_cache,
+                                package        => $status->{package},
+                               );
+              last if $buggy eq 'found';
+              $min_fixed_time = min($time_versions{$version},$min_fixed_time);
+         }
+         $min_archive_days = max($min_archive_days,ceil((time - $min_fixed_time)/(60*60*24)));
      }
      # 6. at least 28 days have passed since the last action has occured or the bug was closed
      my $age = ceil($config{remove_age} - -M getbugcomponent($param{bug},'log'));
-     if ($age > 0 ) {
-         return $param{days_until}?$age:0;
+     if ($age > 0 or $min_archive_days > 0) {
+         return $param{days_until}?max($age,$min_archive_days):0;
      }
      else {
          return $param{days_until}?0:1;
index 44b9a2c9e8798e688b4805158b3f062f5227ba23..68b7cfc20441360565dfa51a30dad2ea230e51d3 100644 (file)
@@ -180,6 +180,7 @@ debbugs (2.4.2) UNRELEASED; urgency=low
     - Fix double leading spaces of format=flowed messages
       (closes: #428056)
     - Don't doubly select users
+    - Implement versioning aware archiving support (closes: #419693)
 
   
  -- Colin Watson <cjwatson@debian.org>  Fri, 20 Jun 2003 18:57:25 +0100