[Pkg-bazaar-commits] ./bzr-builddeb/trunk.old r274: Strip the changelog message as "debcommit" does. Thanks Colin. (#265045)

James Westby jw+debian at jameswestby.net
Wed Dec 10 08:33:05 UTC 2008


------------------------------------------------------------
revno: 274
committer: James Westby <jw+debian at jameswestby.net>
branch nick: trunk
timestamp: Tue 2008-09-09 21:24:37 +0100
message:
  Strip the changelog message as "debcommit" does. Thanks Colin. (#265045)
modified:
  import_dsc.py
  util.py
    ------------------------------------------------------------
    revno: 273.1.1
    committer: Colin Watson <cjwatson at canonical.com>
    branch nick: strip-message
    timestamp: Fri 2008-09-05 13:33:02 +0100
    message:
      Strip imported changelog entries in the same way as debcommit.
    modified:
      import_dsc.py
      util.py
-------------- next part --------------
=== modified file 'import_dsc.py'
--- a/import_dsc.py	2008-08-27 21:06:59 +0000
+++ b/import_dsc.py	2008-09-05 12:33:02 +0000
@@ -73,6 +73,7 @@
 from bzrlib.plugins.builddeb.merge_upstream import (make_upstream_tag,
                 upstream_tag_to_version,
                 )
+from bzrlib.plugins.builddeb.util import strip_changelog_message
 
 
 files_to_ignore = set(['.cvsignore', '.arch-inventory', '.bzrignore',
@@ -599,7 +600,7 @@
         changelog = Changelog(file=changelog_contents, max_blocks=1)
         if changelog._blocks:
           author = changelog._blocks[0].author
-          changes = changelog._blocks[0].changes()
+          changes = strip_changelog_message(changelog._blocks[0].changes())
           message = ''
           sep = ''
           for change in reversed(changes):
@@ -1546,7 +1547,7 @@
           changelog = Changelog(file=changelog_contents, max_blocks=1)
           if changelog._blocks:
             author = changelog._blocks[0].author
-            changes = changelog._blocks[0].changes()
+            changes = strip_changelog_message(changelog._blocks[0].changes())
             message = ''
             sep = ''
             for change in reversed(changes):

=== modified file 'util.py'
--- a/util.py	2008-08-27 12:13:34 +0000
+++ b/util.py	2008-09-05 12:33:02 +0000
@@ -78,6 +78,22 @@
     changelog.parse_changelog(contents, max_blocks=1, allow_empty_author=True)
     return changelog, larstiq
 
+def strip_changelog_message(changes):
+  while changes[-1] == '':
+    changes.pop()
+  while changes[0] == '':
+    changes.pop(0)
+
+  whitespace_column_re = re.compile(r'  |\t')
+  changes = map(lambda line: whitespace_column_re.sub('', line, 1), changes)
+
+  leader_re = re.compile(r'[ \t]*[*+-] ')
+  count = len(filter(leader_re.match, changes))
+  if count == 1:
+    return map(lambda line: leader_re.sub('', line, 1).lstrip(), changes)
+  else:
+    return changes
+
 def tarball_name(package, version):
   """Return the name of the .orig.tar.gz for the given package and version."""
 



More information about the Pkg-bazaar-commits mailing list