[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[SCM] Debian package checker branch, master, updated. 2.5.15-1-gc06bbf0



The following commit has been merged in the master branch:
commit c06bbf0b68cd5c18508d955de60b8540c010df27
Author: Niels Thykier <niels@thykier.net>
Date:   Wed Jul 24 10:43:48 2013 +0200

    Move code for "unused-override" into L::Tags
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/debian/changelog b/debian/changelog
index b39ca5e..4387723 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,14 @@
+lintian (2.5.16) UNRELEASED; urgency=low
+
+  * frontend/lintian:
+    + [NT] Move some handling of overrides to Lintian::Tags.
+
+  * lib/Lintian/Tags.pm:
+    + [NT] Take over some handling of overrides from the
+      frontend.
+
+ -- Niels Thykier <niels@thykier.net>  Wed, 24 Jul 2013 10:30:01 +0200
+
 lintian (2.5.15) unstable; urgency=low
 
   "use less qw(memory);"
diff --git a/frontend/lintian b/frontend/lintian
index 25a610c..64a6a24 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -1187,7 +1187,6 @@ foreach my $gname (sort $pool->get_group_names()) {
 
 # Write the lab state to the disk, so it remembers the new packages
 $LAB->close;
-$TAGS->file_end();
 
 if ($action eq 'check' and not $opt{'no-override'} and not $opt{'show-overrides'}) {
     my $errors = $overrides{errors} || 0;
@@ -1267,19 +1266,6 @@ sub auto_clean_package {
 
 sub post_pkg_process_overrides{
     my ($lpkg) = @_;
-    # report unused overrides
-    if (not $opt{'no-override'}) {
-        my $pkg_overrides = $TAGS->overrides ($lpkg);
-
-        for my $tag (sort keys %$pkg_overrides) {
-            next if $TAGS->suppressed($tag);
-
-            for my $extra (sort keys %{$pkg_overrides->{$tag}}) {
-                next if $pkg_overrides->{$tag}{$extra};
-                tag ('unused-override', $tag, $extra);
-            }
-        }
-    }
 
     # Report override statistics.
     if (not $opt{'no-override'} and not $opt{'show-overrides'}) {
@@ -1400,11 +1386,9 @@ sub process_group {
 
         debug_msg(1, "Base directory in lab: $base");
 
-        unless ($opt{'no-override'}) {
-            if ($collmap->getp ('override-file') && -f "$base/override") {
-                debug_msg(1, 'Override file collected, loading it ...');
-                $TAGS->file_overrides("$base/override");
-            }
+        if (not $opt{'no-override'} and $collmap->getp('override-file')) {
+            debug_msg(1, 'Loading overrides file (if any) ...');
+            $TAGS->load_overrides;
         }
         foreach my $script (@scripts) {
             my $cs = $PROFILE->get_script ($script);
@@ -1443,6 +1427,8 @@ sub process_group {
         post_pkg_process_overrides ($lpkg);
     } # end foreach my $lpkg ($group->get_processable)
 
+    $TAGS->file_end;
+
     if ($debug > 2) {
         for my $lpkg ($group->get_processables) {
             my $id = $lpkg->identifier;
diff --git a/lib/Lintian/Tags.pm b/lib/Lintian/Tags.pm
index 6bc6c2a..1f6cc21 100644
--- a/lib/Lintian/Tags.pm
+++ b/lib/Lintian/Tags.pm
@@ -648,17 +648,61 @@ sub file_overrides {
     return;
 }
 
+=item load_overrides
+
+Loads overrides for the current file.  This is basically a short-hand
+for finding the overrides file in the lab and calling
+L<files_overrides|/file_overrides(OVERRIDE-FILE)> on it if it is
+present.
+
+=cut
+
+sub load_overrides {
+    my ($self, $overrides) = @_;
+    my $current = $self->{current};
+    my $lpkg;
+    my $overrides_file;
+    unless (defined($current)) {
+        die 'no current file when loading overrides';
+    }
+    $lpkg = $self->{'info'}{$current}{'processable'};
+    $overrides_file = $lpkg->info->lab_data_path('override');
+    if ( -f $overrides_file ) {
+        $self->file_overrides($overrides_file);
+    }
+    return;
+}
+
 =item file_end()
 
-Ends processing of a file.  The main reason for this call is to, in turn,
-call Lintian::Output::print_end_pkg() to mark the end of the package.
+Ends processing of a file.
+
+This does two things.  First it emits "unused-override" tags for all
+unused overrides.  Secondly, it calls Lintian::Output::print_end_pkg
+to mark the end of the package.
+
+Note that this method is called by file_start if it detects another
+entry is already active.
 
 =cut
 
 sub file_end {
     my ($self) = @_;
-    if ($self->{current}) {
-        my $info = $self->{info}{$self->{current}};
+    if (my $current = $self->{current}) {
+        my $info = $self->{info}{$current};
+        my $pkg_overrides = $info->{overrides};
+
+        for my $tag (sort(keys %{$pkg_overrides} )) {
+            my $overrides;
+            next if $self->suppressed($tag);
+
+            $overrides = $pkg_overrides->{$tag};
+            for my $extra (sort(keys %{$overrides} )) {
+                next if $overrides->{$extra};
+                $self->tag('unused-override', $tag, $extra);
+            }
+        }
+
         $Lintian::Output::GLOBAL->print_end_pkg($info);
     }
     undef $self->{current};

-- 
Debian package checker


Reply to: