← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/no-duplicate-copies-mail into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/no-duplicate-copies-mail into lp:launchpad.

Commit message:
Don't generate notifications for no-op copies.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/no-duplicate-copies-mail/+merge/273454

Today I uploaded a package to wily-proposed, and then got something like nine notifications of the copy to wily because proposed-migration ran several times (presumably for other reasons) between the initial copy to wily and that copy actually being published, and thus repeated the copy several times.  I should only have received a notification from the first one; a copy job that doesn't actually copy anything should not generate mail notifications either.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/no-duplicate-copies-mail into lp:launchpad.
=== modified file 'lib/lp/soyuz/scripts/packagecopier.py'
--- lib/lp/soyuz/scripts/packagecopier.py	2015-08-26 13:41:21 +0000
+++ lib/lp/soyuz/scripts/packagecopier.py	2015-10-05 18:54:27 +0000
@@ -611,7 +611,7 @@
             close_bugs_since_version=old_version, creator=creator,
             sponsor=sponsor, packageupload=packageupload,
             phased_update_percentage=phased_update_percentage, logger=logger)
-        if send_email:
+        if send_email and sub_copies:
             mailer = PackageUploadMailer.forAction(
                 'accepted', person, source.sourcepackagerelease, [], [],
                 archive, destination_series, pocket,

=== modified file 'lib/lp/soyuz/scripts/tests/test_copypackage.py'
--- lib/lp/soyuz/scripts/tests/test_copypackage.py	2015-09-23 11:52:26 +0000
+++ lib/lp/soyuz/scripts/tests/test_copypackage.py	2015-10-05 18:54:27 +0000
@@ -1590,6 +1590,23 @@
             send_email=False)
         self.assertEqual([], pop_notifications())
 
+    def test_duplicate_copy_does_not_generate_notification(self):
+        # If there is nothing to copy because the packages in question are
+        # already in the destination, then no notification is generated.
+        nobby, archive, source = self._setup_archive()
+        target_archive = self.factory.makeArchive(
+            distribution=self.test_publisher.ubuntutest)
+        self.assertNotEqual([], do_copy(
+            [source], target_archive, nobby, source.pocket, False,
+            person=target_archive.owner, check_permissions=False,
+            send_email=True))
+        self.assertNotEqual([], pop_notifications())
+        self.assertEqual([], do_copy(
+            [source], target_archive, nobby, source.pocket, False,
+            person=target_archive.owner, check_permissions=False,
+            send_email=True))
+        self.assertEqual([], pop_notifications())
+
     def test_copying_unsupported_arch_with_override(self):
         # When the copier is passed an unsupported arch with an override
         # on the destination series, no binary is copied. But an


Follow ups