This is an automated email from the git hooks/post-receive script. intrigeri pushed a commit to tag debian_version_0_7-1 in repository libparse-debianchangelog-perl.
commit e8a45969a9eb420e7184b81a48851cc06ecc376b Author: Frank Lichtenheld <fr...@lichtenheld.de> Date: Tue Aug 16 00:46:50 2005 +0000 Merge 0.7 to MAIN --- lib/Parse/DebianChangelog.pm | 154 ++++++++++++++++++++++++++++++++++--------- t/Parse-DebianChangelog.t | 10 +-- 2 files changed, 128 insertions(+), 36 deletions(-) diff --git a/lib/Parse/DebianChangelog.pm b/lib/Parse/DebianChangelog.pm index 1734b44..8f109e4 100644 --- a/lib/Parse/DebianChangelog.pm +++ b/lib/Parse/DebianChangelog.pm @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # =head1 NAME @@ -41,7 +41,7 @@ Parse::DebianChangelog - parse Debian changelogs and output them in other format =head1 DESCRIPTION -Parse::DebianChangelog parses Debian changelogs as desribed in the Debian +Parse::DebianChangelog parses Debian changelogs as described in the Debian policy (version 3.6.2.1 at the time of this writing). See section L<"SEE ALSO"> for locations where to find this definition. @@ -60,10 +60,10 @@ changelogs to various other formats. These are currently: =item dpkg -Format as know from L<dpkg-parsechangelog(1)>. All requested entries +Format as known from L<dpkg-parsechangelog(1)>. All requested entries (see L<"METHODS"> for an explanation what this means) are returned in the usual Debian control format, merged in one stanza, ready to be used -a F<.changes> file. +in a F<.changes> file. =item rfc822 @@ -74,7 +74,7 @@ to use if you want a machine-usable representation of the changelog. =item html The changelog is converted to a somewhat nice looking HTML file with -some niće features as a quicklink bar with direct links to every entry. +some nice features as a quicklink bar with direct links to every entry. NOTE: This is not very configurable yet and was specifically designed to be used on L<http://packages.debian.org/>. This is planned to be changed until version 1.0. @@ -97,7 +97,7 @@ use Parse::DebianChangelog::Util qw( :all ); use Parse::DebianChangelog::Entry; our $CLASSNAME = 'Parse::DebianChangelog'; -our $VERSION = 0.6; +our $VERSION = 0.7; =pod @@ -448,6 +448,63 @@ sub data { return $self->{data}; } +sub __sanity_check_range { + my ( $data, $from, $to, $since, $until ) = @_; + + if ($$from && $$since) { + warn( "you can only specify one of 'from' and 'since'\n" ); + $$from = ''; + } + if ($$to && $$until) { + warn( "you can only specify one of 'to' and 'until'\n" ); + $$to = ''; + } + if ($data->[0]{Version} eq $$since) { + warn( "'since' option specifies most recent version\n" ); + $$since = ''; + } + if ($data->[$#{$data}]{Version} eq $$until) { + warn( "'until' option specifies oldest version\n" ); + $$until = ''; + } + #TODO: compare versions +} + +sub _data_range { + my ($self, $config) = @_; + + my $data = $self->data or return undef; + my $since = $config->{since} || ''; + my $until = $config->{until} || ''; + my $from = $config->{from} || ''; + my $to = $config->{to} || ''; + + return $data if $config->{all}; + + __sanity_check_range( $data, \$from, \$to, \$since, \$until ); + + unless ($from or $to or $since or $until) { + return [ $data->[0] ]; + } + + my @result; + + my $include = 1; + $include = 0 if $to or $until; + foreach (@$data) { + my $v = $_->{Version}; + $include = 1 if $v eq $to; + last if $v eq $since; + + push @result, $_ if $include; + + $include = 1 if $v eq $until; + last if $v eq $from; + } + + return \@result; +} + =pod =head3 dpkg @@ -498,8 +555,8 @@ C<dpkg_str> returns a stringified version of this hash which should look exactly like the output of L<dpkg-parsechangelog(1)>. The fields are ordered like in the list above. -Both methods support the configuration item C<since> which works exactly -like the C<-v> option of dpkg-parsechangelog. +Both methods only support the common output options described in +section L<"COMMON OUTPUT OPTIONS">. =cut @@ -520,8 +577,7 @@ sub dpkg { $self->{config}{DPKG} = $config if $config; $config = $self->{config}{DPKG} || {}; - my $data = $self->{data} or return undef; - my $since = $config->{since} || ''; + my $data = $self->_data_range( $config ) or return undef; my %f; foreach my $field (qw( Urgency Source Version @@ -529,16 +585,12 @@ sub dpkg { $f{$field} = $data->[0]{$field}; } - warn( "-v<since> option specifies most recent version" ) - if $f{Version} eq $since; - $f{Changes} = get_dpkg_changes( $data->[0] ); $f{Closes} = [ @{$data->[0]{Closes}} ]; my $first = 1; my $urg_comment = ''; foreach my $entry (@$data) { $first = 0, next if $first; - last if !$since or $entry->{Version} eq $since; my $oldurg = $f{Urgency} || ''; my $oldurgn = $URGENCIES{$f{Urgency}} || -1; @@ -549,7 +601,6 @@ sub dpkg { $f{Changes} .= "\n .".get_dpkg_changes( $entry ); push @{$f{Closes}}, @{$entry->{Closes}}; - } $f{Closes} = join " ", sort { $a <=> $b } @{$f{Closes}}; @@ -579,8 +630,8 @@ C<rfc822_str> returns a stringified version of this hash which looks similar to the output of dpkg-parsechangelog but instead of one stanza the output contains one stanza for each entry. -Both methods support the configuration item C<since> which works exactly -like the C<-v> option of dpkg-parsechangelog. +Both methods only support the common output options described in +section L<"COMMON OUTPUT OPTIONS">. =cut @@ -590,18 +641,10 @@ sub rfc822 { $self->{config}{RFC822} = $config if $config; $config = $self->{config}{RFC822} || {}; - my $data = $self->{data} or return undef; - my $since = $config->{since} || ''; - + my $data = $self->_data_range( $config ) or return undef; my @out_data; - warn( "-v<since> option specifies most recent version" ) - if $data->[0]{Version} eq $since; - my $first = 1; foreach my $entry (@$data) { - last if (!$since and !$first) or $entry->{Version} eq $since; - $first = 0; - my %f; foreach my $field (qw( Urgency Source Version Distribution Maintainer Date )) { @@ -643,7 +686,9 @@ how to edit it. The method C<html_str> is an alias for C<html>. -Both methods support the following configuration items (as usual to give +Both methods support the common output options described in +section L<"COMMON OUTPUT OPTIONS"> and additionally the following +configuration options (as usual to give in a hash reference as parameter to the method call): =over 4 @@ -679,7 +724,8 @@ sub html { $self->{config}{HTML} = $config if $config; $config = $self->{config}{HTML} || {}; - my $data = $self->{data} or return undef; + $config->{all} = 1 unless exists $config->{all}; + my $data = $self->_data_range( $config ) or return undef; require CGI; import CGI qw( -no_xhtml -no_debug ); @@ -749,14 +795,16 @@ sub html { $years{$last_year}{CONTENT_VERSIONS} ||= []; $years{$last_year}{CONTENT_YEAR} ||= $last_year; - my $text = $self->apply_filters( 'html::changes', $entry->{Changes}, $cgi ); + my $text = $self->apply_filters( 'html::changes', + $entry->{Changes}, $cgi ); (my $maint_name = $entry->{Maintainer} ) =~ s|<([a-zA-Z0-9_\+\-\.]+\@([a-zA-Z0-9][\w\.+\-]+\.[a-zA-Z]{2,}))>||o; my $maint_mail = $1; my $parse_error; $parse_error = $cgi->p( { -class=>'parse_error' }, - "(There has been a parse error in the entry above, if some values don't make sense please check the original changelog)" ) if $entry->{ERROR}; + "(There has been a parse error in the entry above, if some values don't make sense please check the original changelog)" ) + if $entry->{ERROR}; push @{$years{$last_year}{CONTENT_VERSIONS}}, { CONTENT_VERSION => $entry->{Version}, @@ -909,6 +957,50 @@ sub replace_filter { 1; __END__ +=head1 COMMON OUTPUT OPTIONS + +The following options are supported by all output methods, +all take a version number as value: + +=over 4 + +=item since + +Causes changelog information from all versions strictly +later than B<version> to be used. + +(works exactly like the C<-v> option of dpkg-parsechangelog). + +=item until + +Causes changelog information from all versions strictly +ealier than B<version> to be used. + +=item from + +Similar to C<since> but also includes the information for the +specified B<version> itself. + +=item to + +Similar to C<until> but also includes the information for the +specified B<version> itself. + +=back + +Some examples for the above options. Imagine an example changelog with +entries for the versions 1.2, 1.3, 2.0, 2.1, 2.2, 3.0 and 3.1. + + Call Included entries + C<E<lt>formatE<gt>({ since =E<gt> '2.0' })> 2.2, 3.0, 3.1 + C<E<lt>formatE<gt>({ until =E<gt> '2.0' })> 1.2, 1.3 + C<E<lt>formatE<gt>({ from =E<gt> '2.0' })> 2.0, 2.2, 3.0, 3.1 + C<E<lt>formatE<gt>({ to =E<gt> '2.0' })> 1.2, 1.3, 2.0 + +Any combination of one option of C<since> and C<from> and one of +C<until> and C<to> returns the intersection of the two results +with only one of the options specified. + =head1 SEE ALSO Parse::DebianChangelog::Entry, Parse::DebianChangelog::ChangesFilters @@ -936,6 +1028,6 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =cut diff --git a/t/Parse-DebianChangelog.t b/t/Parse-DebianChangelog.t index 3c2c078..4d691ac 100644 --- a/t/Parse-DebianChangelog.t +++ b/t/Parse-DebianChangelog.t @@ -71,13 +71,13 @@ foreach my $file (qw(Changes t/examples/shadow)) { $html_out =~ s/Generated .*? by//go; $html_out2 =~ s/Generated .*? by//go; - ok( $html_out eq $html_out2 ) + is( $html_out, $html_out2 ) and unlink "t/$basename.html.tmp", "t/$basename.html.tmp.2"; my $str = $changes->dpkg_str(); - ok( $str eq `dpkg-parsechangelog -l$file`, - 'Output of dpkg_out equal to output of dpkg-parsechangelog' ); + is( $str, `dpkg-parsechangelog -l$file`, + 'Output of dpkg_str equal to output of dpkg-parsechangelog' ); my @data = $changes->data; @@ -86,8 +86,8 @@ foreach my $file (qw(Changes t/examples/shadow)) { my $oldest_version = $data[-1]->Version; $str = $changes->dpkg_str({ since => $oldest_version }); - ok( $str eq `dpkg-parsechangelog -v$oldest_version -l$file`, - 'Output of dpkg_out equal to output of dpkg-parsechangelog' ) + is( $str, `dpkg-parsechangelog -v$oldest_version -l$file`, + 'Output of dpkg_str equal to output of dpkg-parsechangelog' ) or diag("oldest_version=$oldest_version"); $str = $changes->rfc822_str(); -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libparse-debianchangelog-perl.git _______________________________________________ Pkg-perl-cvs-commits mailing list Pkg-perl-cvs-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits