summaryrefslogtreecommitdiffstats
path: root/Bugzilla/PatchReader/NarrowPatch.pm
blob: b6502f2f30db54d4fdd20bf62df53a961883c060 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package Bugzilla::PatchReader::NarrowPatch;

use Bugzilla::PatchReader::FilterPatch;

use strict;

@Bugzilla::PatchReader::NarrowPatch::ISA = qw(Bugzilla::PatchReader::FilterPatch);

sub new {
  my $class = shift;
  $class = ref($class) || $class;
  my $this = $class->SUPER::new();
  bless $this, $class;

  $this->{INCLUDE_FILES} = [@_];

  return $this;
}

sub start_file {
  my $this = shift;
  my ($file) = @_;
  if (grep { $_ eq substr($file->{filename}, 0, length($_)) } @{$this->{INCLUDE_FILES}}) {
    $this->{IS_INCLUDED} = 1;
    $this->{TARGET}->start_file(@_) if $this->{TARGET};
  }
}

sub end_file {
  my $this = shift;
  if ($this->{IS_INCLUDED}) {
    $this->{TARGET}->end_file(@_) if $this->{TARGET};
    $this->{IS_INCLUDED} = 0;
  }
}

sub next_section {
  my $this = shift;
  if ($this->{IS_INCLUDED}) {
    $this->{TARGET}->next_section(@_) if $this->{TARGET};
  }
}

1