Merge lp:~jelmer/launchpad/stable-fix into lp:launchpad/db-devel

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Edwin Grubbs
Approved revision: no longer in the source branch.
Merged at revision: 9513
Proposed branch: lp:~jelmer/launchpad/stable-fix
Merge into: lp:launchpad/db-devel
Diff against target: 259 lines (+97/-21)
8 files modified
lib/lp/soyuz/browser/archive.py (+29/-1)
lib/lp/soyuz/configure.zcml (+2/-1)
lib/lp/soyuz/interfaces/archive.py (+6/-2)
lib/lp/soyuz/interfaces/processor.py (+6/-0)
lib/lp/soyuz/model/archive.py (+18/-0)
lib/lp/soyuz/model/processor.py (+5/-0)
lib/lp/soyuz/tests/test_archive.py (+21/-17)
lib/lp/soyuz/tests/test_processor.py (+10/-0)
To merge this branch: bzr merge lp:~jelmer/launchpad/stable-fix
Reviewer Review Type Date Requested Status
Edwin Grubbs (community) Approve
Review via email: mp+28912@code.launchpad.net

Commit message

Manual merge of stable.

Description of the change

Merge of the stable branch, with conflicts resolved.

To post a comment you must log in.
Revision history for this message
Edwin Grubbs (edwin-grubbs) wrote :

Hi Jelmer,

The merge looks good, but there are a bunch of lint errors. There are also dangling whitespace and tab characters that lint doesn't warn you about, since that is normally picked up by the user's editor configuration.

-Edwin

configure.zcml has tab-characters instead of spaces and dangling
whitespace at the end of lines.

test_archive.py has a lot of dangling whitespace.

archive.py has dangling whitespace.

== Pyflakes notices ==

lib/lp/soyuz/tests/test_archive.py
    133: local variable 'gedit_main_src_hist' is assigned to but never used

== Pylint notices ==

lib/lp/soyuz/interfaces/archive.py
    502: [C0301] Line too long (79/78)

lib/lp/soyuz/tests/test_archive.py
    789: [C0301] Line too long (79/78)

lib/lp/soyuz/tests/test_processor.py
    30: [C0301] Line too long (79/78)
    37: [C0301] Line too long (79/78)
    39: [C0301] Line too long (79/78)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/soyuz/browser/archive.py'
