← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/bug-740584 into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/bug-740584 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #740584 in Launchpad itself: "Build lacks a corresponding source publication"
  https://bugs.launchpad.net/launchpad/+bug/740584

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/bug-740584/+merge/61060

BinaryPackageBuild.current_component expects each build to have a corresponding source publication in its archive and series. But some ancient production data (mostly created by gina) does not satisfy this invariant, so we must relax it.

This branch changes it to return None if no component was found, as it did up until a few months ago. The only code that sees these builds is the UI, and it copes with a None component.
-- 
https://code.launchpad.net/~wgrant/launchpad/bug-740584/+merge/61060
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/bug-740584 into lp:launchpad.
=== modified file 'lib/lp/soyuz/model/binarypackagebuild.py'
--- lib/lp/soyuz/model/binarypackagebuild.py	2011-05-04 04:10:58 +0000
+++ lib/lp/soyuz/model/binarypackagebuild.py	2011-05-16 04:03:31 +0000
@@ -146,9 +146,11 @@
     def current_component(self):
         """See `IBuild`."""
         latest_publication = self._getLatestPublication()
-        assert latest_publication is not None, (
-            'Build %d lacks a corresponding source publication.' % self.id)
-        return latest_publication.component
+        # Production has some buggy builds without source publications.
+        # They seem to have been created by early versions of gina and
+        # the readding of hppa.
+        if latest_publication is not None:
+            return latest_publication.component
 
     @property
     def current_source_publication(self):

=== modified file 'lib/lp/soyuz/tests/test_build.py'
--- lib/lp/soyuz/tests/test_build.py	2011-05-03 02:39:30 +0000
+++ lib/lp/soyuz/tests/test_build.py	2011-05-16 04:03:31 +0000
@@ -154,6 +154,15 @@
         # If the package has no uploads, its package_upload is None
         self.assertEquals(None, build.package_upload)
 
+    def test_current_component_when_unpublished(self):
+        # Production has some buggy builds without source publications.
+        # current_component returns None in that case.
+        spph = self.publisher.getPubSource()
+        other_das = self.factory.makeDistroArchSeries()
+        build = spph.sourcepackagerelease.createBuild(
+            other_das, PackagePublishingPocket.RELEASE, spph.archive)
+        self.assertIs(None, build.current_component)
+
     def test_retry_for_released_series(self):
         # Builds can not be retried for released distroseries
         distroseries = self.factory.makeDistroSeries()