Paul Hummer has proposed merging lp:~rockstar/launchpad/recipe-too-new into 
lp:launchpad/devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  #645403 TooNewRecipeFormat raised editing a recipe
  https://bugs.launchpad.net/bugs/645403


This branch fixes an issue where users try to use a recipe format that we don't 
yet support.  In this case, we have bzr-builder in source code, but Aaron can't 
land the support until the buildds have the newer bzr-builder.

I talked this over with Aaron, and we decided to monkey patch the actual 
NEWEST_VERSION in bzr-builder to a recipe format version we're never going to 
have (in this case, it's also the frequency of my local HAM radio repeater).  
This way, we won't have erroneous test failures when we actually add support 
for 0.3 formatted recipes.

While talking this over with Aaron, I found another potential place where this 
may occur in tests, and fixed that test as well.
-- 
https://code.launchpad.net/~rockstar/launchpad/recipe-too-new/+merge/36379
Your team Launchpad code reviewers is requested to review the proposed merge of 
lp:~rockstar/launchpad/recipe-too-new into lp:launchpad/devel.
=== modified file 'lib/lp/code/browser/sourcepackagerecipe.py'
--- lib/lp/code/browser/sourcepackagerecipe.py	2010-09-02 14:28:57 +0000
+++ lib/lp/code/browser/sourcepackagerecipe.py	2010-09-22 20:37:43 +0000
@@ -60,6 +60,7 @@
     BuildAlreadyPending,
     NoSuchBranch,
     PrivateBranchRecipe,
+    TooNewRecipeFormat
     )
 from lp.code.interfaces.sourcepackagerecipe import (
     ISourcePackageRecipe,
@@ -333,6 +334,11 @@
                     data['recipe_text'], data['description'], data['distros'],
                     data['daily_build_archive'], data['build_daily'])
             Store.of(source_package_recipe).flush()
+        except TooNewRecipeFormat:
+            self.setFieldError(
+                'recipe_text',
+                'The recipe format version specified is not available.')
+            return
         except ForbiddenInstructionError:
             # XXX: bug=592513 We shouldn't be hardcoding "run" here.
             self.setFieldError(

=== modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipe.py'
--- lib/lp/code/browser/tests/test_sourcepackagerecipe.py	2010-09-20 19:12:35 +0000
+++ lib/lp/code/browser/tests/test_sourcepackagerecipe.py	2010-09-22 20:37:43 +0000
@@ -304,6 +304,30 @@
         self.assertEqual(
             get_message_text(browser, 2), 'foo is not a branch on Launchpad.')
 
+    def test_create_recipe_format_too_new(self):
+        # If the recipe's format version is too new, we should notify the
+        # user.
+        product = self.factory.makeProduct(
+            name='ratatouille', displayname='Ratatouille')
+        branch = self.factory.makeBranch(
+            owner=self.chef, product=product, name='veggies')
+
+        # We need to monkeypath RecipeParser.NEWEST_VERSION
+        from bzrlib.plugins.builder.recipe import RecipeParser
+        old_version = RecipeParser.NEWEST_VERSION
+        RecipeParser.NEWEST_VERSION = 145.115
+
+        recipe = dedent(u'''\
+            # bzr-builder format 145.115 deb-version 0+{revno}
+            %s
+            ''') % branch.bzr_identity
+        browser = self.createRecipe(recipe, branch)
+        self.assertEqual(
+            get_message_text(browser, 2),
+            'The recipe format version specified is not available.')
+
+        RecipeParser.NEWEST_VERSION = old_version
+
     def test_create_dupe_recipe(self):
         # You shouldn't be able to create a duplicate recipe owned by the same
         # person with the same name.

=== modified file 'lib/lp/code/model/tests/test_sourcepackagerecipe.py'
--- lib/lp/code/model/tests/test_sourcepackagerecipe.py	2010-09-21 19:02:44 +0000
+++ lib/lp/code/model/tests/test_sourcepackagerecipe.py	2010-09-22 20:37:43 +0000
@@ -246,12 +246,19 @@
             old_branches, list(sp_recipe.getReferencedBranches()))
 
     def test_reject_newer_formats(self):
+        # We need to monkeypath RecipeParser.NEWEST_VERSION
+        from bzrlib.plugins.builder.recipe import RecipeParser
+        old_version = RecipeParser.NEWEST_VERSION
+        RecipeParser.NEWEST_VERSION = 145.115
+
         builder_recipe = self.factory.makeRecipe()
-        builder_recipe.format = 0.3
+        builder_recipe.format = 145.115
         self.assertRaises(
             TooNewRecipeFormat,
             self.factory.makeSourcePackageRecipe, recipe=str(builder_recipe))
 
+        RecipeParser.NEWEST_VERSION = old_version
+
     def test_requestBuild(self):
         recipe = self.factory.makeSourcePackageRecipe()
         (distroseries,) = list(recipe.distroseries)

_______________________________________________
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp

Reply via email to