Merge lp:~lifeless/launchpad/recipes into lp:launchpad

Proposed by Robert Collins on 2010-11-04
Status: Merged
Approved by: Gavin Panella on 2010-11-04
Approved revision: no longer in the source branch.
Merged at revision: 11866
Proposed branch: lp:~lifeless/launchpad/recipes
Merge into: lp:launchpad
Diff against target: 168 lines (+36/-4)
6 files modified
lib/lp/code/browser/branch.py (+2/-1)
lib/lp/code/browser/sourcepackagerecipelisting.py (+2/-1)
lib/lp/code/interfaces/sourcepackagerecipe.py (+13/-0)
lib/lp/code/model/sourcepackagerecipe.py (+2/-1)
lib/lp/code/model/tests/test_sourcepackagerecipe.py (+16/-0)
lib/lp/code/templates/branch-index.pt (+1/-1)
To merge this branch: bzr merge lp:~lifeless/launchpad/recipes
Reviewer Review Type Date Requested Status
Gavin Panella (community) 2010-11-04 Approve on 2010-11-04
Review via email: mp+40050@code.launchpad.net

Commit Message

Add a feature flag 'code.recipes_enabled'.

Description of the Change

Permit controlling build from branch via feature flags.

To post a comment you must log in.
Gavin Panella (allenap) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/browser/branch.py'
2--- lib/lp/code/browser/branch.py 2010-10-25 05:33:20 +0000
3+++ lib/lp/code/browser/branch.py 2010-11-04 06:44:20 +0000
4@@ -140,6 +140,7 @@
5 from lp.code.interfaces.branchnamespace import IBranchNamespacePolicy
6 from lp.code.interfaces.branchtarget import IBranchTarget
7 from lp.code.interfaces.codereviewvote import ICodeReviewVoteReference
8+from lp.code.interfaces.sourcepackagerecipe import recipes_enabled
9 from lp.registry.interfaces.person import (
10 IPerson,
11 IPersonSet,
12@@ -381,7 +382,7 @@
13 '+upgrade', 'Upgrade this branch', icon='edit', enabled=enabled)
14
15 def create_recipe(self):
16- if not self.context.private and config.build_from_branch.enabled:
17+ if not self.context.private and recipes_enabled():
18 enabled = True
19 else:
20 enabled = False
21
22=== modified file 'lib/lp/code/browser/sourcepackagerecipelisting.py'
23--- lib/lp/code/browser/sourcepackagerecipelisting.py 2010-08-23 02:07:45 +0000
24+++ lib/lp/code/browser/sourcepackagerecipelisting.py 2010-11-04 06:44:20 +0000
25@@ -20,6 +20,7 @@
26 Link,
27 )
28 from lp.code.interfaces.branch import IBranch
29+from lp.code.interfaces.sourcepackagerecipe import recipes_enabled
30 from lp.registry.interfaces.person import IPerson
31 from lp.registry.interfaces.product import IProduct
32
33@@ -32,7 +33,7 @@
34 enabled = False
35 if self.context.getRecipes().count():
36 enabled = True
37- if not config.build_from_branch.enabled:
38+ if not recipes_enabled():
39 enabled = False
40 return Link(
41 '+recipes', text, icon='info', enabled=enabled, site='code')
42
43=== modified file 'lib/lp/code/interfaces/sourcepackagerecipe.py'
44--- lib/lp/code/interfaces/sourcepackagerecipe.py 2010-09-08 15:29:51 +0000
45+++ lib/lp/code/interfaces/sourcepackagerecipe.py 2010-11-04 06:44:20 +0000
46@@ -14,6 +14,7 @@
47 'ISourcePackageRecipeData',
48 'ISourcePackageRecipeSource',
49 'MINIMAL_RECIPE_TEXT',
50+ 'recipes_enabled',
51 ]
52
53
54@@ -45,12 +46,14 @@
55 TextLine,
56 )
57
58+from canonical.config import config
59 from canonical.launchpad import _
60 from canonical.launchpad.validators.name import name_validator
61 from lp.code.interfaces.branch import IBranch
62 from lp.registry.interfaces.distroseries import IDistroSeries
63 from lp.registry.interfaces.pocket import PackagePublishingPocket
64 from lp.registry.interfaces.role import IHasOwner
65+from lp.services import features
66 from lp.services.fields import (
67 PersonChoice,
68 PublicPersonChoice,
69@@ -208,3 +211,13 @@
70
71 def exists(owner, name):
72 """Check to see if a recipe by the same name and owner exists."""
73+
74+
75+def recipes_enabled():
76+ """Return True if recipes are enabled."""
77+ # Features win:
78+ if features.getFeatureFlag(u'code.recipes_enabled'):
79+ return True
80+ if not config.build_from_branch.enabled:
81+ return False
82+ return True
83
84=== modified file 'lib/lp/code/model/sourcepackagerecipe.py'
85--- lib/lp/code/model/sourcepackagerecipe.py 2010-09-02 15:56:16 +0000
86+++ lib/lp/code/model/sourcepackagerecipe.py 2010-11-04 06:44:20 +0000
87@@ -46,6 +46,7 @@
88 ISourcePackageRecipe,
89 ISourcePackageRecipeData,
90 ISourcePackageRecipeSource,
91+ recipes_enabled,
92 )
93 from lp.code.interfaces.sourcepackagerecipebuild import (
94 ISourcePackageRecipeBuildSource,
95@@ -215,7 +216,7 @@
96 def requestBuild(self, archive, requester, distroseries, pocket,
97 manual=False):
98 """See `ISourcePackageRecipe`."""
99- if not config.build_from_branch.enabled:
100+ if not recipes_enabled():
101 raise ValueError('Source package recipe builds disabled.')
102 if not archive.is_ppa:
103 raise NonPPABuildRequest
104
105=== modified file 'lib/lp/code/model/tests/test_sourcepackagerecipe.py'
106--- lib/lp/code/model/tests/test_sourcepackagerecipe.py 2010-10-26 15:47:24 +0000
107+++ lib/lp/code/model/tests/test_sourcepackagerecipe.py 2010-11-04 06:44:20 +0000
108@@ -41,6 +41,7 @@
109 ISourcePackageRecipe,
110 ISourcePackageRecipeSource,
111 MINIMAL_RECIPE_TEXT,
112+ recipes_enabled,
113 )
114 from lp.code.interfaces.sourcepackagerecipebuild import (
115 ISourcePackageRecipeBuild,
116@@ -65,10 +66,12 @@
117 )
118 from lp.testing import (
119 ANONYMOUS,
120+ feature_flags,
121 launchpadlib_for,
122 login,
123 login_person,
124 person_logged_in,
125+ set_feature_flag,
126 TestCaseWithFactory,
127 ws_object,
128 )
129@@ -79,6 +82,10 @@
130
131 layer = DatabaseFunctionalLayer
132
133+ def setUp(self):
134+ super(TestSourcePackageRecipe, self).setUp()
135+ self.useContext(feature_flags())
136+
137 def test_implements_interface(self):
138 """SourcePackageRecipe implements ISourcePackageRecipe."""
139 recipe = self.factory.makeSourcePackageRecipe()
140@@ -347,6 +354,15 @@
141 ValueError, recipe.requestBuild, ppa, ppa.owner, distroseries,
142 PackagePublishingPocket.RELEASE)
143
144+ def test_recipes_enabled_config(self):
145+ self.pushConfig('build_from_branch', enabled=False)
146+ self.assertFalse(recipes_enabled())
147+
148+ def test_recipes_enabled_flag(self):
149+ self.pushConfig('build_from_branch', enabled=False)
150+ set_feature_flag(u'code.recipes_enabled', u'on')
151+ self.assertTrue(recipes_enabled())
152+
153 def test_requestBuildRejectsOverQuota(self):
154 """Build requests that exceed quota raise an exception."""
155 requester = self.factory.makePerson(name='requester')
156
157=== modified file 'lib/lp/code/templates/branch-index.pt'
158--- lib/lp/code/templates/branch-index.pt 2010-10-19 01:24:36 +0000
159+++ lib/lp/code/templates/branch-index.pt 2010-11-04 06:44:20 +0000
160@@ -111,7 +111,7 @@
161 replace="structure context/@@++branch-pending-merges" />
162 <tal:branch-recipes
163 replace="structure context/@@++branch-recipes"
164- condition="modules/canonical.config/config/build_from_branch/enabled"
165+ condition="modules/lp.code.interfaces.sourcepackagerecipe/recipes_enabled"
166 />
167 <tal:related-bugs-specs
168 replace="structure context/@@++branch-related-bugs-specs" />