launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #01810
[Merge] lp:~lifeless/launchpad/recipes into lp:launchpad/devel
Robert Collins has proposed merging lp:~lifeless/launchpad/recipes into lp:launchpad/devel.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Permit controlling build from branch via feature flags.
--
https://code.launchpad.net/~lifeless/launchpad/recipes/+merge/40050
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~lifeless/launchpad/recipes into lp:launchpad/devel.
=== modified file 'lib/lp/code/browser/branch.py'
--- lib/lp/code/browser/branch.py 2010-10-25 05:33:20 +0000
+++ lib/lp/code/browser/branch.py 2010-11-04 06:43:52 +0000
@@ -140,6 +140,7 @@
from lp.code.interfaces.branchnamespace import IBranchNamespacePolicy
from lp.code.interfaces.branchtarget import IBranchTarget
from lp.code.interfaces.codereviewvote import ICodeReviewVoteReference
+from lp.code.interfaces.sourcepackagerecipe import recipes_enabled
from lp.registry.interfaces.person import (
IPerson,
IPersonSet,
@@ -381,7 +382,7 @@
'+upgrade', 'Upgrade this branch', icon='edit', enabled=enabled)
def create_recipe(self):
- if not self.context.private and config.build_from_branch.enabled:
+ if not self.context.private and recipes_enabled():
enabled = True
else:
enabled = False
=== modified file 'lib/lp/code/browser/sourcepackagerecipelisting.py'
--- lib/lp/code/browser/sourcepackagerecipelisting.py 2010-08-23 02:07:45 +0000
+++ lib/lp/code/browser/sourcepackagerecipelisting.py 2010-11-04 06:43:52 +0000
@@ -20,6 +20,7 @@
Link,
)
from lp.code.interfaces.branch import IBranch
+from lp.code.interfaces.sourcepackagerecipe import recipes_enabled
from lp.registry.interfaces.person import IPerson
from lp.registry.interfaces.product import IProduct
@@ -32,7 +33,7 @@
enabled = False
if self.context.getRecipes().count():
enabled = True
- if not config.build_from_branch.enabled:
+ if not recipes_enabled():
enabled = False
return Link(
'+recipes', text, icon='info', enabled=enabled, site='code')
=== modified file 'lib/lp/code/interfaces/sourcepackagerecipe.py'
--- lib/lp/code/interfaces/sourcepackagerecipe.py 2010-09-08 15:29:51 +0000
+++ lib/lp/code/interfaces/sourcepackagerecipe.py 2010-11-04 06:43:52 +0000
@@ -14,6 +14,7 @@
'ISourcePackageRecipeData',
'ISourcePackageRecipeSource',
'MINIMAL_RECIPE_TEXT',
+ 'recipes_enabled',
]
@@ -45,12 +46,14 @@
TextLine,
)
+from canonical.config import config
from canonical.launchpad import _
from canonical.launchpad.validators.name import name_validator
from lp.code.interfaces.branch import IBranch
from lp.registry.interfaces.distroseries import IDistroSeries
from lp.registry.interfaces.pocket import PackagePublishingPocket
from lp.registry.interfaces.role import IHasOwner
+from lp.services import features
from lp.services.fields import (
PersonChoice,
PublicPersonChoice,
@@ -208,3 +211,13 @@
def exists(owner, name):
"""Check to see if a recipe by the same name and owner exists."""
+
+
+def recipes_enabled():
+ """Return True if recipes are enabled."""
+ # Features win:
+ if features.getFeatureFlag(u'code.recipes_enabled'):
+ return True
+ if not config.build_from_branch.enabled:
+ return False
+ return True
=== modified file 'lib/lp/code/model/sourcepackagerecipe.py'
--- lib/lp/code/model/sourcepackagerecipe.py 2010-09-02 15:56:16 +0000
+++ lib/lp/code/model/sourcepackagerecipe.py 2010-11-04 06:43:52 +0000
@@ -46,6 +46,7 @@
ISourcePackageRecipe,
ISourcePackageRecipeData,
ISourcePackageRecipeSource,
+ recipes_enabled,
)
from lp.code.interfaces.sourcepackagerecipebuild import (
ISourcePackageRecipeBuildSource,
@@ -215,7 +216,7 @@
def requestBuild(self, archive, requester, distroseries, pocket,
manual=False):
"""See `ISourcePackageRecipe`."""
- if not config.build_from_branch.enabled:
+ if not recipes_enabled():
raise ValueError('Source package recipe builds disabled.')
if not archive.is_ppa:
raise NonPPABuildRequest
=== modified file 'lib/lp/code/model/tests/test_sourcepackagerecipe.py'
--- lib/lp/code/model/tests/test_sourcepackagerecipe.py 2010-10-26 15:47:24 +0000
+++ lib/lp/code/model/tests/test_sourcepackagerecipe.py 2010-11-04 06:43:52 +0000
@@ -41,6 +41,7 @@
ISourcePackageRecipe,
ISourcePackageRecipeSource,
MINIMAL_RECIPE_TEXT,
+ recipes_enabled,
)
from lp.code.interfaces.sourcepackagerecipebuild import (
ISourcePackageRecipeBuild,
@@ -65,10 +66,12 @@
)
from lp.testing import (
ANONYMOUS,
+ feature_flags,
launchpadlib_for,
login,
login_person,
person_logged_in,
+ set_feature_flag,
TestCaseWithFactory,
ws_object,
)
@@ -79,6 +82,10 @@
layer = DatabaseFunctionalLayer
+ def setUp(self):
+ super(TestSourcePackageRecipe, self).setUp()
+ self.useContext(feature_flags())
+
def test_implements_interface(self):
"""SourcePackageRecipe implements ISourcePackageRecipe."""
recipe = self.factory.makeSourcePackageRecipe()
@@ -347,6 +354,15 @@
ValueError, recipe.requestBuild, ppa, ppa.owner, distroseries,
PackagePublishingPocket.RELEASE)
+ def test_recipes_enabled_config(self):
+ self.pushConfig('build_from_branch', enabled=False)
+ self.assertFalse(recipes_enabled())
+
+ def test_recipes_enabled_flag(self):
+ self.pushConfig('build_from_branch', enabled=False)
+ set_feature_flag(u'code.recipes_enabled', u'on')
+ self.assertTrue(recipes_enabled())
+
def test_requestBuildRejectsOverQuota(self):
"""Build requests that exceed quota raise an exception."""
requester = self.factory.makePerson(name='requester')
=== modified file 'lib/lp/code/templates/branch-index.pt'
--- lib/lp/code/templates/branch-index.pt 2010-10-19 01:24:36 +0000
+++ lib/lp/code/templates/branch-index.pt 2010-11-04 06:43:52 +0000
@@ -111,7 +111,7 @@
replace="structure context/@@++branch-pending-merges" />
<tal:branch-recipes
replace="structure context/@@++branch-recipes"
- condition="modules/canonical.config/config/build_from_branch/enabled"
+ condition="modules/lp.code.interfaces.sourcepackagerecipe/recipes_enabled"
/>
<tal:related-bugs-specs
replace="structure context/@@++branch-related-bugs-specs" />
Follow ups