Dpkg/Changelog.pm

filter: Statementstmt 74.7% 225 / 301 Branchbran 55.5% 90 / 162 Conditioncond 55.5% 60 / 108 MC/DCmcdc 22.5% 14 / 62 Subroutinesub 100% 30 / 30 Podpod 100% 11 / 11 totaltotal 63.8% 430 / 674 CC 143 SCAR 49.4
CC
143
Cov
66%
_sanitize_range
411.0
abort_early
264.0
_data_range
28.2
CRAP 140.3
« Dpkg/Source/Patch.pm ↑ Summary Dpkg/Vendor/Debian.pm »
1 # Copyright © 2005, 2007 Frank Lichtenheld <frank@lichtenheld.de>
2 # Copyright © 2009 Raphaël Hertzog <hertzog@debian.org>
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16  
17 =encoding utf8
18  
19 =head1 NAME
20  
21 Dpkg::Changelog - base class to implement a changelog parser
22  
23 =head1 DESCRIPTION
24  
25 Dpkg::Changelog is a class representing a changelog file
26 as an array of changelog entries (L<Dpkg::Changelog::Entry>).
27 By deriving this class and implementing its parse() method, you
28 add the ability to fill this object with changelog entries.
29  
30 =cut
31  
32 package Dpkg::Changelog 2.00;
33  
34 2 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
37  
38 2 ▶use Dpkg::Gettext;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 2 ▶use Dpkg::ErrorHandling qw(:DEFAULT report REPORT_WARN);
Subroutine BEGIN: called CC=1 SCAR=0.0
40 2 ▶use Dpkg::Control;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 2 ▶use Dpkg::Control::Changelog;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 2 ▶use Dpkg::Control::Fields;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 2 ▶use Dpkg::Index;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 2 ▶use Dpkg::Version;
Subroutine BEGIN: called CC=1 SCAR=0.0
45 2 ▶use Dpkg::Vendor qw(run_vendor_hook);
Subroutine BEGIN: called CC=1 SCAR=0.0
46  
47 2 ▶use parent qw(Dpkg::Interface::Storable);
Subroutine BEGIN: called CC=1 SCAR=0.0
48  
49 use overload
50 2 ▶ '@{}' => sub { return $_[0]->{data} };
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
51  
52 =head1 METHODS
53  
54 =over 4
55  
56 =item $chlog = Dpkg::Changelog->new(%opts)
57  
58 Creates a new changelog object.
59  
60 Accepts the same options as $chlog->set_options().
61  
62 =cut
63  
64 16 ▶sub new {
Subroutine new: called CC=2 SCAR=7.1
Pod documented
65 16 my ($this, %opts) = @_;
66 16 ▶ my $class = ref($this) || $this;
Condition33%1/3
ref $this || $this
l!l&&r!l&&!r
0160
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table33%1/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
67 16 my $self = {
68 verbose => 1,
69 parse_errors => []
70 };
71 16 bless $self, $class;
72 16 $self->set_options(%opts);
73 16 return $self;
74 }
75  
76 =item $chlog->set_options(%opts)
77  
78 Change the value of some options.
79  
80 Options:
81  
82 =over
83  
84 =item B<verbose>
85  
86 Defines whether parse errors are displayed as warnings by default.
87  
88 Defaults to 1.
89  
90 =item B<reportfile>
91  
92 A string to use instead of the name of the file parsed, in particular
93 in error messages.
94  
95 =item B<range>
96  
97 Defines the range of entries that we want to parse, the parser will stop as
98 soon as it has parsed enough data to satisfy $chlog->get_range($opts{range}).
99  
100 =back
101  
102 =cut
103  
104 16 ▶sub set_options {
Subroutine set_options: called CC=2 SCAR=6.9
Pod documented
105 16 my ($self, %opts) = @_;
106 16 $self->{$_} = $opts{$_} foreach keys %opts;
107 }
108  
109 =item $count = $chlog->parse($fh, $description)
110  
111 Read the filehandle and parse a changelog in it. The data in the object is
112 reset before parsing new data.
113  
114 Returns the number of changelog entries that have been parsed with success.
115  
116 This method needs to be implemented by one of the specialized changelog
117 format subclasses.
118  
119 =item $count = $chlog->load($filename)
120  
121 Parse $filename contents for a changelog.
122  
123 Returns the number of changelog entries that have been parsed with success.
124  
125 =item $chlog->reset_parse_errors()
126  
127 Can be used to delete all information about errors occurred during
128 previous parse() runs.
129  
130 =cut
131  
132 16 ▶sub reset_parse_errors {
Subroutine reset_parse_errors: called CC=1 SCAR=0.0
Pod documented
133 16 my $self = shift;
134 16 $self->{parse_errors} = [];
135 }
136  
137 =item $chlog->parse_error($file, $line_nr, $error, [$line])
138  
139 Record a new parse error in $file at line $line_nr. The error message is
140 specified with $error and a copy of the line can be recorded in $line.
141  
142 =cut
143  
144 6 ▶sub parse_error {
Subroutine parse_error: called CC=3 SCAR=15.0
Pod documented
145 6 my ($self, $file, $line_nr, $error, $line) = @_;
146  
147 6 push @{$self->{parse_errors}}, [ $file, $line_nr, $error, $line ];
148  
149 6 ▶ if ($self->{verbose}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"verbose"}) 0 6 6
150 0 ▶ if ($line) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line) { } 0 0 0
151 0 warning("%20s(l$line_nr): $error\nLINE: $line", $file);
152 } else {
153 0 warning("%20s(l$line_nr): $error", $file);
154 }
155 }
156 }
157  
158 =item @errors = $chlog->get_parse_errors()
159  
160 =item $errors = $chlog->get_parse_errors()
161  
162 Returns all error messages from the last parse() run.
163 If called in scalar context returns a human readable
164 string representation. If called in list context returns
165 an array of arrays. Each of these arrays contains
166  
167 =over 4
168  
169 =item 1.
170  
171 a string describing the origin of the data (a filename usually). If the
172 B<reportfile> configuration option was given, its value will be used instead.
173  
174 =item 2.
175  
176 the line number where the error occurred
177  
178 =item 3.
179  
180 an error description
181  
182 =item 4.
183  
184 the original line
185  
186 =back
187  
188 =cut
189  
190 16 ▶sub get_parse_errors {
Subroutine get_parse_errors: called CC=4 SCAR=15.2
Pod documented
191 16 my $self = shift;
192  
193 16 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 4 12 16
194 4 return @{$self->{parse_errors}};
195 } else {
196 12 my $res = '';
197 12 foreach my $e (@{$self->{parse_errors}}) {
198 0 ▶ if ($e->[3]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e->[3]) { } 0 0 0
199 0 $res .= report(REPORT_WARN, g_("%s(l%s): %s\nLINE: %s"), @$e);
200 } else {
201 0 $res .= report(REPORT_WARN, g_('%s(l%s): %s'), @$e);
202 }
203 }
204 12 return $res;
205 }
206 }
207  
208 =item $chlog->set_unparsed_tail($tail)
209  
210 Add a string representing unparsed lines after the changelog entries.
211 Use undef as $tail to remove the unparsed lines currently set.
212  
213 =item $string = $chlog->get_unparsed_tail()
214  
215 Return a string representing the unparsed lines after the changelog
216 entries. Returns undef if there's no such thing.
217  
218 =cut
219  
220 20 ▶sub set_unparsed_tail {
Subroutine set_unparsed_tail: called CC=1 SCAR=0.0
Pod documented
221 20 my ($self, $tail) = @_;
222 20 $self->{unparsed_tail} = $tail;
223 }
224  
225 14 ▶sub get_unparsed_tail {
Subroutine get_unparsed_tail: called CC=1 SCAR=0.0
Pod documented
226 14 my $self = shift;
227 14 return $self->{unparsed_tail};
228 }
229  
230 =item @entries = @{$chlog}
231  
232 Returns all the L<Dpkg::Changelog::Entry> objects contained in this changelog
233 in the order in which they have been parsed.
234  
235 =item @entries = $chlog->get_range($range)
236  
237 =item $entries = $chlog->get_range($range)
238  
239 Returns an array (if called in list context) or a reference to an array of
240 L<Dpkg::Changelog::Entry> objects which each represent one entry of the
241 changelog. $range is a hash reference describing the range of entries
242 to return. See section L</RANGE SELECTION>.
243  
244 =cut
245  
246 70 ▶sub _sanitize_range {
Subroutine _sanitize_range: called CC=43 SCAR=60.2
247 70 my ($self, $r) = @_;
248 70 my $data = $self->{data};
249  
250 70 ▶ if (defined($r->{offset}) and not defined($r->{count})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $r->{"offset"} and not defined $r->{"count"}) 0 70 70
Condition66%2/3
defined $r->{"offset"} and not defined $r->{"count"}
!ll&&!rl&&r
50200
MC/DC0%0/2
defined $r->{"offset"} and not defined $r->{"count"}
defined $r->{"offset"} not defined $r->{"count"}
Truth table66%2/3
A and not(B)
A= defined $r->{"offset"}B= not defined $r->{"count"}
ABresult
0X0
100
111
251 0 ▶ warning(g_("'offset' without 'count' has no effect")) if $self->{verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"verbose"} 0 0 0
252 0 delete $r->{offset};
253 }
254  
255 ## no critic (ControlStructures::ProhibitUntilBlocks)
256 70 ▶ if ((defined($r->{count}) || defined($r->{offset})) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $r->{"count"} || defined $r->{"offset"} and defined $r->{"from"} || defined $r->{"since"} || defined $r->{"to"} || defined $r->{"until"}) 0 70 70
Condition46%7/15
defined $r->{"count"} || defined $r->{"offset"} and defined $r->{"from"} || defined $r->{"since"} || defined $r->{"to"} || defined $r->{"until"}
!ll&&!rl&&r
30400
defined $r->{"count"} or defined $r->{"offset"}
l!l&&r!l&&!r
40030
defined $r->{"from"} or defined $r->{"since"} or defined $r->{"to"} or defined $r->{"until"}
l!l&&r!l&&!r
0040
defined $r->{"from"} or defined $r->{"since"} or defined $r->{"to"}
l!l&&r!l&&!r
0040
defined $r->{"from"} or defined $r->{"since"}
l!l&&r!l&&!r
0040
MC/DC0%0/6
defined $r->{"count"} || defined $r->{"offset"} and defined $r->{"from"} || defined $r->{"since"} || defined $r->{"to"} || defined $r->{"until"}
defined $r->{"count"} defined $r->{"offset"} defined $r->{"from"} defined $r->{"since"} defined $r->{"to"} defined $r->{"until"}
Truth table18%2/11
A or B and C or D or E or F
A= defined $r->{"count"}B= defined $r->{"offset"}C= defined $r->{"from"}D= defined $r->{"since"}E= defined $r->{"to"}F= defined $r->{"until"}
ABCDEFresult
00XXXX0
1X00000
0100000
1X1XXX1
1X01XX1
1X001X1
1X00011
011XXX1
0101XX1
01001X1
0100011
257 (defined($r->{from}) || defined($r->{since}) ||
258 defined($r->{to}) || defined($r->{until})))
259 {
260 warning(g_("cannot combine 'count' or 'offset' with any other " .
261 0 ▶ 'range option')) if $self->{verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"verbose"} 0 0 0
262 0 delete $r->{from};
263 0 delete $r->{since};
264 0 delete $r->{to};
265 0 delete $r->{until};
266 }
267 70 ▶ if (defined($r->{from}) && defined($r->{since})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $r->{"from"} and defined $r->{"since"}) 0 70 70
Condition66%2/3
defined $r->{"from"} and defined $r->{"since"}
!ll&&!rl&&r
6820
MC/DC0%0/2
defined $r->{"from"} and defined $r->{"since"}
defined $r->{"from"} defined $r->{"since"}
Truth table66%2/3
A and B
A= defined $r->{"from"}B= defined $r->{"since"}
ABresult
0X0
100
111
268 warning(g_("can only specify one of 'from' and 'since', using " .
269 0 ▶ "'since'")) if $self->{verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"verbose"} 0 0 0
270 0 delete $r->{from};
271 }
272 70 ▶ if (defined($r->{to}) && defined($r->{until})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $r->{"to"} and defined $r->{"until"}) 0 70 70
Condition66%2/3
defined $r->{"to"} and defined $r->{"until"}
!ll&&!rl&&r
6820
MC/DC0%0/2
defined $r->{"to"} and defined $r->{"until"}
defined $r->{"to"} defined $r->{"until"}
Truth table66%2/3
A and B
A= defined $r->{"to"}B= defined $r->{"until"}
ABresult
0X0
100
111
273 warning(g_("can only specify one of 'to' and 'until', using " .
274 0 ▶ "'until'")) if $self->{verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"verbose"} 0 0 0
275 0 delete $r->{to};
276 }
277  
278 # Handle non-existing versions.
279 70 my (%versions, @versions);
280 70 foreach my $entry (@{$data}) {
281 818 my $version = $entry->get_version();
282 818 ▶ next unless defined $version;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $version 0 818 818
283 818 $versions{$version->as_string()} = 1;
284 818 push @versions, $version->as_string();
285 }
286 70 ▶ if ((defined($r->{since}) and not exists $versions{$r->{since}})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $r->{"since"} and not exists $versions{$r->{"since"}}) 2 68 70
Condition100%3/3
defined $r->{"since"} and not exists $versions{$r->{"since"}}
!ll&&!rl&&r
6622
MC/DC100%2/2
defined $r->{"since"} and not exists $versions{$r->{"since"}}
defined $r->{"since"} not exists $versions{$r->{"since"}}
Truth table100%3/3
A and not(B)
A= defined $r->{"since"}B= not exists $versions{$r->{"since"}}
ABresult
0X0
100
111
287 2 warning(g_("'%s' option specifies non-existing version '%s'"), 'since', $r->{since});
288 2 warning(g_('use newest entry that is earlier than the one specified'));
289 2 foreach my $v (@versions) {
290 14 ▶ if (version_compare_relation($v, REL_LT, $r->{since})) {
Branch: 1 branch
BranchTrueFalseTotal
if (version_compare_relation($v, "<<", $r->{"since"})) 0 14 14
291 0 $r->{since} = $v;
292 0 last;
293 }
294 }
295 2 ▶ if (not exists $versions{$r->{since}}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $versions{$r->{"since"}}) 2 0 2
296 # No version was earlier, include all.
297 2 warning(g_('none found, starting from the oldest entry'));
298 2 delete $r->{since};
299 2 $r->{from} = $versions[-1];
300 }
301 }
302 70 ▶ if ((defined($r->{from}) and not exists $versions{$r->{from}})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $r->{"from"} and not exists $versions{$r->{"from"}}) 0 70 70
Condition66%2/3
defined $r->{"from"} and not exists $versions{$r->{"from"}}
!ll&&!rl&&r
6640
MC/DC0%0/2
defined $r->{"from"} and not exists $versions{$r->{"from"}}
defined $r->{"from"} not exists $versions{$r->{"from"}}
Truth table66%2/3
A and not(B)
A= defined $r->{"from"}B= not exists $versions{$r->{"from"}}
ABresult
0X0
100
111
303 0 warning(g_("'%s' option specifies non-existing version '%s'"), 'from', $r->{from});
304 0 warning(g_('use oldest entry that is later than the one specified'));
305 0 my $oldest;
306 0 foreach my $v (@versions) {
307 0 ▶ if (version_compare_relation($v, REL_GT, $r->{from})) {
Branch: 1 branch
BranchTrueFalseTotal
if (version_compare_relation($v, ">>", $r->{"from"})) 0 0 0
308 0 $oldest = $v;
309 }
310 }
311 0 ▶ if (defined($oldest)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $oldest) { } 0 0 0
312 0 $r->{from} = $oldest;
313 } else {
314 # No version was oldest.
315 0 warning(g_("no such entry found, ignoring '%s' parameter '%s'"), 'from', $r->{from});
316 0 delete $r->{from};
317 }
318 }
319 70 ▶ if (defined($r->{until}) and not exists $versions{$r->{until}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $r->{"until"} and not exists $versions{$r->{"until"}}) 0 70 70
Condition66%2/3
defined $r->{"until"} and not exists $versions{$r->{"until"}}
!ll&&!rl&&r
6820
MC/DC0%0/2
defined $r->{"until"} and not exists $versions{$r->{"until"}}
defined $r->{"until"} not exists $versions{$r->{"until"}}
Truth table66%2/3
A and not(B)
A= defined $r->{"until"}B= not exists $versions{$r->{"until"}}
ABresult
0X0
100
111
320 0 warning(g_("'%s' option specifies non-existing version '%s'"), 'until', $r->{until});
321 0 warning(g_('use oldest entry that is later than the one specified'));
322 0 my $oldest;
323 0 foreach my $v (@versions) {
324 0 ▶ if (version_compare_relation($v, REL_GT, $r->{until})) {
Branch: 1 branch
BranchTrueFalseTotal
if (version_compare_relation($v, ">>", $r->{"until"})) 0 0 0
325 0 $oldest = $v;
326 }
327 }
328 0 ▶ if (defined($oldest)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $oldest) { } 0 0 0
329 0 $r->{until} = $oldest;
330 } else {
331 # No version was oldest.
332 0 warning(g_("no such entry found, ignoring '%s' parameter '%s'"), 'until', $r->{until});
333 0 delete $r->{until};
334 }
335 }
336 70 ▶ if (defined($r->{to}) and not exists $versions{$r->{to}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $r->{"to"} and not exists $versions{$r->{"to"}}) 0 70 70
Condition66%2/3
defined $r->{"to"} and not exists $versions{$r->{"to"}}
!ll&&!rl&&r
6820
MC/DC0%0/2
defined $r->{"to"} and not exists $versions{$r->{"to"}}
defined $r->{"to"} not exists $versions{$r->{"to"}}
Truth table66%2/3
A and not(B)
A= defined $r->{"to"}B= not exists $versions{$r->{"to"}}
ABresult
0X0
100
111
337 0 warning(g_("'%s' option specifies non-existing version '%s'"), 'to', $r->{to});
338 0 warning(g_('use newest entry that is earlier than the one specified'));
339 0 foreach my $v (@versions) {
340 0 ▶ if (version_compare_relation($v, REL_LT, $r->{to})) {
Branch: 1 branch
BranchTrueFalseTotal
if (version_compare_relation($v, "<<", $r->{"to"})) 0 0 0
341 0 $r->{to} = $v;
342 0 last;
343 }
344 }
345 0 ▶ if (not exists $versions{$r->{to}}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $versions{$r->{"to"}}) 0 0 0
346 # No version was earlier.
347 0 warning(g_("no such entry found, ignoring '%s' parameter '%s'"), 'to', $r->{to});
348 0 delete $r->{to};
349 }
350 }
351  
352 70 ▶ if (defined($r->{since}) and $data->[0]->get_version() eq $r->{since}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $r->{"since"} and $data->[0]->get_version eq $r->{"since"}) 0 70 70
Condition66%2/3
defined $r->{"since"} and $data->[0]->get_version eq $r->{"since"}
!ll&&!rl&&r
6820
MC/DC0%0/2
defined $r->{"since"} and $data->[0]->get_version eq $r->{"since"}
defined $r->{"since"} $data->[0]->get_version eq $r->{"since"}
Truth table66%2/3
A and B
A= defined $r->{"since"}B= $data->[0]->get_version eq $r->{"since"}
ABresult
0X0
100
111
353 0 warning(g_("'since' option specifies most recent version '%s', ignoring"), $r->{since});
354 0 delete $r->{since};
355 }
356 70 ▶ if (defined($r->{until}) and $data->[-1]->get_version() eq $r->{until}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $r->{"until"} and $data->[-1]->get_version eq $r->{"until"}) 0 70 70
Condition66%2/3
defined $r->{"until"} and $data->[-1]->get_version eq $r->{"until"}
!ll&&!rl&&r
6820
MC/DC0%0/2
defined $r->{"until"} and $data->[-1]->get_version eq $r->{"until"}
defined $r->{"until"} $data->[-1]->get_version eq $r->{"until"}
Truth table66%2/3
A and B
A= defined $r->{"until"}B= $data->[-1]->get_version eq $r->{"until"}
ABresult
0X0
100
111
357 0 warning(g_("'until' option specifies oldest version '%s', ignoring"), $r->{until});
358 0 delete $r->{until};
359 }
360 ## use critic
361 }
362  
363 84 ▶sub get_range {
Subroutine get_range: called CC=5 SCAR=16.3
Pod documented
364 84 my ($self, $range) = @_;
365 84 ▶ $range //= {};
Condition100%2/2
$range //= {}
l!l
7212
MC/DC100%1/1
$range //= {}
$range
Truth table100%2/2
A
A= $range
Aresult
11
00
366 84 my $res = $self->_data_range($range);
367 84 ▶ return unless defined $res;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $res 0 84 84
368 84 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 84 0 84
369 84 ▶ return reverse @{$res} if $range->{reverse};
Branch: 1 branch
BranchTrueFalseTotal
if $range->{"reverse"} 2 82 84
370 82 return @{$res};
371 } else {
372 0 return $res;
373 }
374 }
375  
376 84 ▶sub _is_full_range {
Subroutine _is_full_range: called CC=4 SCAR=13.9
377 84 my ($self, $range) = @_;
378  
379 84 ▶ return 1 if $range->{all};
Branch: 1 branch
BranchTrueFalseTotal
if $range->{"all"} 2 82 84
380  
381 # If no range delimiter is specified, we want everything.
382 82 foreach my $delim (qw(since until from to count offset)) {
383 314 ▶ return 0 if exists $range->{$delim};
Branch: 1 branch
BranchTrueFalseTotal
if exists $range->{$delim} 70 244 314
384 }
385  
386 12 return 1;
387 }
388  
389 84 ▶sub _data_range {
Subroutine _data_range: called CC=28 SCAR=33.4
390 84 my ($self, $range) = @_;
391  
392 84 ▶ my $data = $self->{data} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $data = $self->{"data"} or return 84 0 84
393  
394 84 ▶ return [ @$data ] if $self->_is_full_range($range);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_is_full_range($range) 14 70 84
395  
396 70 $self->_sanitize_range($range);
397  
398 70 my ($start, $end);
399 70 ▶ if (defined($range->{count})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $range->{"count"}) 40 30 70
400 40 ▶ my $offset = $range->{offset} // 0;
Condition100%2/2
$range->{"offset"} // 0
l!l
2020
MC/DC100%1/1
$range->{"offset"} // 0
$range->{"offset"}
Truth table100%2/2
A
A= $range->{"offset"}
Aresult
11
00
401 40 my $count = $range->{count};
402 # Convert count/offset in start/end.
403 40 ▶ if ($offset > 0) {
Branch: 2 branches
BranchTrueFalseTotal
if ($offset > 0) { } 12 28 40
elsif ($offset < 0) { } 8 20 28
404 12 $offset -= ($count < 0);
405 } elsif ($offset < 0) {
406 8 $offset = $#$data + ($count > 0) + $offset;
407 } else {
408 20 ▶ $offset = $#$data if $count < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $count < 0 8 12 20
409 }
410 40 $start = $end = $offset;
411 40 ▶ $start += $count + 1 if $count < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $count < 0 16 24 40
412 40 ▶ $end += $count - 1 if $count > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $count > 0 24 16 40
413 # Check limits.
414 40 ▶ $start = 0 if $start < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $start < 0 6 34 40
415 40 ▶ return if $start > $#$data;
Branch: 1 branch
BranchTrueFalseTotal
if $start > $data->$#* 0 40 40
416 40 ▶ $end = $#$data if $end > $#$data;
Branch: 1 branch
BranchTrueFalseTotal
if $end > $data->$#* 6 34 40
417 40 ▶ return if $end < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $end < 0 0 40 40
418 40 ▶ $end = $start if $end < $start;
Branch: 1 branch
BranchTrueFalseTotal
if $end < $start 0 40 40
419 40 return [ @{$data}[$start .. $end] ];
420 }
421  
422 ## no critic (ControlStructures::ProhibitUntilBlocks)
423 30 my @result;
424 30 my $include = 1;
425 30 ▶ $include = 0 if defined($range->{to}) or defined($range->{until});
Branch: 1 branch
BranchTrueFalseTotal
if defined $range->{"to"} or defined $range->{"until"} 4 26 30
Condition100%3/3
defined $range->{"to"} or defined $range->{"until"}
l!l&&r!l&&!r
2226
MC/DC100%2/2
defined $range->{"to"} or defined $range->{"until"}
defined $range->{"to"} defined $range->{"until"}
Truth table100%3/3
A or B
A= defined $range->{"to"}B= defined $range->{"until"}
ABresult
1X1
011
000
426 30 foreach my $entry (@{$data}) {
427 538 my $v = $entry->get_version();
428 538 ▶ $include = 1 if defined($range->{to}) and $v eq $range->{to};
Branch: 1 branch
BranchTrueFalseTotal
if defined $range->{"to"} and $v eq $range->{"to"} 2 536 538
Condition100%3/3
defined $range->{"to"} and $v eq $range->{"to"}
!ll&&!rl&&r
524122
MC/DC100%2/2
defined $range->{"to"} and $v eq $range->{"to"}
defined $range->{"to"} $v eq $range->{"to"}
Truth table100%3/3
A and B
A= defined $range->{"to"}B= $v eq $range->{"to"}
ABresult
0X0
100
111
429 538 ▶ last if defined($range->{since}) and $v eq $range->{since};
Branch: 1 branch
BranchTrueFalseTotal
if defined $range->{"since"} and $v eq $range->{"since"} 2 536 538
Condition100%3/3
defined $range->{"since"} and $v eq $range->{"since"}
!ll&&!rl&&r
53062
MC/DC100%2/2
defined $range->{"since"} and $v eq $range->{"since"}
defined $range->{"since"} $v eq $range->{"since"}
Truth table100%3/3
A and B
A= defined $range->{"since"}B= $v eq $range->{"since"}
ABresult
0X0
100
111
430  
431 536 ▶ push @result, $entry if $include;
Branch: 1 branch
BranchTrueFalseTotal
if $include 518 18 536
432  
433 536 ▶ $include = 1 if defined($range->{until}) and $v eq $range->{until};
Branch: 1 branch
BranchTrueFalseTotal
if defined $range->{"until"} and $v eq $range->{"until"} 2 534 536
Condition100%3/3
defined $range->{"until"} and $v eq $range->{"until"}
!ll&&!rl&&r
522122
MC/DC100%2/2
defined $range->{"until"} and $v eq $range->{"until"}
defined $range->{"until"} $v eq $range->{"until"}
Truth table100%3/3
A and B
A= defined $range->{"until"}B= $v eq $range->{"until"}
ABresult
0X0
100
111
434 536 ▶ last if defined($range->{from}) and $v eq $range->{from};
Branch: 1 branch
BranchTrueFalseTotal
if defined $range->{"from"} and $v eq $range->{"from"} 4 532 536
Condition100%3/3
defined $range->{"from"} and $v eq $range->{"from"}
!ll&&!rl&&r
514184
MC/DC100%2/2
defined $range->{"from"} and $v eq $range->{"from"}
defined $range->{"from"} $v eq $range->{"from"}
Truth table100%3/3
A and B
A= defined $range->{"from"}B= $v eq $range->{"from"}
ABresult
0X0
100
111
435 }
436 ## use critic
437  
438 30 ▶ return \@result if scalar(@result);
Branch: 1 branch
BranchTrueFalseTotal
if scalar @result 30 0 30
439 0 return;
440 }
441  
442 =item $bool = $chlog->abort_early()
443  
444 Returns true if enough data have been parsed to be able to return all
445 entries selected by the range set at creation (or with set_options).
446  
447 =cut
448  
449 234 ▶sub abort_early {
Subroutine abort_early: called CC=18 SCAR=55.8
Pod documented
450 234 my $self = shift;
451  
452 234 ▶ my $data = $self->{data} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $data = $self->{"data"} or return 234 0 234
453 234 ▶ my $r = $self->{range} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $r = $self->{"range"} or return 0 234 234
454 0 ▶ my $count = $r->{count} // 0;
Condition0%0/2
$r->{"count"} // 0
l!l
00
MC/DC0%0/1
$r->{"count"} // 0
$r->{"count"}
Truth table0%0/2
A
A= $r->{"count"}
Aresult
11
00
455 0 ▶ my $offset = $r->{offset} // 0;
Condition0%0/2
$r->{"offset"} // 0
l!l
00
MC/DC0%0/1
$r->{"offset"} // 0
$r->{"offset"}
Truth table0%0/2
A
A= $r->{"offset"}
Aresult
11
00
456  
457 0 ▶ return if $self->_is_full_range($r);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_is_full_range($r) 0 0 0
458 0 ▶ return if $offset < 0 or $count < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $offset < 0 or $count < 0 0 0 0
Condition0%0/3
$offset < 0 or $count < 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$offset < 0 or $count < 0
$offset < 0 $count < 0
Truth table0%0/3
A or B
A= $offset < 0B= $count < 0
ABresult
1X1
011
000
459 0 ▶ if (defined($r->{count})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $r->{"count"}) 0 0 0
460 0 ▶ if ($offset > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($offset > 0) 0 0 0
461 0 $offset -= ($count < 0);
462 }
463 0 my $start = my $end = $offset;
464 0 ▶ $end += $count-1 if $count > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $count > 0 0 0 0
465 0 return $start < @{$data} > $end;
466 }
467  
468 0 ▶ return unless defined($r->{since}) or defined($r->{from});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $r->{"since"} or defined $r->{"from"} 0 0 0
Condition0%0/3
defined $r->{"since"} or defined $r->{"from"}
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $r->{"since"} or defined $r->{"from"}
defined $r->{"since"} defined $r->{"from"}
Truth table0%0/3
A or B
A= defined $r->{"since"}B= defined $r->{"from"}
ABresult
1X1
011
000
469 0 foreach my $entry (@{$data}) {
470 0 my $v = $entry->get_version();
471 0 ▶ return 1 if defined($r->{since}) and $v eq $r->{since};
Branch: 1 branch
BranchTrueFalseTotal
if defined $r->{"since"} and $v eq $r->{"since"} 0 0 0
Condition0%0/3
defined $r->{"since"} and $v eq $r->{"since"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $r->{"since"} and $v eq $r->{"since"}
defined $r->{"since"} $v eq $r->{"since"}
Truth table0%0/3
A and B
A= defined $r->{"since"}B= $v eq $r->{"since"}
ABresult
0X0
100
111
472 0 ▶ return 1 if defined($r->{from}) and $v eq $r->{from};
Branch: 1 branch
BranchTrueFalseTotal
if defined $r->{"from"} and $v eq $r->{"from"} 0 0 0
Condition0%0/3
defined $r->{"from"} and $v eq $r->{"from"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $r->{"from"} and $v eq $r->{"from"}
defined $r->{"from"} $v eq $r->{"from"}
Truth table0%0/3
A and B
A= defined $r->{"from"}B= $v eq $r->{"from"}
ABresult
0X0
100
111
473 }
474  
475 0 return;
476 }
477  
478 =item $string = "$chlog"
479  
480 =item $string = $chlog->output()
481  
482 Returns a string representation of the changelog (it's a concatenation of
483 the string representation of the individual changelog entries).
484  
485 =item $string = $chlog->output($fh)
486  
487 Output the changelog to the given filehandle.
488  
489 =cut
490  
491 12 ▶sub output {
Subroutine output: called CC=7 SCAR=20.5
Pod documented
492 12 my ($self, $fh) = @_;
493 12 my $str = '';
494 12 foreach my $entry (@{$self}) {
495 242 my $text = $entry->output();
496 0 ▶ print { $fh } $text if defined $fh;
Branch: 1 branch
BranchTrueFalseTotal
if defined $fh 0 242 242
497 242 ▶ $str .= $text if defined wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if defined wantarray 242 0 242
498 }
499 12 my $text = $self->get_unparsed_tail();
500 12 ▶ if (defined $text) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $text) 4 8 12
501 0 ▶ print { $fh } $text if defined $fh;
Branch: 1 branch
BranchTrueFalseTotal
if defined $fh 0 4 4
502 4 ▶ $str .= $text if defined wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if defined wantarray 4 0 4
503 }
504 12 return $str;
505 }
506  
507 =item $chlog->save($filename)
508  
509 Save the changelog in the given file.
510  
511 =cut
512  
513 2 our (@URGENCIES, %URGENCIES);
514 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
515 2 @URGENCIES = qw(
516 low
517 medium
518 high
519 critical
520 emergency
521 );
522 2 my $i = 1;
523 2 %URGENCIES = map { $_ => $i++ } @URGENCIES;
524 }
525  
526 16 ▶sub _format_dpkg {
Subroutine _format_dpkg: called CC=23 SCAR=32.7
527 16 my ($self, $range) = @_;
528  
529 16 ▶ my @data = $self->get_range($range) or return;
Branch: 1 branch
BranchTrueFalseTotal
my(@data) = $self->get_range($range) or return 16 0 16
530 16 my $src = shift @data;
531  
532 16 my $chlog = Dpkg::Control::Changelog->new();
533 16 ▶ $chlog->{Urgency} = $src->get_urgency() || 'unknown';
Condition50%1/2
$src->get_urgency || 'unknown'
l!l
160
MC/DC0%0/1
$src->get_urgency || 'unknown'
$src->get_urgency
Truth table50%1/2
A
A= $src->get_urgency
Aresult
11
00
534 16 ▶ $chlog->{Source} = $src->get_source() || 'unknown';
Condition50%1/2
$src->get_source || 'unknown'
l!l
160
MC/DC0%0/1
$src->get_source || 'unknown'
$src->get_source
Truth table50%1/2
A
A= $src->get_source
Aresult
11
00
535 16 ▶ $chlog->{Version} = $src->get_version() // 'unknown';
Condition50%1/2
$src->get_version // "unknown"
l!l
160
MC/DC0%0/1
$src->get_version // "unknown"
$src->get_version
Truth table50%1/2
A
A= $src->get_version
Aresult
11
00
536 16 $chlog->{Distribution} = join ' ', $src->get_distributions();
537 16 ▶ $chlog->{Maintainer} = $src->get_maintainer() // '';
Condition50%1/2
$src->get_maintainer // ""
l!l
160
MC/DC0%0/1
$src->get_maintainer // ""
$src->get_maintainer
Truth table50%1/2
A
A= $src->get_maintainer
Aresult
11
00
538 16 ▶ $chlog->{Date} = $src->get_timestamp() // '';
Condition50%1/2
$src->get_timestamp // ""
l!l
160
MC/DC0%0/1
$src->get_timestamp // ""
$src->get_timestamp
Truth table50%1/2
A
A= $src->get_timestamp
Aresult
11
00
539 16 ▶ $chlog->{Timestamp} = $src->get_timepiece ? $src->get_timepiece->epoch : '';
Branch: 1 branch
BranchTrueFalseTotal
$src->get_timepiece ? : 16 0 16
540 16 $chlog->{Changes} = $src->get_dpkg_changes();
541  
542 # Handle optional fields.
543 16 my $opts = $src->get_optional_fields();
544 16 my %closes;
545 16 foreach my $f (keys %{$opts}) {
546 26 ▶ if ($f eq 'Urgency') {
Branch: 2 branches
BranchTrueFalseTotal
if ($f eq 'Urgency') { } 16 10 26
elsif ($f eq 'Closes') { } 10 0 10
547 # Already handled.
548 } elsif ($f eq 'Closes') {
549 10 $closes{$_} = 1 foreach (split(/\s+/, $opts->{Closes}));
550 } else {
551 0 field_transfer_single($opts, $chlog, $f);
552 }
553 }
554  
555 16 foreach my $bin (@data) {
556 238 ▶ my $oldurg = $chlog->{Urgency} // '';
Condition50%1/2
$chlog->{"Urgency"} // ""
l!l
2380
MC/DC0%0/1
$chlog->{"Urgency"} // ""
$chlog->{"Urgency"}
Truth table50%1/2
A
A= $chlog->{"Urgency"}
Aresult
11
00
557 238 ▶ my $oldurgn = $URGENCIES{$chlog->{Urgency}} // -1;
Condition50%1/2
$Dpkg::Changelog::URGENCIES{$chlog->{"Urgency"}} // -1
l!l
2380
MC/DC0%0/1
$Dpkg::Changelog::URGENCIES{$chlog->{"Urgency"}} // -1
$Dpkg::Changelog::URGENCIES{$chlog->{"Urgency"}}
Truth table50%1/2
A
A= $Dpkg::Changelog::URGENCIES{$chlog->{"Urgency"}}
Aresult
11
00
558 238 ▶ my $newurg = $bin->get_urgency() // '';
Condition50%1/2
$bin->get_urgency // ""
l!l
2380
MC/DC0%0/1
$bin->get_urgency // ""
$bin->get_urgency
Truth table50%1/2
A
A= $bin->get_urgency
Aresult
11
00
559 238 ▶ my $newurgn = $URGENCIES{$newurg} // -1;
Condition50%1/2
$Dpkg::Changelog::URGENCIES{$newurg} // -1
l!l
2380
MC/DC0%0/1
$Dpkg::Changelog::URGENCIES{$newurg} // -1
$Dpkg::Changelog::URGENCIES{$newurg}
Truth table50%1/2
A
A= $Dpkg::Changelog::URGENCIES{$newurg}
Aresult
11
00
560 238 ▶ $chlog->{Urgency} = ($newurgn > $oldurgn) ? $newurg : $oldurg;
Branch: 1 branch
BranchTrueFalseTotal
$newurgn > $oldurgn ? : 10 228 238
561 238 $chlog->{Changes} .= "\n" . $bin->get_dpkg_changes();
562  
563 # Handle optional fields.
564 238 $opts = $bin->get_optional_fields();
565 238 foreach my $f (keys %{$opts}) {
566 416 ▶ if ($f eq 'Closes') {
Branch: 2 branches
BranchTrueFalseTotal
if ($f eq 'Closes') { } 168 248 416
elsif (not exists $chlog->{$f}) { } 10 238 248
567 168 $closes{$_} = 1 foreach (split(/\s+/, $opts->{Closes}));
568 } elsif (not exists $chlog->{$f}) {
569 # Do not overwrite an existing field.
570 10 field_transfer_single($opts, $chlog, $f);
571 }
572 }
573 }
574  
575 16 ▶ if (scalar keys %closes) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar keys %closes) 10 6 16
576 10 $chlog->{Closes} = join ' ', sort { $a <=> $b } keys %closes;
577 }
578 16 run_vendor_hook('post-process-changelog-entry', $chlog);
579  
580 16 return $chlog;
581 }
582  
583 22 ▶sub _format_rfc822 {
Subroutine _format_rfc822: called CC=11 SCAR=24.8
584 22 my ($self, $range) = @_;
585  
586 22 ▶ my @data = $self->get_range($range) or return;
Branch: 1 branch
BranchTrueFalseTotal
my(@data) = $self->get_range($range) or return 22 0 22
587 22 my @ctrl;
588  
589 22 foreach my $entry (@data) {
590 484 my $chlog = Dpkg::Control::Changelog->new();
591 484 ▶ $chlog->{Urgency} = $entry->get_urgency() || 'unknown';
Condition50%1/2
$entry->get_urgency || 'unknown'
l!l
4840
MC/DC0%0/1
$entry->get_urgency || 'unknown'
$entry->get_urgency
Truth table50%1/2
A
A= $entry->get_urgency
Aresult
11
00
592 484 ▶ $chlog->{Source} = $entry->get_source() || 'unknown';
Condition50%1/2
$entry->get_source || 'unknown'
l!l
4840
MC/DC0%0/1
$entry->get_source || 'unknown'
$entry->get_source
Truth table50%1/2
A
A= $entry->get_source
Aresult
11
00
593 484 ▶ $chlog->{Version} = $entry->get_version() // 'unknown';
Condition50%1/2
$entry->get_version // "unknown"
l!l
4840
MC/DC0%0/1
$entry->get_version // "unknown"
$entry->get_version
Truth table50%1/2
A
A= $entry->get_version
Aresult
11
00
594 484 $chlog->{Distribution} = join ' ', $entry->get_distributions();
595 484 ▶ $chlog->{Maintainer} = $entry->get_maintainer() // '';
Condition50%1/2
$entry->get_maintainer // ""
l!l
4840
MC/DC0%0/1
$entry->get_maintainer // ""
$entry->get_maintainer
Truth table50%1/2
A
A= $entry->get_maintainer
Aresult
11
00
596 484 ▶ $chlog->{Date} = $entry->get_timestamp() // '';
Condition50%1/2
$entry->get_timestamp // ""
l!l
4840
MC/DC0%0/1
$entry->get_timestamp // ""
$entry->get_timestamp
Truth table50%1/2
A
A= $entry->get_timestamp
Aresult
11
00
597 484 ▶ $chlog->{Timestamp} = $entry->get_timepiece ? $entry->get_timepiece->epoch : '';
Branch: 1 branch
BranchTrueFalseTotal
$entry->get_timepiece ? : 484 0 484
598 484 $chlog->{Changes} = $entry->get_dpkg_changes();
599  
600 # Handle optional fields.
601 484 my $opts = $entry->get_optional_fields();
602 484 foreach my $f (keys %{$opts}) {
603 834 ▶ field_transfer_single($opts, $chlog, $f) unless exists $chlog->{$f};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $chlog->{$f} 350 484 834
604 }
605  
606 484 run_vendor_hook('post-process-changelog-entry', $chlog);
607  
608 484 push @ctrl, $chlog;
609 }
610  
611 22 return @ctrl;
612 }
613  
614 =item $ctrl_index = $chlog->format_range($format, $range)
615  
616 =item @ctrl_list = $chlog->format_range($format, $range)
617  
618 Formats the changelog into L<Dpkg::Control::Changelog> objects representing
619 the entries selected by the optional range specifier (see L</RANGE SELECTION>
620 for details). In scalar context returns a L<Dpkg::Index> object containing
621 the selected entries, in list context returns an array of
622 L<Dpkg::Control::Changelog> objects.
623  
624 With format B<dpkg> the returned L<Dpkg::Control::Changelog> object is
625 coalesced from the entries in the changelog that are part of the range
626 requested, with the fields described below, but considering that
627 "selected entry" means the first entry of the selected range.
628  
629 With format B<rfc822> each returned L<Dpkg::Control::Changelog> objects
630 represents one entry in the changelog that is part of the range requested,
631 with the fields described below, but considering that "selected entry"
632 means for each entry.
633  
634 The different formats return undef if no entries are matched. The following
635 fields are contained in the object(s) returned:
636  
637 =over 4
638  
639 =item Source
640  
641 package name (selected entry)
642  
643 =item Version
644  
645 packages' version (selected entry)
646  
647 =item Distribution
648  
649 target distribution (selected entry)
650  
651 =item Urgency
652  
653 urgency (highest of all entries in range)
654  
655 =item Maintainer
656  
657 person that created the (selected) entry
658  
659 =item Date
660  
661 date of the (selected) entry
662  
663 =item Timestamp
664  
665 date of the (selected) entry as a timestamp in seconds since the epoch
666  
667 =item Closes
668  
669 bugs closed by the (selected) entry/entries, sorted by bug number
670  
671 =item Changes
672  
673 content of the (selected) entry/entries
674  
675 =back
676  
677 =cut
678  
679 38 ▶sub format_range {
Subroutine format_range: called CC=5 SCAR=16.2
Pod documented
680 38 my ($self, $format, $range) = @_;
681  
682 38 my @ctrl;
683  
684 38 ▶ if ($format eq 'dpkg') {
Branch: 2 branches
BranchTrueFalseTotal
if ($format eq 'dpkg') { } 16 22 38
elsif ($format eq 'rfc822') { } 22 0 22
685 16 @ctrl = $self->_format_dpkg($range);
686 } elsif ($format eq 'rfc822') {
687 22 @ctrl = $self->_format_rfc822($range);
688 } else {
689 0 croak "unknown changelog output format $format";
690 }
691  
692 38 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 2 36 38
693 2 return @ctrl;
694 } else {
695 36 my $index = Dpkg::Index->new(type => CTRL_CHANGELOG);
696  
697 36 foreach my $ctrl (@ctrl) {
698 498 $index->add($ctrl);
699 }
700  
701 36 return $index;
702 }
703 }
704  
705 =back
706  
707 =head1 RANGE SELECTION
708  
709 A range selection is described by a hash reference where
710 the allowed keys and values are described below.
711  
712 The following options take a version number as value.
713  
714 =over 4
715  
716 =item since
717  
718 Causes changelog information from all versions strictly
719 later than B<version> to be used.
720  
721 =item until
722  
723 Causes changelog information from all versions strictly
724 earlier than B<version> to be used.
725  
726 =item from
727  
728 Similar to C<since> but also includes the information for the
729 specified B<version> itself.
730  
731 =item to
732  
733 Similar to C<until> but also includes the information for the
734 specified B<version> itself.
735  
736 =back
737  
738 The following options don't take version numbers as values:
739  
740 =over 4
741  
742 =item all
743  
744 If set to a true value, all entries of the changelog are returned,
745 this overrides all other options.
746  
747 =item count
748  
749 Expects a signed integer as value. Returns C<value> entries from the
750 top of the changelog if set to a positive integer, and C<abs(value)>
751 entries from the tail if set to a negative integer.
752  
753 =item offset
754  
755 Expects a signed integer as value. Changes the starting point for
756 C<count>, either counted from the top (positive integer) or from
757 the tail (negative integer). C<offset> has no effect if C<count>
758 wasn't given as well.
759  
760 =back
761  
762 Some examples for the above options. Imagine an example changelog with
763 entries for the versions 1.2, 1.3, 2.0, 2.1, 2.2, 3.0 and 3.1.
764  
765 Range Included entries
766 ----- ----------------
767 since => '2.0' 3.1, 3.0, 2.2
768 until => '2.0' 1.3, 1.2
769 from => '2.0' 3.1, 3.0, 2.2, 2.1, 2.0
770 to => '2.0' 2.0, 1.3, 1.2
771 count => 2 3.1, 3.0
772 count => -2 1.3, 1.2
773 count => 3, offset => 2 2.2, 2.1, 2.0
774 count => 2, offset => -3 2.0, 1.3
775 count => -2, offset => 3 3.0, 2.2
776 count => -2, offset => -3 2.2, 2.1
777  
778 Any combination of one option of C<since> and C<from> and one of
779 C<until> and C<to> returns the intersection of the two results
780 with only one of the options specified.
781  
782 =head1 CHANGES
783  
784 =head2 Version 2.00 (dpkg 1.20.0)
785  
786 Remove methods: $chlog->dpkg(), $chlog->rfc822().
787  
788 =head2 Version 1.01 (dpkg 1.18.8)
789  
790 New method: $chlog->format_range().
791  
792 Deprecated methods: $chlog->dpkg(), $chlog->rfc822().
793  
794 New field Timestamp in output formats.
795  
796 =head2 Version 1.00 (dpkg 1.15.6)
797  
798 Mark the module as public.
799  
800 =cut
801 2 1;
« Dpkg/Source/Patch.pm ↑ Summary Dpkg/Vendor/Debian.pm »