Преглед изворни кода

Dpkg::Changelog: fix heuristic to identify correct start entry

The heuristic to identify the version number that is most approaching
was not working properly for the case where the version number was smaller
than the oldest version (for example "0"). Add a non-regression test for
this case.

Also add supplementary warnings message so that people notice when
the parameters are discarded.
Raphael Hertzog пре 17 година
родитељ
комит
3fe3521d24
3 измењених фајлова са 21 додато и 3 уклоњено
  1. 2 0
      debian/changelog
  2. 13 2
      scripts/Dpkg/Changelog.pm
  3. 6 1
      scripts/t/600_Dpkg_Changelog.t

+ 2 - 0
debian/changelog

@@ -37,6 +37,8 @@ dpkg (1.15.4) UNRELEASED; urgency=low
   * Upgrade Standards-Version to 3.8.2 (no changes).
   * Update deb-substvars(5) to list fields that do not support substvars.
     Closes: #535353
+  * Fix dpkg-parsechangelog to include all entries with -v0 parameter.
+    Closes: #537800
 
   [ Modestas Vainius ]
   * Provide a meaningful label for dpkg-gensymbols diff.

+ 13 - 2
scripts/Dpkg/Changelog.pm

@@ -262,7 +262,12 @@ sub __sanity_check_range {
                 last;
             }
         }
-        $$since = '' if not exists $versions{$$since}; # No version was smaller
+        if (not exists $versions{$$since}) {
+            # No version was smaller, include all
+            warning(_g("none found, starting from the oldest entry"));
+            $$since = '';
+            $$from = $versions[-1];
+        }
     }
     if ((length($$from) and not exists $versions{$$from})) {
         warning(_g("'%s' option specifies non-existing version"), "from");
@@ -276,6 +281,7 @@ sub __sanity_check_range {
         if (defined($oldest)) {
             $$from = $oldest;
         } else {
+            warning(_g("no such entry found, ignoring '%s' parameter"), "from");
             $$from = ''; # No version was bigger
         }
     }
@@ -291,6 +297,7 @@ sub __sanity_check_range {
         if (defined($oldest)) {
             $$until = $oldest;
         } else {
+            warning(_g("no such entry found, ignoring '%s' parameter"), "until");
             $$until = ''; # No version was bigger
         }
     }
@@ -303,7 +310,11 @@ sub __sanity_check_range {
                 last;
             }
         }
-        $$to = '' if not exists $versions{$$to}; # No version was smaller
+        if (not exists $versions{$$to}) {
+            # No version was smaller
+            warning(_g("no such entry found, ignoring '%s' parameter"), "to");
+            $$to = '';
+        }
     }
 
     if (length($$since) && ($data->[0]{Version} eq $$since)) {

+ 6 - 1
scripts/t/600_Dpkg_Changelog.t

@@ -10,7 +10,7 @@ BEGIN {
     my $no_err_examples = 1;
     my $no_tests = $no_examples * 4
 	+ $no_err_examples * 2
-	+ 24 # countme
+	+ 26 # countme
 	+  2 # fields
 	+ 24;
 
@@ -150,6 +150,11 @@ foreach my $file ("$srcdir/countme", "$srcdir/shadow", "$srcdir/fields",
 		       { since => '1:2.0~rc2-1sarge3' }, 3,
 		       '2:2.0-1/1:2.0~rc2-3/1:2.0~rc2-2',
 		       'since => "1:2.0~rc2-1sarge3"' );
+        $SIG{'__WARN__'} = sub {};
+        check_options( $changes, \@data,
+                       { since => 0 }, 7, '',
+                       'since => 0 returns all');
+        delete $SIG{'__WARN__'};
 	check_options( $changes, \@data,
 		       { to => '1:2.0~rc2-1sarge2' }, 3,
 		       '1:2.0~rc2-1sarge2/1:2.0~rc2-1sarge1/1.5-1',