The branch, master has been updated
       via  ebe27f2ad5e1438324c6f87021aa24b3bce8f9df (commit)
       via  aded1d7a4a7c5acfef5f002fb6a3e4f7b0477eed (commit)
       via  ef838bec60117cd043a82af266f5f0e570341a05 (commit)
       via  7d81f1cd37b6985c7416a92efa3f9d0374c3655b (commit)
       via  5ab947df77388732f7a7b30cd07e8065c1a71c34 (commit)
      from  722c3b3da1e6ae29dad21b921c08886da5d59918 (commit)


- Shortlog ------------------------------------------------------------
ebe27f2 Dpkg::Fields::Object: Support filehandles and strings for output and 
dump
aded1d7 600_Dpkg_Changelog.t: Add more tests
ef838be Dpkg::Changelog::Debian: Don't separate forced Xs- fields from normal 
ones
7d81f1c Dpkg::Changelog: Use Dpkg::Fields for field handling
5ab947d dpkg-parsechangelog(1): Document the new parser options

Summary of changes:
 ChangeLog                           |   26 ++++
 man/ChangeLog                       |    5 +
 man/dpkg-parsechangelog.1           |   88 +++++++++++-
 scripts/Dpkg/Changelog.pm           |  254 +++++++++++------------------------
 scripts/Dpkg/Changelog/Debian.pm    |   14 +-
 scripts/Dpkg/Fields.pm              |   14 ++-
 scripts/Makefile.am                 |    1 +
 scripts/t/600_Dpkg_Changelog.t      |   66 ++++++++-
 scripts/t/600_Dpkg_Changelog/fields |   23 +++
 9 files changed, 296 insertions(+), 195 deletions(-)
-----------------------------------------------------------------------
Details of changes:

commit ebe27f2ad5e1438324c6f87021aa24b3bce8f9df
Author: Frank Lichtenheld <[EMAIL PROTECTED]>
Date:   Sun Jan 13 18:07:15 2008 +0100

    Dpkg::Fields::Object: Support filehandles and strings for output and dump
    
    * scripts/Dpkg/Fields.pm (dump): Allow to omit the
    filehandle argument. If the function is called in
    non-void context, also remove the printed string
    to the caller. Together this avoids having to fiddle
    with filehandles if the caller doesn't want to.
    (output): Likewise.
    * scripts/Dpkg/Changelog.pm (data2rfc822): Simplify
    using this new behaviour.

diff --git a/ChangeLog b/ChangeLog
index 87ba103..4d1028d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2008-01-13  Frank Lichtenheld  <[EMAIL PROTECTED]>
 
+       * scripts/Dpkg/Fields.pm (dump): Allow to omit the
+       filehandle argument. If the function is called in
+       non-void context, also remove the printed string
+       to the caller. Together this avoids having to fiddle
+       with filehandles if the caller doesn't want to.
+       (output): Likewise.
+       * scripts/Dpkg/Changelog.pm (data2rfc822): Simplify
+       using this new behaviour.
+
        * scripts/t/600_Dpkg_Changelog.t: Add a new changelog
        'fields' that tests the handling of the different fields
        in the dpkg format.
diff --git a/scripts/Dpkg/Changelog.pm b/scripts/Dpkg/Changelog.pm
index e186871..de59c66 100644
--- a/scripts/Dpkg/Changelog.pm
+++ b/scripts/Dpkg/Changelog.pm
@@ -35,7 +35,6 @@ package Dpkg::Changelog;
 use strict;
 use warnings;
 
-use v5.8.0; # for open $fh, '>', \$scalar
 use English;
 
 use Dpkg;
@@ -665,12 +664,7 @@ sub data2rfc822 {
 
        return join "\n", @rfc822;
     } else {
-       my $rfc822_str = "";
-
-       open my $fh, '>', \$rfc822_str
-           or warning("couldn't open filehandle for string");
-       $data->output($fh);
-       close $fh;
+       my $rfc822_str = $data->output;
 
        return $rfc822_str;
     }
