Merge lp:~michael.nelson/launchpad/529926-partner-override-to-main into lp:launchpad

Proposed by Michael Nelson
Status: Merged
Approved by: Michael Nelson
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~michael.nelson/launchpad/529926-partner-override-to-main
Merge into: lp:launchpad
Diff against target: 129 lines (+52/-10)
4 files modified
lib/lp/soyuz/doc/distroseriesqueue.txt (+1/-1)
lib/lp/soyuz/model/queue.py (+9/-4)
lib/lp/soyuz/scripts/queue.py (+9/-5)
lib/lp/soyuz/tests/test_packageupload.py (+33/-0)
To merge this branch: bzr merge lp:~michael.nelson/launchpad/529926-partner-override-to-main
Reviewer Review Type Date Requested Status
Paul Hummer (community) code Approve
Brad Crittenden (community) Needs Information
Review via email: mp+21329@code.launchpad.net

Commit message

Uploads that are overridden to a component requiring a different archive will be published in the correct archive context.

Description of the change

Fixes bug 529926 by ensuring that when the component of a source package upload is overridden, the target archive of the upload is also overridden as necessary.

This only becomes apparent when a "main" archive is uploaded and overridden to "partner" (or debug, I assume, any component that has a separate archive). In this case the source package release was being overridden correctly, but it is the package upload's archive that is used to create the new publishings.

Pre-implementation notes on the bug, and I chatted with Julian about this as well.

I was originally planning simply to use the SourcePackageRelease.upload_archive as the target for the publishing, but delayed copies actually re-use IPackageUpload to store the intended target archive. So rather than having conditional code for the target archive dependent on IPackageUpload.is_delayed_upload, I've updated the archive on the IPackageUpload itself.

To test:
bin/test -vv -m lp.archiveuploader

To post a comment you must log in.
Revision history for this message
Brad Crittenden (bac) wrote :

Michael can you resolve the conflicts in your branch? I gave it a try but failed.

review: Needs Information
Revision history for this message
Michael Nelson (michael.nelson) wrote :

Thanks for taking a look Brad even when I wasn't around. I've re-merged, resolved and pushed, but am guessing you're finished your OCR now... I'll see if someone else can take a look in the mean time.

Revision history for this message
Paul Hummer (rockstar) wrote :

