Merge lp:~stevenk/launchpad/delayed-ppa-copies-ancestryless into lp:launchpad

Proposed by Steve Kowalik
Status: Merged
Approved by: Julian Edwards
Approved revision: no longer in the source branch.
Merged at revision: 12084
Proposed branch: lp:~stevenk/launchpad/delayed-ppa-copies-ancestryless
Merge into: lp:launchpad
Diff against target: 64 lines (+34/-9)
2 files modified
lib/lp/soyuz/model/publishing.py (+15/-9)
lib/lp/soyuz/tests/test_publishing.py (+19/-0)
To merge this branch: bzr merge lp:~stevenk/launchpad/delayed-ppa-copies-ancestryless
Reviewer Review Type Date Requested Status
Julian Edwards (community) code Approve
Review via email: mp+43750@code.launchpad.net

Commit message

[r=julian-edwards][ui=none][bug=610687] Change overrideFromAncestry() to not check ancestry for PPA uploads, and assert the component is sane.

Description of the change

This branch changes overrideFromAncestry() to not even check it for PPA uploads, and assert their component is 'main' for a sanity check.

I also drove-by a comment fix that I noticed.

To post a comment you must log in.
Revision history for this message
Julian Edwards (julian-edwards) wrote :

Approved on the understanding that you fix the hard-coded check for 'main' and replace it with IArchive.getComponentsForSeries()

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/model/publishing.py'
2--- lib/lp/soyuz/model/publishing.py 2010-12-09 11:25:48 +0000
3+++ lib/lp/soyuz/model/publishing.py 2010-12-15 23:37:39 +0000
4@@ -801,15 +801,21 @@
5 assert self.status == PackagePublishingStatus.PENDING, (
6 "Cannot override published records.")
7
8- # If there is an published ancestry, use its component, otherwise
9- # use the original upload component.
10- ancestry = self.getAncestry()
11- if ancestry is not None:
12- component = ancestry.component
13- else:
14- component = self.sourcepackagerelease.component
15-
16- self.component = component
17+ # If there is published ancestry, use its component, otherwise
18+ # use the original upload component. Since PPAs only use main,
19+ # we don't need to check the ancestry.
20+ if not self.archive.is_ppa:
21+ ancestry = self.getAncestry()
22+ if ancestry is not None:
23+ component = ancestry.component
24+ else:
25+ component = self.sourcepackagerelease.component
26+
27+ self.component = component
28+
29+ assert self.component in (
30+ self.archive.getComponentsForSeries(self.distroseries))
31+
32
33 def _proxied_urls(self, files, parent):
34 """Run the files passed through `ProxiedLibraryFileAlias`."""
35
36=== modified file 'lib/lp/soyuz/tests/test_publishing.py'
37--- lib/lp/soyuz/tests/test_publishing.py 2010-10-06 11:46:51 +0000
38+++ lib/lp/soyuz/tests/test_publishing.py 2010-12-15 23:37:39 +0000
39@@ -956,6 +956,25 @@
40 self.copyAndCheck(
41 binary, binary.distroarchseries.distroseries, 'universe')
42
43+ def test_ppa_override_no_ancestry(self):
44+ # Test a PPA publication with no ancestry is 'main'
45+ ppa = self.factory.makeArchive(purpose=ArchivePurpose.PPA)
46+ spr = self.factory.makeSourcePackageRelease()
47+ spph = self.factory.makeSourcePackagePublishingHistory(
48+ sourcepackagerelease=spr, archive=ppa)
49+ spph.overrideFromAncestry()
50+ self.assertEquals(spph.component.name, 'main')
51+
52+ def test_ppa_override_with_ancestry(self):
53+ # Test a PPA publication with ancestry
54+ ppa = self.factory.makeArchive(purpose=ArchivePurpose.PPA)
55+ spr = self.factory.makeSourcePackageRelease()
56+ spph = self.factory.makeSourcePackagePublishingHistory(
57+ sourcepackagerelease=spr, archive=ppa)
58+ spph2 = self.factory.makeSourcePackagePublishingHistory(
59+ sourcepackagerelease=spr, archive=ppa)
60+ spph2.overrideFromAncestry()
61+ self.assertEquals(spph2.component.name, 'main')
62
63 class BuildRecordCreationTests(TestNativePublishingBase):
64 """Test the creation of build records."""