launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #18246
[Merge] lp:~cjwatson/launchpad/bpph-source into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/bpph-source into lp:launchpad.
Commit message:
Add and export BinaryPackagePublishingHistory.getPublishedSource.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #597041 in Launchpad itself: "No way to get from binary package to source package"
https://bugs.launchpad.net/launchpad/+bug/597041
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/bpph-source/+merge/255070
Add and export BinaryPackagePublishingHistory.getPublishedSource. This provides a simple way to get from a BPPH to an SPPH on the webservice, which was previously more or less impossible to do accurately unless you already had the SPPH in hand, and certainly inefficient. At the moment I need this for new-style ddeb publication, where we want to walk through Archive.getPublishedBinaries() results and need to know the source package name so that we can publish them to the right directory.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/bpph-source into lp:launchpad.
=== modified file 'lib/lp/_schema_circular_imports.py'
--- lib/lp/_schema_circular_imports.py 2015-01-30 18:24:07 +0000
+++ lib/lp/_schema_circular_imports.py 2015-04-02 11:37:11 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2014 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2015 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Update the interface schema values due to circular imports.
@@ -208,6 +208,7 @@
from lp.soyuz.interfaces.publishing import (
IBinaryPackagePublishingHistory,
IBinaryPackagePublishingHistoryEdit,
+ IBinaryPackagePublishingHistoryPublic,
ISourcePackagePublishingHistory,
ISourcePackagePublishingHistoryEdit,
ISourcePackagePublishingHistoryPublic,
@@ -359,6 +360,9 @@
patch_collection_return_type(
ISourcePackagePublishingHistoryPublic, 'getPublishedBinaries',
IBinaryPackagePublishingHistory)
+patch_entry_return_type(
+ IBinaryPackagePublishingHistoryPublic, 'getPublishedSource',
+ ISourcePackagePublishingHistory)
patch_reference_property(
IBinaryPackagePublishingHistory, 'distroarchseries',
IDistroArchSeries)
=== modified file 'lib/lp/soyuz/interfaces/publishing.py'
--- lib/lp/soyuz/interfaces/publishing.py 2014-11-09 09:01:26 +0000
+++ lib/lp/soyuz/interfaces/publishing.py 2015-04-02 11:37:11 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2014 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2015 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Publishing interfaces."""
@@ -867,6 +867,19 @@
:return: A collection of URLs for this binary.
"""
+ # Really ISourcePackagePublishingHistory, patched in
+ # _schema_circular_imports.py.
+ @operation_returns_entry(Interface)
+ @export_read_operation()
+ @operation_for_version("devel")
+ def getPublishedSource():
+ """The latest source publication corresponding to this binary.
+
+ :return: An `ISourcePackagePublishingHistory`, or None if no
+ corresponding source publication can be located (which is a bug,
+ but is true for some old production builds).
+ """
+
class IBinaryPackagePublishingHistoryEdit(IPublishingEdit):
"""A writeable binary package publishing record."""
=== modified file 'lib/lp/soyuz/model/publishing.py'
--- lib/lp/soyuz/model/publishing.py 2014-11-09 09:01:26 +0000
+++ lib/lp/soyuz/model/publishing.py 2015-04-02 11:37:11 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2014 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2015 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
__metaclass__ = type
@@ -1065,6 +1065,10 @@
for url, (size, sha1) in zip(binary_urls, meta)]
return binary_urls
+ def getPublishedSource(self):
+ """See `IBinaryPackagePublishingHistory`."""
+ return self.binarypackagerelease.build._getLatestPublication()
+
def expand_binary_requests(distroseries, binaries):
"""Architecture-expand a dict of binary publication requests.
=== modified file 'lib/lp/soyuz/tests/test_publishing_models.py'
--- lib/lp/soyuz/tests/test_publishing_models.py 2013-05-30 00:53:13 +0000
+++ lib/lp/soyuz/tests/test_publishing_models.py 2015-04-02 11:37:11 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2015 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Test model and set utilities used for publishing."""
@@ -221,3 +221,20 @@
bpph = self.factory.makeBinaryPackagePublishingHistory(
binpackageformat=BinaryPackageFormat.DDEB)
self.assertTrue(bpph.is_debug)
+
+ def test_getPublishedSource(self):
+ distroseries = self.factory.makeDistroSeries()
+ archive = self.factory.makeArchive(
+ distribution=distroseries.distribution)
+ other_archive = self.factory.makeArchive(
+ distribution=distroseries.distribution)
+ spph = self.factory.makeSourcePackagePublishingHistory(
+ distroseries=distroseries, archive=archive)
+ self.factory.makeSourcePackagePublishingHistory(
+ distroseries=distroseries, archive=other_archive,
+ sourcepackagerelease=spph.sourcepackagerelease)
+ das = self.factory.makeDistroArchSeries(distroseries=distroseries)
+ bpph = self.factory.makeBinaryPackagePublishingHistory(
+ distroarchseries=das, archive=archive,
+ source_package_release=spph.sourcepackagerelease)
+ self.assertEqual(spph, bpph.getPublishedSource())
Follow ups