Merge lp:~wgrant/launchpad/reject-not-accepted into lp:launchpad

Proposed by William Grant
Status: Merged
Merged at revision: 17882
Proposed branch: lp:~wgrant/launchpad/reject-not-accepted
Merge into: lp:launchpad
Diff against target: 60 lines (+3/-20)
2 files modified
lib/lp/archiveuploader/nascentupload.py (+2/-9)
lib/lp/archiveuploader/tests/nascentupload.txt (+1/-11)
To merge this branch: bzr merge lp:~wgrant/launchpad/reject-not-accepted
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+281435@code.launchpad.net

Commit message

Fix NascentUpload.do_reject to not send an erroneous Accepted email.

Description of the change

Fix NascentUpload.do_reject to not send an erroneous Accepted email.

It would previously do so if the upload made it to Done before an exception occurred (eg. because build creation failed).

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) wrote :

This seems to change do_reject to only send the mail, and not actually change the status (PU.notify doesn't do that). That seems odd. Can you explain what's going on there?

review: Needs Information
Revision history for this message
William Grant (wgrant) wrote :

On 05/01/16 01:57, Colin Watson wrote:
> Review: Needs Information
>
> This seems to change do_reject to only send the mail, and not
> actually change the status (PU.notify doesn't do that). That seems
> odd. Can you explain what's going on there?

The transaction is about to be aborted, so the only side-effect that can
depend on the status is the email. Since we can't reliably set the
status, I opted to be consistent and rely solely on the override.

Revision history for this message
Colin Watson (cjwatson) wrote :

OK, I hadn't traced things through to confirm that do_reject is always followed by an abort (and was put off by the original nascentupload.txt test that you removed; I now realise that it goes through a path that doesn't involve the abort). Now that I have, I agree with you.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/archiveuploader/nascentupload.py'
--- lib/lp/archiveuploader/nascentupload.py 2014-08-13 07:47:43 +0000
+++ lib/lp/archiveuploader/nascentupload.py 2015-12-30 23:59:31 +0000
@@ -50,6 +50,7 @@
50 FromExistingOverridePolicy,50 FromExistingOverridePolicy,
51 SourceOverride,51 SourceOverride,
52 )52 )
53from lp.soyuz.enums import PackageUploadStatus
53from lp.soyuz.interfaces.binarypackagename import IBinaryPackageNameSet54from lp.soyuz.interfaces.binarypackagename import IBinaryPackageNameSet
54from lp.soyuz.interfaces.component import IComponentSet55from lp.soyuz.interfaces.component import IComponentSet
55from lp.soyuz.interfaces.queue import QueueInconsistentStateError56from lp.soyuz.interfaces.queue import QueueInconsistentStateError
@@ -755,17 +756,9 @@
755 if not self.queue_root:756 if not self.queue_root:
756 self.queue_root = self._createQueueEntry()757 self.queue_root = self._createQueueEntry()
757758
758 # Avoid cyclic imports.
759 from lp.soyuz.interfaces.queue import QueueInconsistentStateError
760 try:
761 self.queue_root.setRejected()
762 except QueueInconsistentStateError:
763 # These exceptions are ignored, we want to force the rejected
764 # state.
765 pass
766
767 with open(self.changes.filepath, "r") as changes_file_object:759 with open(self.changes.filepath, "r") as changes_file_object:
768 self.queue_root.notify(760 self.queue_root.notify(
761 status=PackageUploadStatus.REJECTED,
769 summary_text=self.rejection_message,762 summary_text=self.rejection_message,
770 changes_file_object=changes_file_object, logger=self.logger)763 changes_file_object=changes_file_object, logger=self.logger)
771764
772765
=== modified file 'lib/lp/archiveuploader/tests/nascentupload.txt'
--- lib/lp/archiveuploader/tests/nascentupload.txt 2015-04-21 10:03:15 +0000
+++ lib/lp/archiveuploader/tests/nascentupload.txt 2015-12-30 23:59:31 +0000
@@ -489,17 +489,6 @@
489 cannot upload the same version within the same distribution. You489 cannot upload the same version within the same distribution. You
490 have to modify the source version and re-upload.490 have to modify the source version and re-upload.
491491
492We rely on process-upload transaction rollback to not store bogus
493queue entry in the database.
494
495 >>> print ed_src_dup.queue_root.status.name
496 REJECTED
497
498 >>> from lp.soyuz.enums import PackageUploadStatus
499 >>> hoary.getPackageUploads(
500 ... status=PackageUploadStatus.REJECTED, name=u"ed").count()
501 1
502
503492
504Staged Source and Binary upload with multiple binaries493Staged Source and Binary upload with multiple binaries
505......................................................494......................................................
@@ -717,6 +706,7 @@
717content, it should have all the required fields except the706content, it should have all the required fields except the
718'dsc_standards_version':707'dsc_standards_version':
719708
709 >>> from lp.soyuz.enums import PackageUploadStatus
720 >>> inst_queue = hoary.getPackageUploads(710 >>> inst_queue = hoary.getPackageUploads(
721 ... PackageUploadStatus.NEW, name=u'test75874', exact_match=True)[0]711 ... PackageUploadStatus.NEW, name=u'test75874', exact_match=True)[0]
722 >>> inst_spr = inst_queue.sources[0].sourcepackagerelease712 >>> inst_spr = inst_queue.sources[0].sourcepackagerelease