diff --git a/scripts/Dpkg/Fields.pm b/scripts/Dpkg/Fields.pm
index 809ca66..c640bb5 100644
--- a/scripts/Dpkg/Fields.pm
+++ b/scripts/Dpkg/Fields.pm
@@ -158,15 +158,19 @@ sub NEXTKEY {
 
 sub dump {
     my ($self, $fh) = @_;
+    my $str = "";
     foreach (@{$self->[1]}) {
        if (exists $self->[0]->{$_}) {
-           print $fh "$_: " . $self->[0]->{$_} . "\n";
+           print $fh "$_: " . $self->[0]->{$_} . "\n" if $fh;
+           $str .= "$_: " . $self->[0]->{$_} . "\n" if defined wantarray;
        }
     }
+    return $str;
 }
 
 sub output {
     my ($self, $fh, $substvars) = @_;
+    my $str = "";
 
     # Add substvars to refer to other fields
     if (defined($substvars)) {
@@ -194,8 +198,14 @@ sub output {
            $v =~ s/\s*,\s*$//;
         }
         $v =~ s/\$\{\}/\$/g;
-        print $fh "$f: $v\n" || syserr(_g("write error on control data"));
+       if ($fh) {
+           print $fh "$f: $v\n" || syserr(_g("write error on control data"));
+       }
+       if (defined wantarray) {
+           $str .= "$f: $v\n";
+       }
     }
+    return $str;
 }
 
 1;

commit aded1d7a4a7c5acfef5f002fb6a3e4f7b0477eed
Author: Frank Lichtenheld <[EMAIL PROTECTED]>
Date:   Sun Jan 13 16:38:28 2008 +0100

    600_Dpkg_Changelog.t: Add more tests
    
    * scripts/t/600_Dpkg_Changelog.t: Add a new changelog
    'fields' that tests the handling of the different fields
    in the dpkg format.

diff --git a/ChangeLog b/ChangeLog
index 1fb295d..87ba103 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2008-01-13  Frank Lichtenheld  <[EMAIL PROTECTED]>
 
+       * scripts/t/600_Dpkg_Changelog.t: Add a new changelog
+       'fields' that tests the handling of the different fields
+       in the dpkg format.
+
        * scripts/Dpkg/Changelog.pm: Replace all field hashes
        with Dpkg::Changelog::Entry objects.
        (Dpkg::Changelog::Entry): Base on Dpkg::Fields::Object.
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index b70a576..e27f294 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -72,6 +72,7 @@ EXTRA_DIST = \
        t/500_Dpkg_Path.t \
        t/600_Dpkg_Changelog.t \
        t/600_Dpkg_Changelog/countme \
+       t/600_Dpkg_Changelog/fields \
        t/600_Dpkg_Changelog/misplaced-tz \
        t/600_Dpkg_Changelog/shadow \
        t/700_Dpkg_Control.t \
diff --git a/scripts/t/600_Dpkg_Changelog.t b/scripts/t/600_Dpkg_Changelog.t
index a9b8f32..6c4837a 100644
--- a/scripts/t/600_Dpkg_Changelog.t
+++ b/scripts/t/600_Dpkg_Changelog.t
@@ -6,11 +6,13 @@ use warnings;
 use File::Basename;
 
 BEGIN {
-    my $no_examples = 2;
+    my $no_examples = 3;
     my $no_err_examples = 1;
     my $no_tests = $no_examples * 4
        + $no_err_examples * 2
-       + 48;
+       + 24 # countme
+       +  2 # fields
+       + 24;
 
     require Test::More;
     import Test::More tests => $no_tests;
@@ -30,7 +32,7 @@ my $test = Dpkg::Changelog::Debian->init( { infile => 
'/nonexistant',
 ok( !defined($test), "fatal parse errors lead to init() returning undef");
 
 my $save_data;
-foreach my $file ("$srcdir/countme", "$srcdir/shadow") {
+foreach my $file ("$srcdir/countme", "$srcdir/shadow", "$srcdir/fields") {
 
     my $changes = Dpkg::Changelog::Debian->init( { infile => $file,
                                                   quiet => 1 } );
@@ -157,6 +159,56 @@ foreach my $file ("$srcdir/countme", "$srcdir/shadow") {
                       'until => "1:2.0~rc2-1sarge2"' );
        #TODO: test combinations
     }
+    if ($file eq "$srcdir/fields") {
+       my $str = $changes->dpkg_str({ all => 1 });
+       my $expected = 'Source: fields
+Version: 2.0-0etch1
+Distribution: stable
+Urgency: high
+Maintainer: Frank Lichtenheld <[EMAIL PROTECTED]>
+Date: Sun, 13 Jan 2008 15:49:19 +0100
+Closes: 1000000 1111111 1111111 2222222 2222222
+Changes: 
+ fields (2.0-0etch1) stable; urgency=low
+ .
+   * Upload to stable (Closes: #1111111, #2222222)
+ .
+ fields (2.0-1) unstable; urgency=medium
+ .
+   * Upload to unstable (Closes: #1111111, #2222222)
+ .
+ fields (2.0~b1-1) unstable; urgency=low,xc-userfield=foobar
+ .
+   * Beta
+ .
+ fields (1.0) experimental; urgency=high
+ .
+   * First upload (Closes: #1000000)
+Xc-Userfield: foobar
+';
+       cmp_ok($str,'eq',$expected,"fields handling");
+
+       $str = $changes->dpkg_str({ offset => 1, count => 2 });
+       $expected = 'Source: fields
+Version: 2.0-1
+Distribution: unstable
+Urgency: medium
+Maintainer: Frank Lichtenheld <[EMAIL PROTECTED]>
+Date: Sun, 12 Jan 2008 15:49:19 +0100
+Closes: 1111111 2222222
+Changes: 
+ fields (2.0-1) unstable; urgency=medium
+ .
+   * Upload to unstable (Closes: #1111111, #2222222)
+ .
+ fields (2.0~b1-1) unstable; urgency=low,xc-userfield=foobar
+ .
+   * Beta
+Xc-Userfield: foobar
+';
+       cmp_ok($str,'eq',$expected,"fields handling 2");
+
+    }
 
 #     if ($file eq 'Changes') {
 #      my $v = $data[0]->Version;
diff --git a/scripts/t/600_Dpkg_Changelog/fields 
b/scripts/t/600_Dpkg_Changelog/fields
new file mode 100644
index 0000000..5f08b71
--- /dev/null
+++ b/scripts/t/600_Dpkg_Changelog/fields
@@ -0,0 +1,23 @@
+fields (2.0-0etch1) stable; urgency=low
+
+  * Upload to stable (Closes: #1111111, #2222222)
+
+ -- Frank Lichtenheld <[EMAIL PROTECTED]>  Sun, 13 Jan 2008 15:49:19 +0100
+
+fields (2.0-1) unstable; urgency=medium
+
+  * Upload to unstable (Closes: #1111111, #2222222)
+
+ -- Frank Lichtenheld <[EMAIL PROTECTED]>  Sun, 12 Jan 2008 15:49:19 +0100
+
+fields (2.0~b1-1) unstable; urgency=low,xc-userfield=foobar
+
+  * Beta
+
+ -- Frank Lichtenheld <[EMAIL PROTECTED]>  Sun, 11 Jan 2008 15:49:19 +0100
+
+fields (1.0) experimental; urgency=high
+
+  * First upload (Closes: #1000000)
+
+ -- Frank Lichtenheld <[EMAIL PROTECTED]>  Sun, 10 Jan 2008 15:49:19 +0100

commit ef838bec60117cd043a82af266f5f0e570341a05
Author: Frank Lichtenheld <[EMAIL PROTECTED]>
Date:   Sun Jan 13 16:35:40 2008 +0100

    Dpkg::Changelog::Debian: Don't separate forced Xs- fields from normal ones

diff --git a/scripts/Dpkg/Changelog/Debian.pm b/scripts/Dpkg/Changelog/Debian.pm
index 6ff9567..7971466 100644
--- a/scripts/Dpkg/Changelog/Debian.pm
+++ b/scripts/Dpkg/Changelog/Debian.pm
@@ -175,7 +175,7 @@ sub parse {
                } else {
                    $self->_do_parse_error($file, $NR,
                                           sprintf(_g("unknown key-value key %s 
- copying to XS-%s"), $k, $k));
-                   $entry->{ExtraFields}{"XS-$k"} = $v;
+                   $entry->{"XS-$k"} = $v;
                }
            }
            $expect= 'start of change data';

commit 7d81f1cd37b6985c7416a92efa3f9d0374c3655b
Author: Frank Lichtenheld <[EMAIL PROTECTED]>
Date:   Sun Jan 13 16:03:39 2008 +0100

    Dpkg::Changelog: Use Dpkg::Fields for field handling
    
    * scripts/Dpkg/Changelog.pm: Replace all field hashes
    with Dpkg::Changelog::Entry objects.
    (Dpkg::Changelog::Entry): Base on Dpkg::Fields::Object.
    (data2rfc822): Use Dpkg::Fields::Object->output and fix
    handling of user-defined fields.
    (data2rfc822_mult): Merge into data2rfc822 (autodetect
    whether the argument is an object or an array of object).
    * scripts/Dpkg/Changelog/Debian.pm: Adapt for
    Dpkg::Changelog::Entry changes.
    * scripts/t/600_Dpkg_Changelog.t: Likewise.

diff --git a/ChangeLog b/ChangeLog
index ba126bd..1fb295d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2008-01-13  Frank Lichtenheld  <[EMAIL PROTECTED]>
+
+       * scripts/Dpkg/Changelog.pm: Replace all field hashes
+       with Dpkg::Changelog::Entry objects.
+       (Dpkg::Changelog::Entry): Base on Dpkg::Fields::Object.
+       (data2rfc822): Use Dpkg::Fields::Object->output and fix
+       handling of user-defined fields.
+       (data2rfc822_mult): Merge into data2rfc822 (autodetect
+       whether the argument is an object or an array of object).
+       * scripts/Dpkg/Changelog/Debian.pm: Adapt for
+       Dpkg::Changelog::Entry changes.
+       * scripts/t/600_Dpkg_Changelog.t: Likewise.
+
 2008-01-12  Raphael hertzog  <[EMAIL PROTECTED]>
 
        * scripts/Dpkg/Fields.pm, scripts/dpkg-source.pl: Add support of
diff --git a/scripts/Dpkg/Changelog.pm b/scripts/Dpkg/Changelog.pm
index 8a5cc7f..e186871 100644
--- a/scripts/Dpkg/Changelog.pm
+++ b/scripts/Dpkg/Changelog.pm
@@ -35,12 +35,14 @@ package Dpkg::Changelog;
 use strict;
 use warnings;
 
+use v5.8.0; # for open $fh, '>', \$scalar
 use English;
 
 use Dpkg;
 use Dpkg::Gettext;
 use Dpkg::ErrorHandling qw(warning report syserr subprocerr);
 use Dpkg::Cdata;
+use Dpkg::Fields qw(set_field_importance);
 
 use base qw(Exporter);
 
@@ -408,15 +410,19 @@ See L<dpkg>.
 
 =cut
 
-our ( %FIELDIMPS, %URGENCIES );
+our ( @CHANGELOG_FIELDS, %CHANGELOG_FIELDS );
+our ( @URGENCIES, %URGENCIES );
 BEGIN {
-    my $i=100;
-    grep($FIELDIMPS{$_}=$i--,
-        qw(Source Version Distribution Urgency Maintainer Date Closes
-           Changes));
-    $i=1;
-    grep($URGENCIES{$_}=$i++,
-        qw(low medium high critical emergency));
+    @CHANGELOG_FIELDS = qw(Source Version Distribution
+                           Urgency Maintainer Date Closes Changes
+                           Timestamp Header Items Trailer
+                           Urgency_comment Urgency_lc);
+    tie %CHANGELOG_FIELDS, 'Dpkg::Fields::Object';
+    %CHANGELOG_FIELDS = map { $_ => 1 } @CHANGELOG_FIELDS;
+    set_field_importance(@CHANGELOG_FIELDS);
+    @URGENCIES = qw(low medium high critical emergency);
+    my $i = 1;
+    %URGENCIES = map { $_ => $i++ } @URGENCIES;
 }
 
 sub dpkg {
@@ -427,39 +433,51 @@ sub dpkg {
     $config = $self->{config}{DPKG} || {};
     my $data = $self->_data_range( $config ) or return undef;
 
-    my %f;
+    my $f = new Dpkg::Changelog::Entry;
     foreach my $field (qw( Urgency Source Version
                           Distribution Maintainer Date )) {
-       $f{$field} = $data->[0]{$field};
+       $f->{$field} = $data->[0]{$field};
+    }
+    # handle unknown fields
+    foreach my $field (keys %{$data->[0]}) {
+       next if $CHANGELOG_FIELDS{$field};
+       $f->{$field} = $data->[0]{$field};
     }
 
-    $f{Changes} = get_dpkg_changes( $data->[0] );
-    $f{Closes} = [ @{$data->[0]{Closes}} ];
+    $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;
 
-       my $oldurg = $f{Urgency} || '';
-       my $oldurgn = $URGENCIES{$f{Urgency}} || -1;
-       my $newurg = $entry->{Urgency_LC} || '';
-       my $newurgn = $URGENCIES{$entry->{Urgency_LC}} || -1;
-       $f{Urgency} = ($newurgn > $oldurgn) ? $newurg : $oldurg;
-       $urg_comment .= $entry->{Urgency_Comment};
-
-       $f{Changes} .= "\n .".get_dpkg_changes( $entry );
-       push @{$f{Closes}}, @{$entry->{Closes}};
+       my $oldurg = $f->{Urgency} || '';
+       my $oldurgn = $URGENCIES{$f->{Urgency}} || -1;
+       my $newurg = $entry->{Urgency_lc} || '';
+       my $newurgn = $URGENCIES{$entry->{Urgency_lc}} || -1;
+       $f->{Urgency} = ($newurgn > $oldurgn) ? $newurg : $oldurg;
+       $urg_comment .= $entry->{Urgency_comment};
+
+       $f->{Changes} .= "\n .".get_dpkg_changes( $entry );
+       push @{$f->{Closes}}, @{$entry->{Closes}};
+
+       # handle unknown fields
+       foreach my $field (keys %$entry) {
+           next if $CHANGELOG_FIELDS{$field};
+           next if exists $f->{$field};
+           $f->{$field} = $entry->{$field};
+       }
     }
 
-    $f{Closes} = join " ", sort { $a <=> $b } @{$f{Closes}};
-    $f{Urgency} .= $urg_comment;
+    $f->{Closes} = join " ", sort { $a <=> $b } @{$f->{Closes}};
+    $f->{Urgency} .= $urg_comment;
 
-    return %f if wantarray;
-    return \%f;
+    return %$f if wantarray;
+    return $f;
 }
 
 sub dpkg_str {
-    return data2rfc822( scalar dpkg(@_), \%FIELDIMPS );
+    return data2rfc822(scalar dpkg(@_));
 }
 
 =pod
@@ -495,16 +513,23 @@ sub rfc822 {
     my @out_data;
 
     foreach my $entry (@$data) {
-       my %f;
+       my $f = new Dpkg::Changelog::Entry;
        foreach my $field (qw( Urgency Source Version
-                          Distribution Maintainer Date )) {
-           $f{$field} = $entry->{$field};
+                              Distribution Maintainer Date )) {
+           $f->{$field} = $entry->{$field};
        }
 
-       $f{Urgency} .= $entry->{Urgency_Comment};
-       $f{Changes} = get_dpkg_changes( $entry );
-       $f{Closes} = join " ", sort { $a <=> $b } @{$entry->{Closes}};
-       push @out_data, \%f;
+       $f->{Urgency} .= $entry->{Urgency_Comment};
+       $f->{Changes} = get_dpkg_changes( $entry );
+       $f->{Closes} = join " ", sort { $a <=> $b } @{$entry->{Closes}};
+
+       # handle unknown fields
+       foreach my $field (keys %$entry) {
+           next if $CHANGELOG_FIELDS{$field};
+           $f->{$field} = $entry->{$field};
+       }
+
+       push @out_data, $f;
     }
 
     return @out_data if wantarray;
@@ -512,7 +537,7 @@ sub rfc822 {
 }
 
 sub rfc822_str {
-    return data2rfc822_mult( scalar rfc822(@_), \%FIELDIMPS );
+    return data2rfc822(scalar rfc822(@_));
 }
 
 =pod
@@ -621,59 +646,34 @@ sub find_closes {
 
 =head3 data2rfc822
 
-Takes two hash references as arguments. The first should contain the
-data to output in RFC822 format. The second can contain a sorting order
-for the fields. The higher the numerical value of the hash value, the
-earlier the field is printed if it exists.
+Takes a single argument, either a Dpkg::Changelog::Entry object
+or a reference to an array of such objects.
 
-Return the data in RFC822 format as string.
+Returns the data in RFC822 format as string.
 
 =cut
 
 sub data2rfc822 {
-    my ($data, $fieldimps) = @_;
-    my $rfc822_str = '';
-
-# based on /usr/lib/dpkg/controllib.pl
-    for my $f (sort { $fieldimps->{$b} <=> $fieldimps->{$a} } keys %$data) {
-       my $v= $data->{$f} or next;
-       $v =~ m/\S/o || next; # delete whitespace-only fields
-       $v =~ m/\n\S/o
-           && warning(_g("field %s has newline then non whitespace >%s<"),
-                         $f, $v);
-       $v =~ m/\n[ \t]*\n/o && warning(_g("field %s has blank lines >%s<"),
-                                          $f, $v);
-       $v =~ m/\n$/o && warning(_g("field %s has trailing newline >%s<"),
-                                   $f, $v);
-       $v =~ s/\$\{\}/\$/go;
-       $rfc822_str .= "$f: $v\n";
-    }
-
-    return $rfc822_str;
-}
-
-=pod
+    my ($data) = @_;
 
-=head3 data2rfc822_mult
+    if (ref($data) eq "ARRAY") {
+       my @rfc822 = ();
 
-The first argument should be an array ref to an array of hash references.
-The second argument is a hash reference and has the same meaning as
-the second argument of L<data2rfc822>.
-
-Calls L<data2rfc822> for each element of the array given as first
-argument and returns the concatenated results.
+       foreach my $entry (@$data) {
+           push @rfc822, data2rfc822($entry);
+       }
 
-=cut
+       return join "\n", @rfc822;
+    } else {
+       my $rfc822_str = "";
 
-sub data2rfc822_mult {
-    my ($data, $fieldimps) = @_;
-    my @rfc822 = ();
+       open my $fh, '>', \$rfc822_str
+           or warning("couldn't open filehandle for string");
+       $data->output($fh);
+       close $fh;
 
-    foreach my $entry (@$data) {
-       push @rfc822, data2rfc822($entry,$fieldimps);
+       return $rfc822_str;
     }
-
-    return join "\n", @rfc822;
 }
 
 =pod
@@ -688,7 +688,7 @@ in the output format of C<dpkg-parsechangelog>.
 =cut
 
 sub get_dpkg_changes {
-    my $changes = "\n ".($_[0]->Header||'')."\n .\n".($_[0]->Changes||'');
+    my $changes = "\n ".($_[0]->{Header}||'')."\n .\n".($_[0]->{Changes}||'');
     chomp $changes;
     $changes =~ s/^ $/ ./mgo;
     return $changes;
@@ -724,107 +724,16 @@ Dpkg::Changelog::Entry - represents one entry in a 
Debian changelog
 
 =head1 DESCRIPTION
 
-=head2 Methods
-
-=head3 init
-
-Creates a new object, no options.
-
-=head3 new
-
-Alias for init.
-
-=head3 is_empty
-
-Checks if the object is actually initialized with data. This
-currently simply checks if one of the fields Source, Version,
-Maintainer, Date, or Changes is initalized.
-
-=head2 Accessors
-
-The following fields are available via accessor functions (all
-fields are string values unless otherwise noted):
-
-=over 4
-
-=item *
-
-Source
-
-=item *
-
-Version
-
-=item *
-
-Distribution
-
-=item *
-
-Urgency
-
-=item *
-
-ExtraFields (all fields except for urgency as hash)
-
-=item *
-
-Header (the whole header in verbatim form)
-
-=item *
-
-Changes (the actual content of the bug report, in verbatim form)
-
-=item *
-
-Trailer (the whole trailer in verbatim form)
-
-=item *
-
-Closes (Array of bug numbers)
-
-=item *
-
-Maintainer (name B<and> email address)
-
-=item *
-
-Date
-
-=item *
-
-Timestamp (Date expressed in seconds since the epoche)
-
-=item *
-
-ERROR (last parse error related to this entry in the format described
-at Dpkg::Changelog::get_parse_errors.
-
-=back
-
 =cut
 
 package Dpkg::Changelog::Entry;
 
-use base qw( Class::Accessor );
-
-Dpkg::Changelog::Entry->mk_accessors(qw( Closes Changes Maintainer
-                                        MaintainerEmail Date
-                                        Urgency Distribution
-                                        Source Version ERROR
-                                        ExtraFields Header
-                                        Trailer Timestamp ));
-
 sub new {
-    return init(@_);
-}
+    my ($classname) = @_;
 
-sub init {
-    my $classname = shift;
-    my $self = {};
-    bless( $self, $classname );
-
-    return $self;
+    tie my %entry, 'Dpkg::Fields::Object';
+    my $entry = \%entry;
+    bless $entry, $classname;
 }
 
 sub is_empty {
@@ -837,6 +746,11 @@ sub is_empty {
             || $self->{Date});
 }
 
+sub output {
+    my $self = shift;
+    return tied(%$self)->output(@_);
+}
+
 1;
 __END__
 
diff --git a/scripts/Dpkg/Changelog/Debian.pm b/scripts/Dpkg/Changelog/Debian.pm
index ae2b310..6ff9567 100644
--- a/scripts/Dpkg/Changelog/Debian.pm
+++ b/scripts/Dpkg/Changelog/Debian.pm
@@ -119,7 +119,7 @@ sub parse {
 
 # based on /usr/lib/dpkg/parsechangelog/debian
     my $expect='first heading';
-    my $entry = Dpkg::Changelog::Entry->init();
+    my $entry = new Dpkg::Changelog::Entry;
     my $blanklines = 0;
     my $unknowncounter = 1; # to make version unique, e.g. for using as id
 
@@ -138,7 +138,7 @@ sub parse {
                $entry->{'Closes'} = find_closes( $entry->{Changes} );
 #                  print STDERR, Dumper($entry);
                push @{$self->{data}}, $entry;
-               $entry = Dpkg::Changelog::Entry->init();
+               $entry = new Dpkg::Changelog::Entry;
                last if $self->_abort_early;
            }
            {
@@ -146,8 +146,8 @@ sub parse {
                $entry->{'Version'} = "$2";
                $entry->{'Header'} = "$_";
                ($entry->{'Distribution'} = "$3") =~ s/^\s+//;
-               $entry->{'Changes'} = $entry->{'Urgency_Comment'} = '';
-               $entry->{'Urgency'} = $entry->{'Urgency_LC'} = 'unknown';
+               $entry->{'Changes'} = $entry->{'Urgency_comment'} = '';
+               $entry->{'Urgency'} = $entry->{'Urgency_lc'} = 'unknown';
            }
            (my $rhs = $POSTMATCH) =~ s/^\s+//;
            my %kvdone;
@@ -166,8 +166,8 @@ sub parse {
                                              _g("badly formatted urgency 
value"),
                                              $v);
                    $entry->{'Urgency'} = "$1";
-                   $entry->{'Urgency_LC'} = lc("$1");
-                   $entry->{'Urgency_Comment'} = "$2";
+                   $entry->{'Urgency_lc'} = lc("$1");
+                   $entry->{'Urgency_comment'} = "$2";
                } elsif ($k =~ m/^X[BCS]+-/i) {
                    # Extensions - XB for putting in Binary,
                    # XC for putting in Control, XS for putting in Source
diff --git a/scripts/t/600_Dpkg_Changelog.t b/scripts/t/600_Dpkg_Changelog.t
index d2c7cff..a9b8f32 100644
--- a/scripts/t/600_Dpkg_Changelog.t
+++ b/scripts/t/600_Dpkg_Changelog.t
@@ -56,7 +56,7 @@ foreach my $file ("$srcdir/countme", "$srcdir/shadow") {
 
        # test range options
        cmp_ok( @data, '==', 7, "no options -> count" );
-       my $all_versions = join( '/', map { $_->Version } @data);
+       my $all_versions = join( '/', map { $_->{Version} } @data);
 
        sub check_options {
            my ($changes, $data, $options, $count, $versions,
@@ -68,7 +68,7 @@ foreach my $file ("$srcdir/countme", "$srcdir/shadow") {
                is_deeply( [EMAIL PROTECTED], $data, "$check_name -> returns 
all" );
 
            } else {
-               is( join( "/", map { $_->Version } @cnt),
+               is( join( "/", map { $_->{Version} } @cnt),
                    $versions, "$check_name -> versions" );
            }
        }
@@ -165,7 +165,7 @@ foreach my $file ("$srcdir/countme", "$srcdir/shadow") {
 #              'version numbers in module and Changes match' );
 #     }
 
-    my $oldest_version = $data[-1]->Version;
+    my $oldest_version = $data[-1]->{Version};
     $str = $changes->dpkg_str({ since => $oldest_version });
 
 #    is( $str, `dpkg-parsechangelog -v$oldest_version -l$file`,
@@ -185,7 +185,7 @@ open CHANGES, '<', "$srcdir/countme";
 my $string = join('',<CHANGES>);
 
 my $str_changes = Dpkg::Changelog::Debian->init( { instring => $string,
-                                                quiet => 1 } );
+                                                  quiet => 1 } );
 my $errors = $str_changes->get_parse_errors();
 ok( !$errors,
     "Parse example changelog $srcdir/countme without errors from string" );

commit 5ab947df77388732f7a7b30cd07e8065c1a71c34
Author: Frank Lichtenheld <[EMAIL PROTECTED]>
Date:   Sun Jan 13 13:25:16 2008 +0100

    dpkg-parsechangelog(1): Document the new parser options

diff --git a/man/ChangeLog b/man/ChangeLog
index 92cfa0b..9e29219 100644
--- a/man/ChangeLog
+++ b/man/ChangeLog
@@ -1,3 +1,8 @@
+2008-01-13  Frank Lichtenheld  <[EMAIL PROTECTED]>
+
+       * dpkg-parsechangelog.1: Document the new
+       command line options.
+
 2008-01-12  Raphael Hertzog  <[EMAIL PROTECTED]>
 
        * dpkg-shlibdeps.1: Fix a typo reported by Helge Kreutzmann.
diff --git a/man/dpkg-parsechangelog.1 b/man/dpkg-parsechangelog.1
index 0367dcc..ab5cb6e 100644
--- a/man/dpkg-parsechangelog.1
+++ b/man/dpkg-parsechangelog.1
@@ -1,4 +1,4 @@
-.TH dpkg\-parsechangelog 1 "2007-03-07" "Debian Project" "dpkg utilities"
+.TH dpkg\-parsechangelog 1 "2008-01-13" "Debian Project" "dpkg utilities"
 .SH NAME
 dpkg\-parsechangelog \- parse Debian changelog files
 .
@@ -25,17 +25,91 @@ from a special line near the bottom of the changelog or 
failing that
 defaults to the debian standard format.
 .TP
 .BI \-L libdir
-FIXME not used in the source!?
-.TP
-.BI \-v version
-Use changelog information from all versions strictly later than
-.IR version .
+Specify an additional directory to search for parser scripts.
+This directory is searched before the default directories
+which are currently
+.BR /usr/local/lib/dpkg/parsechangelog " and "
+.BR /usr/lib/dpkg/parsechangelog .
 .TP
 .BR \-h ", " \-\-help
 Show the usage message and exit.
 .TP
 .BR \-\-version
 Show the version and exit.
+.SS Parser Options
+The following options can be used to influence the output of
+the changelog parser, e.g. the range of entries or the format
+of the output. They need to supported by the parser script
+in question. See also \fBCAVEATS\fP.
+.TP
+.BI \-\-format " outputformat"
+Set the output format. Currently supported values are
+.IR dpkg " and " rfc822 .
+\fIdpkg\fP is the classic output format (from before this
+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, most fields are taken from the
+latest entry, except otherwise stated:
+.RS
+.TP
+.BR Source: " <pkg name>"
+.TP
+.BR Version: " <version>"
+.TP
+.BR Distribution: " <target distribution>"
+.TP
+.BR Urgency: " <urgency>"
+The highest urgency of all included entries is used.
+.TP
+.BR Maintainer: " <author>"
+.TP
+.BR Date: " <date>"
+.TP
+.BR Closes: " <bug number>"
+The Closes fields of all included entries are merged.
+.TP
+.BR Changes: " <changelog entries>"
+The text of all changelog entries is concatenated. To make
+this field a valid Debian control format multiline field
+empty lines are replaced with a single full stop and all lines
+is intended by one space character. The exact content depends
+on the changelog format.
+.RE
+.IP
+There might be additional user-defined fields present.
+.IP
+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
+.BR \-\-since ", " \-s ", " \-v " \fIversion\fP"
+include all changes later than \fIversion\fP.
+.TP
+.BR \-\-until ", " \-u " \fIversion\fP"
+include all changes earlier than \fIversion\fP.
+.TP
+.BR \-\-from ", " \-f " \fIversion\fP"
+include all changes equal or later than \fIversion\fP.
+.TP
+.BR \-\-to ", " \-t " \fIversion\fP"
+include all changes up to or equal than \fIversion\fP.
+.TP
+.BR \-\-count ", " \-c ", " \-n " \fInumber\fI"
+include \fInumber\fP entries from the top (or the tail
+if \fInumber\fP is lower than 0).
+.TP
+.BR \-\-offset ", " \-o " \fInumber\fP"
+change the starting point for \-\-count, counted from the top
+(or the tail if \fInumber\fP is lower than 0).
+.TP
+.B \-\-all
+include all changes.
+.
+.SH CAVEATS
+All \fBParser Options\fP except for \-v are only supported in
+\fBdpkg\fP, version 1.14.16 and later. Third party parsers for
+changelog formats other than \fIdebian\fP might not support
+all options.
 .
 .SH FILES
 .TP
@@ -49,6 +123,8 @@ number itself.
 Copyright (C) 1995-1996 Ian Jackson
 .br
 Copyright (C) 2000 Wichert Akkerman
+.br
+Copyright (C) 2007, 2008 Frank Lichtenheld
 .sp
 This is free software; see the GNU General Public Licence version 2 or later
 for copying conditions. There is NO WARRANTY.

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to