← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/queue-no-changes into lp:launchpad

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/queue-no-changes into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/queue-no-changes/+merge/67913

Support rejecting PackageUploads that have no changes file associated with them.
-- 
https://code.launchpad.net/~stevenk/launchpad/queue-no-changes/+merge/67913
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/queue-no-changes into lp:launchpad.
=== modified file 'lib/lp/soyuz/adapters/notification.py'
--- lib/lp/soyuz/adapters/notification.py	2011-06-14 20:45:03 +0000
+++ lib/lp/soyuz/adapters/notification.py	2011-07-14 02:09:34 +0000
@@ -160,6 +160,8 @@
     if spr is None and not bprs and not customfiles:
         # We do not have enough context to do a normal notification, so
         # reject what we do have.
+        if not changesfile_object:
+            return
         reject_changes_file(
             blamer, changesfile_object.name, changes, archive, distroseries,
             summary_text, logger=logger)

=== modified file 'lib/lp/soyuz/model/queue.py'
--- lib/lp/soyuz/model/queue.py	2011-07-07 10:31:38 +0000
+++ lib/lp/soyuz/model/queue.py	2011-07-14 02:09:34 +0000
@@ -562,7 +562,10 @@
             # don't think we need them for sync rejections.
             return
 
-        changes_file_object = StringIO.StringIO(self.changesfile.read())
+        if self.changesfile:
+            changes_file_object = StringIO.StringIO(self.changesfile.read())
+        else:
+            changes_file_object = None
         # We allow unsigned uploads since they come from the librarian,
         # which are now stored unsigned.
         self.notify(
@@ -849,10 +852,13 @@
             PackageUploadStatus.ACCEPTED: 'accepted',
             PackageUploadStatus.DONE: 'accepted',
             }
-        changes, changes_lines = self._getChangesDict(changes_file_object)
         if changes_file_object is not None:
+            changes, changes_lines = self._getChangesDict(
+                changes_file_object)
             changesfile_content = changes_file_object.read()
         else:
+            changes = {}
+            changes_lines = ''
             changesfile_content = 'No changes file content available.'
         if self.signing_key is not None:
             signer = self.signing_key.owner

=== modified file 'lib/lp/soyuz/tests/test_packageupload.py'
--- lib/lp/soyuz/tests/test_packageupload.py	2011-07-11 08:31:46 +0000
+++ lib/lp/soyuz/tests/test_packageupload.py	2011-07-14 02:09:34 +0000
@@ -838,3 +838,10 @@
         self.assertEqual(
             list(reversed(ordered_uploads)),
             list(getUtility(IPackageUploadSet).getAll(series)))
+
+    def test_rejectFromQueue_no_changes_file(self):
+        # If the PackageUpload has no changesfile, we can still reject it.
+        pu = self.factory.makePackageUpload()
+        pu.changesfile = None
+        pu.rejectFromQueue()
+        self.assertEqual(PackageUploadStatus.REJECTED, pu.status)