launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #15620
[Merge] lp:~wgrant/launchpad/clean-up-publication-methods into lp:launchpad
William Grant has proposed merging lp:~wgrant/launchpad/clean-up-publication-methods into lp:launchpad.
Commit message:
Replace publishBinary and newBinaryPublication with publishBinaries.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~wgrant/launchpad/clean-up-publication-methods/+merge/165512
Replace publishBinary and newBinaryPublication with publishBinaries.
--
https://code.launchpad.net/~wgrant/launchpad/clean-up-publication-methods/+merge/165512
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/clean-up-publication-methods into lp:launchpad.
=== modified file 'lib/lp/archivepublisher/tests/test_dominator.py'
--- lib/lp/archivepublisher/tests/test_dominator.py 2012-01-03 05:05:39 +0000
+++ lib/lp/archivepublisher/tests/test_dominator.py 2013-05-24 01:27:28 +0000
@@ -1244,10 +1244,11 @@
"""Create a `BinaryPackagePublishingHistory`."""
if spr is None:
spr = self.makeSPR()
- bpb = self.factory.makeBinaryPackageBuild(source_package_release=spr)
+ das = self.factory.makeDistroArchSeries(distroseries=distroseries)
+ bpb = self.factory.makeBinaryPackageBuild(
+ source_package_release=spr, distroarchseries=das)
bpr = self.factory.makeBinaryPackageRelease(
build=bpb, architecturespecific=arch_specific)
- das = self.factory.makeDistroArchSeries(distroseries=distroseries)
return removeSecurityProxy(
self.factory.makeBinaryPackagePublishingHistory(
binarypackagerelease=bpr, archive=archive,
=== modified file 'lib/lp/archivepublisher/tests/test_generate_extra_overrides.py'
--- lib/lp/archivepublisher/tests/test_generate_extra_overrides.py 2012-11-10 02:21:31 +0000
+++ lib/lp/archivepublisher/tests/test_generate_extra_overrides.py 2013-05-24 01:27:28 +0000
@@ -150,7 +150,8 @@
distroarchseries=das, processor=das.default_processor)
bpr = self.factory.makeBinaryPackageRelease(
binarypackagename=package.name, build=build,
- component=component, **kwargs)
+ component=component, architecturespecific=True,
+ **kwargs)
lfa = self.factory.makeLibraryFileAlias(
filename="%s.deb" % package.name)
transaction.commit()
=== modified file 'lib/lp/soyuz/adapters/tests/test_overrides.py'
--- lib/lp/soyuz/adapters/tests/test_overrides.py 2011-12-30 06:14:56 +0000
+++ lib/lp/soyuz/adapters/tests/test_overrides.py 2013-05-24 01:27:28 +0000
@@ -247,8 +247,11 @@
for i in xrange(3):
distroarchseries = self.factory.makeDistroArchSeries(
distroseries=distroseries)
+ bpb = self.factory.makeBinaryPackageBuild(
+ distroarchseries=distroarchseries)
bpr = self.factory.makeBinaryPackageRelease(
- binarypackagename=bpn)
+ build=bpb, binarypackagename=bpn,
+ architecturespecific=True)
bpph = self.factory.makeBinaryPackagePublishingHistory(
binarypackagerelease=bpr, distroarchseries=distroarchseries,
archive=distroseries.main_archive, pocket=pocket)
=== modified file 'lib/lp/soyuz/doc/publishing.txt'
--- lib/lp/soyuz/doc/publishing.txt 2013-05-08 06:14:45 +0000
+++ lib/lp/soyuz/doc/publishing.txt 2013-05-24 01:27:28 +0000
@@ -1010,7 +1010,6 @@
This utility implements the following methods:
- * newBinaryPublication();
* newSourcePublication();
which create new publishing records, and:
@@ -1056,11 +1055,11 @@
Creating new publication records
--------------------------------
-newSourcePublication() and newBinaryPublication() will create source and
-binary publication records respectively. They are already implicitly tested
-above via the copyTo methods which use them to create new records. However,
-they have one extra feature which is important for PPAs - they will ensure
-that the published component is always 'main'.
+newSourcePublication() will create a source publication record. It is
+already implicitly tested above via the copyTo method which uses it to
+create new records. However, it has one extra feature which is
+important for PPAs - it will ensure that the published component is
+always 'main'.
When copying publications from non-main components in the primary archive,
the PPA publication will always be main:
@@ -1077,22 +1076,6 @@
>>> print ppa_pub.component.name
main
- >>> test_bin_pubs = test_publisher.getPubBinaries(
- ... pub_source=test_source_pub)
- >>> test_bin_pub = test_bin_pubs[0]
- >>> ppa_pub = publishing_set.newBinaryPublication(
- ... archive=mark.archive,
- ... binarypackagerelease=test_bin_pub.binarypackagerelease,
- ... distroarchseries=test_bin_pub.distroarchseries,
- ... component=test_bin_pub.component,
- ... section=test_bin_pub.section,
- ... priority=test_bin_pub.priority,
- ... pocket=test_bin_pub.pocket)
- >>> print ppa_pub.binarypackagerelease.component.name
- universe
- >>> print ppa_pub.component.name
- main
-
IPublishingSet is an essential component for
`ArchiveSourcePublications` feature, see more information below in
its corresponding test section.
=== modified file 'lib/lp/soyuz/interfaces/publishing.py'
--- lib/lp/soyuz/interfaces/publishing.py 2013-05-08 06:18:50 +0000
+++ lib/lp/soyuz/interfaces/publishing.py 2013-05-24 01:27:28 +0000
@@ -996,10 +996,10 @@
def publishBinaries(archive, distroseries, pocket, binaries):
"""Efficiently publish multiple BinaryPackageReleases in an Archive.
- Creates `IBinaryPackagePublishingHistory` records for each binary,
- handling architecture-independent and debug packages, avoiding
- creation of duplicate publications, and leaving disabled
- architectures alone.
+ Creates `IBinaryPackagePublishingHistory` records for each
+ binary, handling architecture-independent, avoiding creation of
+ duplicate publications, and leaving disabled architectures
+ alone.
:param archive: The target `IArchive`.
:param distroseries: The target `IDistroSeries`.
@@ -1011,43 +1011,6 @@
:return: A list of new `IBinaryPackagePublishingHistory` records.
"""
- def publishBinary(archive, binarypackagerelease, distroseries,
- component, section, priority, pocket):
- """Publish a `BinaryPackageRelease` in an archive.
-
- Creates one or more `IBinaryPackagePublishingHistory` records,
- handling architecture-independent and DDEB publications transparently.
-
- Note that binaries will only be copied if they don't already exist in
- the target; this method cannot be used to change overrides.
-
- :param archive: The target `IArchive`.
- :param binarypackagerelease: The `IBinaryPackageRelease` to copy.
- :param distroseries: An `IDistroSeries`.
- :param component: The target `IComponent`.
- :param section: The target `ISection`.
- :param priority: The target `PackagePublishingPriority`.
- :param pocket: The target `PackagePublishingPocket`.
-
- :return: A list of new `IBinaryPackagePublishingHistory` records.
- """
-
- def newBinaryPublication(archive, binarypackagerelease, distroarchseries,
- component, section, priority, pocket):
- """Create a new `BinaryPackagePublishingHistory`.
-
- :param archive: An `IArchive`
- :param binarypackagerelease: An `IBinaryPackageRelease`
- :param distroarchseries: An `IDistroArchSeries`
- :param component: An `IComponent`
- :param section: An `ISection`
- :param priority: A `PackagePublishingPriority`
- :param pocket: A `PackagePublishingPocket`
-
- datecreated will be UTC_NOW.
- status will be PackagePublishingStatus.PENDING
- """
-
def newSourcePublication(archive, sourcepackagerelease, distroseries,
component, section, pocket, ancestor,
create_dsd_job=True):
=== modified file 'lib/lp/soyuz/model/publishing.py'
--- lib/lp/soyuz/model/publishing.py 2013-05-15 05:48:20 +0000
+++ lib/lp/soyuz/model/publishing.py 2013-05-24 01:27:28 +0000
@@ -1494,36 +1494,6 @@
for (das, bpr, (component, section, priority)) in needed],
get_objects=True)
- def publishBinary(self, archive, binarypackagerelease, distroseries,
- component, section, priority, pocket):
- """See `IPublishingSet`."""
- return self.publishBinaries(
- archive, distroseries, pocket,
- {binarypackagerelease: (component, section, priority)})
-
- def newBinaryPublication(self, archive, binarypackagerelease,
- distroarchseries, component, section, priority,
- pocket):
- """See `IPublishingSet`."""
- assert distroarchseries.enabled, (
- "Will not create new publications in a disabled architecture.")
- return BinaryPackagePublishingHistory(
- archive=archive,
- binarypackagename=binarypackagerelease.binarypackagename,
- binarypackagerelease=binarypackagerelease,
- distroarchseries=distroarchseries,
- component=get_component(
- archive, distroarchseries.distroseries, component),
- section=section,
- priority=priority,
- # We do not set the phased_update_percentage here, as in general
- # it requires feedback on error statistics. In any case,
- # pockets that benefit from phased updates should not normally
- # also be direct upload targets.
- status=PackagePublishingStatus.PENDING,
- datecreated=UTC_NOW,
- pocket=pocket)
-
def newSourcePublication(self, archive, sourcepackagerelease,
distroseries, component, section, pocket,
ancestor=None, create_dsd_job=True,
=== modified file 'lib/lp/soyuz/model/queue.py'
--- lib/lp/soyuz/model/queue.py 2013-04-16 21:13:11 +0000
+++ lib/lp/soyuz/model/queue.py 2013-05-24 01:27:28 +0000
@@ -1199,7 +1199,7 @@
build_archtag))
# First up, publish everything in this build into that dar.
- published_binaries = []
+ bins = {}
for binary in self.build.binarypackages:
debug(
logger, "... %s/%s (Arch %s)" % (
@@ -1207,16 +1207,10 @@
binary.version,
'Specific' if binary.architecturespecific else 'Independent',
))
- published_binaries.extend(
- getUtility(IPublishingSet).publishBinary(
- archive=self.packageupload.archive,
- binarypackagerelease=binary,
- distroseries=distroseries,
- component=binary.component,
- section=binary.section,
- priority=binary.priority,
- pocket=self.packageupload.pocket))
- return published_binaries
+ bins[binary] = (binary.component, binary.section, binary.priority)
+ return getUtility(IPublishingSet).publishBinaries(
+ self.packageupload.archive, distroseries,
+ self.packageupload.pocket, bins)
class PackageUploadSource(SQLBase):
=== modified file 'lib/lp/soyuz/scripts/tests/test_copypackage.py'
--- lib/lp/soyuz/scripts/tests/test_copypackage.py 2013-03-07 16:30:32 +0000
+++ lib/lp/soyuz/scripts/tests/test_copypackage.py 2013-05-24 01:27:28 +0000
@@ -29,6 +29,7 @@
from lp.buildmaster.enums import BuildStatus
from lp.registry.interfaces.distribution import IDistributionSet
from lp.registry.interfaces.pocket import PackagePublishingPocket
+from lp.services.database.constants import UTC_NOW
from lp.services.database.sqlbase import flush_database_caches
from lp.soyuz.adapters.overrides import SourceOverride
from lp.soyuz.enums import (
@@ -1191,10 +1192,14 @@
target_archive = self.factory.makeArchive(
distribution=self.test_publisher.ubuntutest, virtualized=False)
# Manually copy the indep pub to just i386.
- getUtility(IPublishingSet).newBinaryPublication(
- target_archive, bin_i386.binarypackagerelease, nobby['i386'],
- bin_i386.component, bin_i386.section, bin_i386.priority,
- bin_i386.pocket)
+ BinaryPackagePublishingHistory(
+ archive=target_archive,
+ binarypackagename=bin_i386.binarypackagename,
+ binarypackagerelease=bin_i386.binarypackagerelease,
+ distroarchseries=nobby['i386'], pocket=bin_i386.pocket,
+ component=bin_i386.component, section=bin_i386.section,
+ priority=bin_i386.priority,
+ status=PackagePublishingStatus.PENDING, datecreated=UTC_NOW)
# Now we can copy the package with binaries.
copies = self.doCopy(
source, target_archive, nobby, source.pocket, True)
=== modified file 'lib/lp/soyuz/tests/test_distributionsourcepackagerelease.py'
--- lib/lp/soyuz/tests/test_distributionsourcepackagerelease.py 2013-02-06 09:21:20 +0000
+++ lib/lp/soyuz/tests/test_distributionsourcepackagerelease.py 2013-05-24 01:27:28 +0000
@@ -41,7 +41,8 @@
source_package_release=self.sourcepackagerelease,
distroarchseries=self.distroarchseries)
bp_release = self.factory.makeBinaryPackageRelease(
- build=bp_build, binarypackagename=name)
+ build=bp_build, binarypackagename=name, architecturespecific=True,
+ version=self.factory.getUniqueString())
sourcepackagename = self.sourcepackagerelease.sourcepackagename
self.factory.makeSourcePackagePublishingHistory(
sourcepackagename=sourcepackagename,
=== modified file 'lib/lp/soyuz/tests/test_distroseriessourcepackagerelease.py'
--- lib/lp/soyuz/tests/test_distroseriessourcepackagerelease.py 2012-01-01 02:58:52 +0000
+++ lib/lp/soyuz/tests/test_distroseriessourcepackagerelease.py 2013-05-24 01:27:28 +0000
@@ -38,7 +38,8 @@
source_package_release=self.sourcepackagerelease,
distroarchseries=self.distroarchseries)
bp_release = self.factory.makeBinaryPackageRelease(
- build=bp_build, binarypackagename=name)
+ build=bp_build, binarypackagename=name,
+ version=self.factory.getUniqueString())
sourcepackagename = self.sourcepackagerelease.sourcepackagename
self.factory.makeSourcePackagePublishingHistory(
sourcepackagename=sourcepackagename,
=== modified file 'lib/lp/soyuz/tests/test_packagecopyjob.py'
--- lib/lp/soyuz/tests/test_packagecopyjob.py 2013-03-07 13:32:57 +0000
+++ lib/lp/soyuz/tests/test_packagecopyjob.py 2013-05-24 01:27:28 +0000
@@ -1591,7 +1591,8 @@
self.factory.makeBinaryPackagePublishingHistory(
status=PackagePublishingStatus.PUBLISHED, distroarchseries=das,
pocket=PackagePublishingPocket.UPDATES, archive=archive,
- source_package_release=spph.sourcepackagerelease)
+ source_package_release=spph.sourcepackagerelease,
+ architecturespecific=True)
requester = self.factory.makePerson()
with person_logged_in(archive.owner):
archive.newComponentUploader(requester, 'multiverse')
=== modified file 'lib/lp/soyuz/tests/test_publishing.py'
--- lib/lp/soyuz/tests/test_publishing.py 2013-05-15 05:48:20 +0000
+++ lib/lp/soyuz/tests/test_publishing.py 2013-05-24 01:27:28 +0000
@@ -1407,12 +1407,12 @@
class TestPublishBinaries(TestCaseWithFactory):
- """Test PublishingSet.publishBinary() works."""
+ """Test PublishingSet.publishBinaries() works."""
layer = LaunchpadZopelessLayer
def makeArgs(self, bprs, distroseries, archive=None):
- """Create a dict of arguments for publishBinary."""
+ """Create a dict of arguments for publishBinaries."""
if archive is None:
archive = distroseries.main_archive
return {
=== modified file 'lib/lp/soyuz/tests/test_publishing_models.py'
--- lib/lp/soyuz/tests/test_publishing_models.py 2013-02-28 09:57:58 +0000
+++ lib/lp/soyuz/tests/test_publishing_models.py 2013-05-24 01:27:28 +0000
@@ -50,7 +50,8 @@
def test_getUnpublishedBuildsForSources_one_published(self):
# If we publish a binary for a build, it is no longer returned.
- bpr = self.factory.makeBinaryPackageRelease(build=self.builds[0])
+ bpr = self.factory.makeBinaryPackageRelease(
+ build=self.builds[0], architecturespecific=True)
self.factory.makeBinaryPackagePublishingHistory(
binarypackagerelease=bpr, archive=self.sources[0].archive,
distroarchseries=self.builds[0].distro_arch_series,
@@ -69,7 +70,8 @@
# Publish the binaries for gedit as superseded, explicitly setting
# the date published.
- bpr = self.factory.makeBinaryPackageRelease(build=self.builds[0])
+ bpr = self.factory.makeBinaryPackageRelease(
+ build=self.builds[0], architecturespecific=True)
bpph = self.factory.makeBinaryPackagePublishingHistory(
binarypackagerelease=bpr, archive=self.sources[0].archive,
distroarchseries=self.builds[0].distro_arch_series,
=== modified file 'lib/lp/soyuz/tests/test_sourcepackagerelease.py'
--- lib/lp/soyuz/tests/test_sourcepackagerelease.py 2012-11-26 12:53:30 +0000
+++ lib/lp/soyuz/tests/test_sourcepackagerelease.py 2013-05-24 01:27:28 +0000
@@ -152,18 +152,20 @@
Since the tests need to create a pocket mismatch, it is guaranteed
that the BPPHs are for the UPDATES pocket.
"""
+ das = self.factory.makeDistroArchSeries()
+ distroseries = das.distroseries
+ archive = distroseries.main_archive
+ pocket = PackagePublishingPocket.UPDATES
+
bpbs = [
- self.factory.makeBinaryPackageBuild(source_package_release=spr)
+ self.factory.makeBinaryPackageBuild(
+ source_package_release=spr, distroarchseries=das)
for counter in range(number)]
bprs = [
self.factory.makeBinaryPackageRelease(
build=bpb, architecturespecific=True)
for bpb in bpbs]
- das = self.factory.makeDistroArchSeries()
- distroseries = das.distroseries
- archive = distroseries.main_archive
- pocket = PackagePublishingPocket.UPDATES
return [
removeSecurityProxy(
self.factory.makeBinaryPackagePublishingHistory(
@@ -289,10 +291,11 @@
# The series also has other architectures.
self.factory.makeDistroArchSeries(distroseries=distroseries)
- for das in distroseries.architectures:
- self.factory.makeBinaryPackagePublishingHistory(
- binarypackagerelease=bpr, distroarchseries=das,
- archive=archive)
+ # makeBinaryPackagePublishingHistory will actually publish an
+ # arch-indep BPR everywhere.
+ self.factory.makeBinaryPackagePublishingHistory(
+ binarypackagerelease=bpr, archive=archive,
+ distroarchseries=distroseries.nominatedarchindep)
naked_spr = removeSecurityProxy(spr)
self.assertEqual(
=== modified file 'lib/lp/testing/factory.py'
--- lib/lp/testing/factory.py 2013-05-15 09:42:22 +0000
+++ lib/lp/testing/factory.py 2013-05-24 01:27:28 +0000
@@ -303,6 +303,7 @@
from lp.soyuz.model.packagediff import PackageDiff
from lp.soyuz.model.processor import ProcessorFamilySet
from lp.testing import (
+ admin_logged_in,
ANONYMOUS,
celebrity_logged_in,
launchpadlib_for,
@@ -3743,6 +3744,7 @@
binpackageformat=None,
sourcepackagename=None,
version=None,
+ architecturespecific=False,
with_debug=False, with_file=False):
"""Make a `BinaryPackagePublishingHistory`."""
if distroarchseries is None:
@@ -3758,6 +3760,13 @@
archive = self.makeArchive(
distribution=distroarchseries.distroseries.distribution,
purpose=ArchivePurpose.PRIMARY)
+ # XXX wgrant 2013-05-23: We need to set build_debug_symbols
+ # until the guard in publishBinaries is gone.
+ need_debug = (
+ with_debug or binpackageformat == BinaryPackageFormat.DDEB)
+ if archive.purpose == ArchivePurpose.PRIMARY and need_debug:
+ with admin_logged_in():
+ archive.build_debug_symbols = True
if pocket is None:
pocket = self.getAnyPocket()
@@ -3780,7 +3789,8 @@
binarypackagename=binarypackagename, version=version,
build=binarypackagebuild,
component=component, binpackageformat=binpackageformat,
- section_name=section_name, priority=priority)
+ section_name=section_name, priority=priority,
+ architecturespecific=architecturespecific)
if with_file:
ext = {
BinaryPackageFormat.DEB: 'deb',
@@ -3800,18 +3810,20 @@
if datecreated is None:
datecreated = self.getUniqueDate()
- bpph = getUtility(IPublishingSet).newBinaryPublication(
- archive, binarypackagerelease, distroarchseries,
- binarypackagerelease.component, binarypackagerelease.section,
- priority, pocket)
- naked_bpph = removeSecurityProxy(bpph)
- naked_bpph.status = status
- naked_bpph.dateremoved = dateremoved
- naked_bpph.datecreated = datecreated
- naked_bpph.scheduleddeletiondate = scheduleddeletiondate
- naked_bpph.priority = priority
- if status == PackagePublishingStatus.PUBLISHED:
- naked_bpph.datepublished = UTC_NOW
+ bpphs = getUtility(IPublishingSet).publishBinaries(
+ archive, distroarchseries.distroseries, pocket,
+ {binarypackagerelease: (
+ binarypackagerelease.component, binarypackagerelease.section,
+ priority)})
+ for bpph in bpphs:
+ naked_bpph = removeSecurityProxy(bpph)
+ naked_bpph.status = status
+ naked_bpph.dateremoved = dateremoved
+ naked_bpph.datecreated = datecreated
+ naked_bpph.scheduleddeletiondate = scheduleddeletiondate
+ naked_bpph.priority = priority
+ if status == PackagePublishingStatus.PUBLISHED:
+ naked_bpph.datepublished = UTC_NOW
if with_debug:
debug_bpph = self.makeBinaryPackagePublishingHistory(
binarypackagename=(
@@ -3828,8 +3840,8 @@
with_file=with_file)
removeSecurityProxy(bpph.binarypackagerelease).debug_package = (
debug_bpph.binarypackagerelease)
- return bpph, debug_bpph
- return bpph
+ return bpphs[0], debug_bpph
+ return bpphs[0]
def makeSPPHForBPPH(self, bpph):
"""Produce a `SourcePackagePublishingHistory` to match `bpph`.