This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch master in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=a7901786002cf4bd9f1dfbf3e4d844fc27478a8b commit a7901786002cf4bd9f1dfbf3e4d844fc27478a8b Author: Guillem Jover <[email protected]> AuthorDate: Tue Sep 18 23:34:59 2018 +0200 dpkg-parsechangelog: Add new --reverse option This option will make the output be in reverse order. --- debian/changelog | 2 ++ man/dpkg-parsechangelog.man | 6 +++++- scripts/Dpkg/Changelog.pm | 9 +++++---- scripts/Dpkg/Changelog/Parse.pm | 2 +- scripts/dpkg-parsechangelog.pl | 3 +++ scripts/t/Dpkg_Changelog.t | 6 +++++- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/debian/changelog b/debian/changelog index 6e18c2587..10d681f61 100644 --- a/debian/changelog +++ b/debian/changelog @@ -98,6 +98,8 @@ dpkg (1.19.1) UNRELEASED; urgency=medium * Switch dpkg-gencontrol and dpkg-genchanges to track automatically generated artifacts by using the Auto-Built-Package field from the binary package instead of hardcoding package name patterns (such as «-dbgsym$»). + * Add new --reverse option to dpkg-parsechangelog, to list the changelog + entries in reverse order. * Architecture support: - Add support for riscv64 CPU. Closes: #822914 Thanks to Manuel A. Fernandez Montecelo <[email protected]> diff --git a/man/dpkg-parsechangelog.man b/man/dpkg-parsechangelog.man index fd73fc8db..0a46394f8 100644 --- a/man/dpkg-parsechangelog.man +++ b/man/dpkg-parsechangelog.man @@ -74,7 +74,7 @@ Set the output format. Currently supported values are option existed) and the default. It consists of one paragraph in Debian control format (see \fBdeb\-control\fP(5)). If more than one entry is requested, then most fields are taken from the -most recent entry, except otherwise stated: +first entry (usually the most recent entry), except otherwise stated: .RS .TP .BI Source: " pkg-name" @@ -122,6 +122,10 @@ The \fBrfc822\fP format uses the same fields but outputs a separate paragraph for each changelog entry so that all metadata for each entry is preserved. .TP +.B \-\-reverse +Include all changes in reverse order (since dpkg 1.19.1). +Note: for the \fBdpkg\fP format the first entry will be the most ancient entry. +.TP .B \-\-all Include all changes. Note: other options have no effect when this is in use. .TP diff --git a/scripts/Dpkg/Changelog.pm b/scripts/Dpkg/Changelog.pm index 35e48ef02..39353fb5c 100644 --- a/scripts/Dpkg/Changelog.pm +++ b/scripts/Dpkg/Changelog.pm @@ -332,11 +332,12 @@ sub get_range { my ($self, $range) = @_; $range //= {}; my $res = $self->_data_range($range); - if (defined $res) { - return @$res if wantarray; - return $res; + return unless defined $res; + if (wantarray) { + return reverse @{$res} if $range->{reverse}; + return @{$res}; } else { - return; + return $res; } } diff --git a/scripts/Dpkg/Changelog/Parse.pm b/scripts/Dpkg/Changelog/Parse.pm index 28bb6892a..91da43ab2 100644 --- a/scripts/Dpkg/Changelog/Parse.pm +++ b/scripts/Dpkg/Changelog/Parse.pm @@ -152,7 +152,7 @@ sub _changelog_parse { $options{format} //= 'dpkg'; $options{compression} //= $options{file} ne 'debian/changelog'; - my @range_opts = qw(since until from to offset count all); + my @range_opts = qw(since until from to offset count reverse all); $options{all} = 1 if exists $options{all}; if (none { defined $options{$_} } @range_opts) { $options{count} = 1; diff --git a/scripts/dpkg-parsechangelog.pl b/scripts/dpkg-parsechangelog.pl index 86c30b451..3d14c4219 100755 --- a/scripts/dpkg-parsechangelog.pl +++ b/scripts/dpkg-parsechangelog.pl @@ -56,6 +56,7 @@ sub usage { "Parser options: --format <output-format> set output format (defaults to 'dpkg'). + --reverse include all changes in reverse order. --all include all changes. -s, --since <version> include all changes later than <version>. -v <version> ditto. @@ -88,6 +89,8 @@ while (@ARGV) { $options{changelogformat} =~ m/^([0-9a-z]+)$/; } elsif ($arg eq '--format') { $options{format} = shift; + } elsif ($arg eq '--reverse') { + $options{reverse} = 1; } elsif ($arg eq '-l' or $arg eq '--file') { $options{file} = shift; usageerr(g_('missing changelog filename')) diff --git a/scripts/t/Dpkg_Changelog.t b/scripts/t/Dpkg_Changelog.t index ed9f8a965..8aa1bfc45 100644 --- a/scripts/t/Dpkg_Changelog.t +++ b/scripts/t/Dpkg_Changelog.t @@ -16,7 +16,7 @@ use strict; use warnings; -use Test::More tests => 94; +use Test::More tests => 96; use Test::Dpkg qw(:paths); use File::Basename; @@ -81,6 +81,10 @@ foreach my $file ("$datadir/countme", "$datadir/shadow", "$datadir/fields", count => 3, versions => [ '2:2.0-1', '1:2.0~rc2-3', '1:2.0~rc2-2' ], name => 'positive count'); + check_options(%ref, range => { count => 3, reverse => 1 }, + count => 3, + versions => [ '1:2.0~rc2-2', '1:2.0~rc2-3', '2:2.0-1' ], + name => 'positive reverse count'); check_options(%ref, range => { count => -3 }, count => 3, versions => [ -- Dpkg.Org's dpkg