Thanks for the branch. These changes look good.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/soyuz/doc/distroseriesqueue.txt'
2--- lib/lp/soyuz/doc/distroseriesqueue.txt 2010-03-11 13:35:11 +0000
3+++ lib/lp/soyuz/doc/distroseriesqueue.txt 2010-03-23 07:48:33 +0000
4@@ -109,7 +109,7 @@
5 ... print source.sourcepackagerelease.name
6 ... pub_records = item.realiseUpload(mock_logger)
7 ed
8- DEBUG: Publishing source ed/0.2-20 to ubuntu/hoary
9+ DEBUG: Publishing source ed/0.2-20 to ubuntu/hoary in the primary archive
10 DEBUG: Publishing build to ubuntu/hoary/i386
11 DEBUG: ... ed/0.2-20 (Arch Specific)
12
13
14=== modified file 'lib/lp/soyuz/model/queue.py'
15--- lib/lp/soyuz/model/queue.py 2010-03-17 12:14:36 +0000
16+++ lib/lp/soyuz/model/queue.py 2010-03-23 07:48:33 +0000
17@@ -1318,7 +1318,12 @@
18 source.sourcepackagerelease.override(
19 component=new_component, section=new_section)
20
21- return self.sources.count() > 0
22+ # We override our own archive too, as it is used to create
23+ # the SPPH during publish().
24+ self.archive = self.distroseries.distribution.getArchiveByComponent(
25+ new_component.name)
26+
27+ return True
28
29 def overrideBinaries(self, new_component, new_section, new_priority,
30 allowed_components):
31@@ -1546,7 +1551,6 @@
32 """See `IPackageUploadSource`."""
33 distroseries = self.packageupload.distroseries
34 component = self.sourcepackagerelease.component
35- section = self.sourcepackagerelease.section
36
37 if self.packageupload.is_delayed_copy:
38 # For a delayed copy the component will not yet have
39@@ -1576,11 +1580,12 @@
40 def publish(self, logger=None):
41 """See `IPackageUploadSource`."""
42 # Publish myself in the distroseries pointed at by my queue item.
43- debug(logger, "Publishing source %s/%s to %s/%s" % (
44+ debug(logger, "Publishing source %s/%s to %s/%s in the %s archive" % (
45 self.sourcepackagerelease.name,
46 self.sourcepackagerelease.version,
47 self.packageupload.distroseries.distribution.name,
48- self.packageupload.distroseries.name))
49+ self.packageupload.distroseries.name,
50+ self.packageupload.archive.name))
51
52 return getUtility(IPublishingSet).newSourcePublication(
53 archive=self.packageupload.archive,
54
55=== modified file 'lib/lp/soyuz/scripts/queue.py'
56--- lib/lp/soyuz/scripts/queue.py 2010-02-09 00:17:40 +0000
57+++ lib/lp/soyuz/scripts/queue.py 2010-03-23 07:48:33 +0000
58@@ -567,11 +567,15 @@
59 raise QueueActionError('Not Found: %s' % info)
60
61 for queue_item in self.items:
62- # There's usually only one item in queue_item.sources.
63- for source in queue_item.sources:
64- source.sourcepackagerelease.override(component=component,
65- section=section)
66- self.displayInfo(queue_item)
67+ # We delegate to the queue_item itself to override any/all
68+ # of its sources.
69+ if queue_item.contains_source:
70+ queue_item.overrideSource(
71+ component, section, [
72+ component,
73+ queue_item.sourcepackagerelease.component
74+ ])
75+ self.displayInfo(queue_item)
76
77 def _override_binary(self):
78 """Overrides binarypackagereleases selected"""
79
80=== modified file 'lib/lp/soyuz/tests/test_packageupload.py'
81--- lib/lp/soyuz/tests/test_packageupload.py 2010-03-13 00:32:40 +0000
82+++ lib/lp/soyuz/tests/test_packageupload.py 2010-03-23 07:48:33 +0000
83@@ -20,6 +20,7 @@
84 from lp.registry.interfaces.pocket import PackagePublishingPocket
85 from lp.services.mail import stub
86 from lp.soyuz.interfaces.archive import ArchivePurpose
87+from lp.soyuz.interfaces.component import IComponentSet
88 from lp.soyuz.interfaces.publishing import PackagePublishingStatus
89 from lp.soyuz.interfaces.queue import (
90 IPackageUploadSet, PackageUploadCustomFormat, PackageUploadStatus)
91@@ -297,6 +298,38 @@
92 self.assertEquals(
93 BuildStatus.NEEDSBUILD, build.buildstate)
94
95+ def test_realiseUpload_for_overridden_component_archive(self):
96+ # If the component of an upload is overridden to 'Partner' for
97+ # example, then the new publishing record should be for the
98+ # partner archive.
99+ self.test_publisher.prepareBreezyAutotest()
100+
101+ # Get some sample changes file content for the new upload.
102+ changes_file = open(
103+ datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'))
104+ changes_file_content = changes_file.read()
105+ changes_file.close()
106+
107+ main_upload_release = self.test_publisher.getPubSource(
108+ sourcename='main-upload', spr_only=True,
109+ component='main', changes_file_content=changes_file_content)
110+ package_upload = main_upload_release.package_upload
111+
112+ self.assertEqual("primary", main_upload_release.upload_archive.name)
113+
114+ # Override the upload to partner and verify the change.
115+ partner_component = getUtility(IComponentSet)['partner']
116+ main_component = getUtility(IComponentSet)['main']
117+ package_upload.overrideSource(
118+ partner_component, None, [partner_component, main_component])
119+ self.assertEqual(
120+ "partner", main_upload_release.upload_archive.name)
121+
122+ # Now realise the upload and verify that the publishing is for
123+ # the partner archive.
124+ pub = package_upload.realiseUpload()[0]
125+ self.assertEqual("partner", pub.archive.name)
126+
127
128 def test_suite():
129 return unittest.TestLoader().loadTestsFromName(__name__)