← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~pcjc2/launchpad/allow-empty-comments into lp:launchpad

 

Peter Clifton has proposed merging lp:~pcjc2/launchpad/allow-empty-comments into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)


Adds an option "--allow-empty-comments" to scripts/bug-import.py

This option allows the import of XML files which specify blank comments, without the
insersion of a "<empty comment>" placeholder.

This is especially useful for comments added purely to attach a file to the bug report. Without this change, it is not possible for the import to give the same clean, uncluttered blank comments can get when adding files directly from within the launchpad web-interface.
-- 
https://code.launchpad.net/~pcjc2/launchpad/allow-empty-comments/+merge/43449
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~pcjc2/launchpad/allow-empty-comments into lp:launchpad.
=== modified file 'lib/lp/bugs/scripts/bugimport.py'
--- lib/lp/bugs/scripts/bugimport.py	2010-08-20 20:31:18 +0000
+++ lib/lp/bugs/scripts/bugimport.py	2010-12-11 23:37:57 +0000
@@ -117,13 +117,14 @@
     """Import bugs into Launchpad"""
 
     def __init__(self, product, bugs_filename, cache_filename,
-                 verify_users=False, logger=None):
+                 verify_users=False, logger=None, allow_empty_comments=False):
         self.product = product
         self.bugs_filename = bugs_filename
         self.cache_filename = cache_filename
         self.verify_users = verify_users
         self.person_id_cache = {}
         self.bug_importer = getUtility(ILaunchpadCelebrities).bug_importer
+        self.allow_empty_comments = allow_empty_comments;
 
         if logger is None:
             self.logger = DEFAULT_LOGGER
@@ -408,8 +409,9 @@
         if date is None:
             raise BugXMLSyntaxError('No date for comment %r' % title)
         text = get_value(commentnode, 'text')
-        if text is None or text == '':
-            text = '<empty comment>'
+        if not self.allow_empty_comments:
+            if text is None or text == '':
+                text = '<empty comment>'
         return getUtility(IMessageSet).fromText(title, text, sender, date)
 
     def createAttachments(self, bug, message, commentnode):

=== modified file 'scripts/bug-import.py'
--- scripts/bug-import.py	2010-11-08 12:52:43 +0000
+++ scripts/bug-import.py	2010-12-11 23:37:57 +0000
@@ -37,6 +37,10 @@
         self.parser.add_option('--dont-verify-users', dest='verify_users',
                                help="Don't verify newly created users",
                                action='store_false', default=True)
+        self.parser.add_option('--allow-empty-comments',
+                               dest='allow_empty_comments',
+                               help="Allow empty bug comments",
+                               action='store_true', default=False)
 
     def main(self):
         if self.options.product is None:
@@ -60,7 +64,8 @@
 
         importer = BugImporter(
             product, bugs_filename, self.options.cache_filename,
-            verify_users=self.options.verify_users, logger=self.logger)
+            verify_users=self.options.verify_users, logger=self.logger,
+            allow_empty_comments=self.options.allow_empty_comments)
         importer.importBugs(self.txn)
         config.pop('send_email_data')