[python-debian/master] changelog: fix the "topline" regular expression to match the one in dpkg

John Wright jsw at debian.org
Wed Oct 15 21:18:21 UTC 2008


dpkg-parsechangelog allows '.' and '+' in the distributions field as of
version 1.13.20 (see #361171).  Support for this was added to the
changelog module in c157dd01285aff8a21fc948cf18410a071b624ec but
regressed in 8ae493bff470f532802bb1c2a2adb79e1270e613.  I changed the
"topline" regular expression to match exactly the one in dpkg's
Dpkg/Changelog/Debian.pm.
---
 debian/changelog                |    5 ++++-
 debian_bundle/changelog.py      |   12 ++++++++++--
 tests/test_changelog_full_stops |    5 +++++
 3 files changed, 19 insertions(+), 3 deletions(-)
 create mode 100644 tests/test_changelog_full_stops

diff --git a/debian/changelog b/debian/changelog
index b913f5f..7c656b5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -13,8 +13,11 @@ python-debian (0.1.12) UNRELEASED; urgency=low
 
   [ John Wright ]
   * deb822: allow the use of unicode objects in __getitem__
+  * changelog: fix the "topline" regular expression to match the one in dpkg's
+    Dpkg/Changelog/Debian.pm so that it allows '.' and '+' in the distribution
+    field
 
- -- John Wright <jsw at debian.org>  Mon, 15 Sep 2008 17:40:44 -0600
+ -- John Wright <jsw at debian.org>  Wed, 15 Oct 2008 15:09:31 -0600
 
 python-debian (0.1.11) unstable; urgency=low
 
diff --git a/debian_bundle/changelog.py b/debian_bundle/changelog.py
index ee6be2a..e4cf450 100644
--- a/debian_bundle/changelog.py
+++ b/debian_bundle/changelog.py
@@ -213,8 +213,10 @@ class ChangeBlock(object):
             block += line + "\n"
         return block
 
-topline = re.compile('^(\w[-a-z0-9.+]+) \(([^\(\) \t]+)\)((\s+[-0-9a-z]+)+);',
-        re.IGNORECASE)
+topline = re.compile(r'^(\w%(name_chars)s*) \(([^\(\) \t]+)\)'
+                     '((\s+%(name_chars)s+)+)\;'
+                     % {'name_chars': '[-+0-9a-z.]'},
+                     re.IGNORECASE)
 blankline = re.compile('^\s*$')
 change = re.compile('^\s\s+.*$')
 endline = re.compile('^ -- (.*) <(.*)>(  ?)((\w+\,\s*)?\d{1,2}\s+\w+\s+'
@@ -632,6 +634,12 @@ class ChangelogTests(unittest.TestCase):
         self.assertEqual(c.epoch, '1')
         self.assertEqual(str(c.version), c.full_version)
 
+    def test_allow_full_stops_in_distribution(self):
+        c = Changelog(open('test_changelog_full_stops'))
+        self.assertEqual(c.debian_version, None)
+        self.assertEqual(c.full_version, '1.2.3')
+        self.assertEqual(str(c.version), c.full_version)
+
 class VersionTests(unittest.TestCase):
 
     def _test_version(self, full_version, epoch, upstream, debian):
diff --git a/tests/test_changelog_full_stops b/tests/test_changelog_full_stops
new file mode 100644
index 0000000..41dc893
--- /dev/null
+++ b/tests/test_changelog_full_stops
@@ -0,0 +1,5 @@
+foo (1.2.3) hpde-3.0.x; urgency=low
+
+  * Initial release.
+
+ -- John Wright <john.wright at hp.com>  Wed, 15 Oct 2008 15:06:05 -0600
-- 
1.5.5.GIT




More information about the pkg-python-debian-commits mailing list