2--- lib/lp/soyuz/browser/archive.py 2010-06-25 15:03:10 +0000
3+++ lib/lp/soyuz/browser/archive.py 2010-06-30 17:52:31 +0000
4@@ -78,6 +78,7 @@
5 from lp.soyuz.interfaces.packageset import IPackagesetSet
6 from lp.registry.interfaces.person import IPersonSet, PersonVisibility
7 from lp.registry.interfaces.pocket import PackagePublishingPocket
8+from lp.soyuz.interfaces.processor import IProcessorFamilySet
9 from lp.soyuz.interfaces.publishing import (
10 active_publishing_status, inactive_publishing_status, IPublishingSet,
11 PackagePublishingStatus)
12@@ -1874,10 +1875,12 @@
13
14 field_names = ['enabled', 'private', 'commercial', 'require_virtualized',
15 'buildd_secret', 'authorized_size', 'relative_build_score',
16- 'external_dependencies', 'arm_builds_allowed']
17+ 'external_dependencies']
18
19 custom_widget('external_dependencies', TextAreaWidget, height=3)
20
21+ custom_widget('enabled_restricted_families', LabeledMultiCheckBoxWidget)
22+
23 def validate_save(self, action, data):
24 """Validate the save action on ArchiveAdminView.
25
26@@ -1956,6 +1959,31 @@
27 """
28 return self.context.owner.visibility == PersonVisibility.PRIVATE
29
30+ def setUpFields(self):
31+ """Override `LaunchpadEditFormView`.
32+
33+ See `createEnabledRestrictedFamilies` method.
34+ """
35+ super(ArchiveAdminView, self).setUpFields()
36+ self.form_fields += self.createEnabledRestrictedFamilies()
37+
38+ def createEnabledRestrictedFamilies(self):
39+ """Creates the 'enabled_restricted_families' field.
40+
41+ """
42+ terms = []
43+ for family in getUtility(IProcessorFamilySet).getRestricted():
44+ terms.append(SimpleTerm(
45+ family, token=family.name, title=family.title))
46+ return form.Fields(
47+ List(__name__='enabled_restricted_families',
48+ title=_('Enabled restricted families'),
49+ value_type=Choice(vocabulary=SimpleVocabulary(terms)),
50+ required=False,
51+ description=_('Select the restricted architecture families '
52+ 'on which this archive is allowed to build.')),
53+ render_context=self.render_context)
54+
55
56 class ArchiveDeleteView(LaunchpadFormView):
57 """View class for deleting `IArchive`s"""
58
59=== modified file 'lib/lp/soyuz/configure.zcml'
60--- lib/lp/soyuz/configure.zcml 2010-06-21 19:29:34 +0000
61+++ lib/lp/soyuz/configure.zcml 2010-06-30 17:52:31 +0000
62@@ -405,7 +405,8 @@
63 set_attributes="description displayname publish status"/>
64 <require
65 permission="launchpad.Commercial"
66- set_attributes="authorized_size buildd_secret arm_builds_allowed
67+ set_attributes="authorized_size buildd_secret
68+ enabled_restricted_families
69 commercial external_dependencies private
70 require_virtualized relative_build_score "/>
71 <require
72
73=== modified file 'lib/lp/soyuz/interfaces/archive.py'
74--- lib/lp/soyuz/interfaces/archive.py 2010-06-25 15:03:10 +0000
75+++ lib/lp/soyuz/interfaces/archive.py 2010-06-30 17:52:31 +0000
76@@ -56,6 +56,7 @@
77 from canonical.launchpad.interfaces.launchpad import IPrivacy
78 from lp.registry.interfaces.role import IHasOwner
79 from lp.soyuz.interfaces.buildrecords import IHasBuildRecords
80+from lp.soyuz.interfaces.processor import IProcessorFamily
81 from lp.registry.interfaces.gpg import IGPGKey
82 from lp.registry.interfaces.person import IPerson
83 from canonical.launchpad.validators.name import name_validator
84@@ -368,8 +369,11 @@
85 "context build.\n"
86 "NOTE: This is for migration of OEM PPAs only!"))
87
88- arm_builds_allowed = Bool(
89- title=_("Allow ARM builds for this archive"))
90+ enabled_restricted_families = CollectionField(
91+ title=_("Restricted architecture families this archive can build "
92+ "on"),
93+ value_type=Reference(schema=IProcessorFamily),
94+ readonly=False)
95
96 commercial = exported(
97 Bool(
98
99=== modified file 'lib/lp/soyuz/interfaces/processor.py'
100--- lib/lp/soyuz/interfaces/processor.py 2010-02-24 15:13:10 +0000
101+++ lib/lp/soyuz/interfaces/processor.py 2010-06-30 17:52:31 +0000
102@@ -55,6 +55,12 @@
103 :return: A `IProcessorFamily` instance if found, None otherwise.
104 """
105
106+ def getRestricted():
107+ """Return a sequence of all restricted architectures.
108+
109+ :return: A sequence of `IProcessorFamily` instances.
110+ """
111+
112 def getByProcessorName(name):
113 """Given a processor name return the ProcessorFamily it belongs to.
114
115
116=== modified file 'lib/lp/soyuz/model/archive.py'
117--- lib/lp/soyuz/model/archive.py 2010-06-29 09:37:26 +0000
118+++ lib/lp/soyuz/model/archive.py 2010-06-30 17:52:31 +0000
119@@ -1590,6 +1590,24 @@
120 LibraryFileContent.id == LibraryFileAlias.contentID).config(
121 distinct=True))
122
123+ def _get_enabled_restricted_families(self):
124+ archive_arch_set = getUtility(IArchiveArchSet)
125+ restricted_families = archive_arch_set.getRestrictedfamilies(self)
126+ return [family for (family, archive_arch) in restricted_families
127+ if archive_arch is not None]
128+
129+ def _set_enabled_restricted_families(self, value):
130+ archive_arch_set = getUtility(IArchiveArchSet)
131+ restricted_families = archive_arch_set.getRestrictedfamilies(self)
132+ for (family, archive_arch) in restricted_families:
133+ if family in value and archive_arch is None:
134+ archive_arch_set.new(self, family)
135+ if family not in value and archive_arch is not None:
136+ Store.of(self).remove(archive_arch)
137+
138+ enabled_restricted_families = property(_get_enabled_restricted_families,
139+ _set_enabled_restricted_families)
140+
141
142 class ArchiveSet:
143 implements(IArchiveSet)
144
145=== modified file 'lib/lp/soyuz/model/processor.py'
146--- lib/lp/soyuz/model/processor.py 2010-02-24 16:14:37 +0000
147+++ lib/lp/soyuz/model/processor.py 2010-06-30 17:52:31 +0000
148@@ -59,6 +59,11 @@
149 rset = store.find(ProcessorFamily, ProcessorFamily.name == name)
150 return rset.one()
151
152+ def getRestricted(self):
153+ """See `IProcessorFamilySet`."""
154+ store = getUtility(IStoreSelector).get(MAIN_STORE, DEFAULT_FLAVOR)
155+ return store.find(ProcessorFamily, ProcessorFamily.restricted == True)
156+
157 def getByProcessorName(self, name):
158 """Please see `IProcessorFamilySet`."""
159 store = getUtility(IStoreSelector).get(MAIN_STORE, DEFAULT_FLAVOR)
160
161=== modified file 'lib/lp/soyuz/tests/test_archive.py'
162--- lib/lp/soyuz/tests/test_archive.py 2010-06-25 15:03:10 +0000
163+++ lib/lp/soyuz/tests/test_archive.py 2010-06-30 17:52:31 +0000
164@@ -739,14 +739,15 @@
165 self.assertCount(3, self.archive, self.bpr_2, day, self.australia)
166
167
168-class TestARMBuildsAllowed(TestCaseWithFactory):
169- """Ensure that ARM builds can be allowed and disallowed correctly."""
170+class TestEnabledRestrictedBuilds(TestCaseWithFactory):
171+ """Ensure that restricted architecture family builds can be allowed and
172+ disallowed correctly."""
173
174 layer = LaunchpadZopelessLayer
175
176 def setUp(self):
177 """Setup an archive with relevant publications."""
178- super(TestARMBuildsAllowed, self).setUp()
179+ super(TestEnabledRestrictedBuilds, self).setUp()
180 self.publisher = SoyuzTestPublisher()
181 self.publisher.prepareBreezyAutotest()
182 self.archive = self.factory.makeArchive()
183@@ -754,41 +755,44 @@
184 self.arm = getUtility(IProcessorFamilySet).getByName('arm')
185
186 def test_default(self):
187- """By default, ARM builds are not allowed."""
188+ """By default, ARM builds are not allowed as ARM is restricted."""
189 self.assertEquals(0,
190 self.archive_arch_set.getByArchive(
191 self.archive, self.arm).count())
192- self.assertFalse(self.archive.arm_builds_allowed)
193+ self.assertEquals([], list(self.archive.enabled_restricted_families))
194
195 def test_get_uses_archivearch(self):
196 """Adding an entry to ArchiveArch for ARM and an archive will
197- enable arm_builds_allowed for that archive."""
198- self.assertFalse(self.archive.arm_builds_allowed)
199+ enable enabled_restricted_families for arm for that archive."""
200+ self.assertEquals([], list(self.archive.enabled_restricted_families))
201 self.archive_arch_set.new(self.archive, self.arm)
202- self.assertTrue(self.archive.arm_builds_allowed)
203+ self.assertEquals([self.arm],
204+ list(self.archive.enabled_restricted_families))
205
206- def test_get_uses_arm_only(self):
207- """Adding an entry to ArchiveArch for something other than ARM
208- does not enable arm_builds_allowed for that archive."""
209- self.assertFalse(self.archive.arm_builds_allowed)
210+ def test_get_returns_restricted_only(self):
211+ """Adding an entry to ArchiveArch for something that is not
212+ restricted does not make it show up in enabled_restricted_families.
213+ """
214+ self.assertEquals([], list(self.archive.enabled_restricted_families))
215 self.archive_arch_set.new(self.archive,
216 getUtility(IProcessorFamilySet).getByName('amd64'))
217- self.assertFalse(self.archive.arm_builds_allowed)
218+ self.assertEquals([], list(self.archive.enabled_restricted_families))
219
220 def test_set(self):
221 """The property remembers its value correctly and sets ArchiveArch."""
222- self.archive.arm_builds_allowed = True
223+ self.archive.enabled_restricted_families = [self.arm]
224 allowed_restricted_families = self.archive_arch_set.getByArchive(
225 self.archive, self.arm)
226 self.assertEquals(1, allowed_restricted_families.count())
227 self.assertEquals(self.arm,
228 allowed_restricted_families[0].processorfamily)
229- self.assertTrue(self.archive.arm_builds_allowed)
230- self.archive.arm_builds_allowed = False
231+ self.assertEquals([self.arm], self.archive.enabled_restricted_families)
232+ self.archive.enabled_restricted_families = []
233 self.assertEquals(0,
234 self.archive_arch_set.getByArchive(
235 self.archive, self.arm).count())
236- self.assertFalse(self.archive.arm_builds_allowed)
237+ self.assertEquals([], list(self.archive.enabled_restricted_families))
238+
239
240 class TestArchiveTokens(TestCaseWithFactory):
241 layer = LaunchpadZopelessLayer
242
243=== modified file 'lib/lp/soyuz/tests/test_processor.py'
244--- lib/lp/soyuz/tests/test_processor.py 2010-02-25 17:07:38 +0000
245+++ lib/lp/soyuz/tests/test_processor.py 2010-06-30 17:52:31 +0000
246@@ -30,3 +30,13 @@
247 proc = family.addProcessor("avr2001", "The 2001 AVR", "Fast as light.")
248 self.assertProvides(proc, IProcessor)
249 self.assertEquals(family, proc.family)
250+
251+ def test_get_restricted(self):
252+ """Test retrieving all restricted processors."""
253+ family_set = getUtility(IProcessorFamilySet)
254+ normal_family = getUtility(IProcessorFamilySet).new("avr", "Atmel AVR",
255+ "The Modified Harvard architecture 8-bit RISC processors.")
256+ restricted_family = getUtility(IProcessorFamilySet).new("5051", "5051",
257+ "Another small processor family", restricted=True)
258+ self.assertFalse(normal_family in family_set.getRestricted())
259+ self.assertTrue(restricted_family in family_set.getRestricted())

Subscribers

People subscribed via source and target branches

to status/vote changes: