Merge lp:~abentley/bzr-builder/lp-update into lp:~launchpad-pqm/bzr-builder/trunk

Proposed by Aaron Bentley
Status: Merged
Approved by: Paul Hummer
Approved revision: 67
Merged at revision: 67
Proposed branch: lp:~abentley/bzr-builder/lp-update
Merge into: lp:~launchpad-pqm/bzr-builder/trunk
Diff against target: 224 lines (+104/-33)
3 files modified
recipe.py (+56/-32)
setup.py (+1/-1)
tests/test_recipe.py (+47/-0)
To merge this branch: bzr merge lp:~abentley/bzr-builder/lp-update
Reviewer Review Type Date Requested Status
Paul Hummer (community) Approve
Review via email: mp+39372@code.launchpad.net

Description of the change

Update bzr-builder to tip (0.6)

To post a comment you must log in.
Revision history for this message
Paul Hummer (rockstar) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'recipe.py'
2--- recipe.py 2010-08-31 20:06:24 +0000
3+++ recipe.py 2010-10-26 14:05:01 +0000
4@@ -452,6 +452,8 @@
5 branch should be merged instead of nested.
6 """
7
8+ can_have_children = False
9+
10 def __init__(self, recipe_branch, nest_path=None):
11 self.recipe_branch = recipe_branch
12 self.nest_path = nest_path
13@@ -462,6 +464,15 @@
14 def as_tuple(self):
15 return (self.recipe_branch, self.nest_path)
16
17+ def _get_revid_part(self):
18+ if self.recipe_branch.revid is not None:
19+ revid_part = " revid:%s" % self.recipe_branch.revid
20+ elif self.recipe_branch.revspec is not None:
21+ revid_part = " %s" % self.recipe_branch.revspec
22+ else:
23+ revid_part = ""
24+ return revid_part
25+
26
27 class CommandInstruction(ChildBranch):
28
29@@ -474,6 +485,9 @@
30 if proc.returncode != 0:
31 raise CommandFailedError(self.nest_path)
32
33+ def as_text(self):
34+ return "%s %s" % (RUN_INSTRUCTION, self.nest_path)
35+
36
37 class MergeInstruction(ChildBranch):
38
39@@ -486,6 +500,12 @@
40 merge_branch(self.recipe_branch, tree_to, br_to,
41 possible_transports=possible_transports)
42
43+ def as_text(self):
44+ revid_part = self._get_revid_part()
45+ return "%s %s %s%s" % (
46+ MERGE_INSTRUCTION, self.recipe_branch.name,
47+ self.recipe_branch.url, revid_part)
48+
49
50 class NestPartInstruction(ChildBranch):
51
52@@ -498,14 +518,33 @@
53 nest_part_branch(self.recipe_branch, tree_to, br_to, self.subpath,
54 self.target_subdir)
55
56+ def as_text(self):
57+ revid_part = self._get_revid_part()
58+ if self.target_subdir is not None:
59+ target_revid_part = " %s%s" % (
60+ self.target_subdir, revid_part)
61+ else:
62+ target_revid_part = revid_part
63+ return "%s %s %s %s%s" % (
64+ NEST_PART_INSTRUCTION, self.recipe_branch.name,
65+ self.recipe_branch.url, self.subpath, target_revid_part)
66+
67
68 class NestInstruction(ChildBranch):
69
70+ can_have_children = True
71+
72 def apply(self, target_path, tree_to, br_to, possible_transports=None):
73 _build_inner_tree(self.recipe_branch,
74 target_path=os.path.join(target_path, self.nest_path),
75 possible_transports=possible_transports)
76
77+ def as_text(self):
78+ revid_part = self._get_revid_part()
79+ return "%s %s %s %s%s" % (
80+ NEST_INSTRUCTION, self.recipe_branch.name,
81+ self.recipe_branch.url, self.nest_path, revid_part)
82+
83
84 class RecipeBranch(object):
85 """A nested structure that represents a Recipe.
86@@ -680,35 +719,22 @@
87 def _add_child_branches_to_manifest(self, child_branches, indent_level):
88 manifest = ""
89 for instruction in child_branches:
90- child_branch = instruction.recipe_branch
91- nest_location = instruction.nest_path
92- if child_branch is None:
93- manifest += "%s%s %s\n" % (" " * indent_level, RUN_INSTRUCTION,
94- nest_location)
95- else:
96- if child_branch.revid is not None:
97- revid_part = " revid:%s" % child_branch.revid
98- elif child_branch.revspec is not None:
99- revid_part = " %s" % child_branch.revspec
100- else:
101- revid_part = ""
102- if nest_location is not None:
103- manifest += "%s%s %s %s %s%s\n" % \
104- (" " * indent_level, NEST_INSTRUCTION,
105- child_branch.name,
106- child_branch.url, nest_location,
107- revid_part)
108- manifest += self._add_child_branches_to_manifest(
109- child_branch.child_branches, indent_level+1)
110- else:
111- manifest += "%s%s %s %s%s\n" % \
112- (" " * indent_level, MERGE_INSTRUCTION,
113- child_branch.name,
114- child_branch.url, revid_part)
115+ manifest += "%s%s\n" % (
116+ " " * indent_level, instruction.as_text())
117+ if instruction.can_have_children:
118+ manifest += self._add_child_branches_to_manifest(
119+ instruction.recipe_branch.child_branches,
120+ indent_level+1)
121 return manifest
122
123
124 def __str__(self):
125+ return self.get_recipe_text(validate=True)
126+
127+ def list_branch_names(self):
128+ return self._list_child_names()
129+
130+ def get_recipe_text(self, validate=False):
131 manifest = "# bzr-builder format %s deb-version " % str(self.format)
132 # TODO: should we store the expanded version that was used?
133 manifest += "%s\n" % (self.deb_version,)
134@@ -720,15 +746,13 @@
135 manifest += "%s\n" % (self.url,)
136 manifest += self._add_child_branches_to_manifest(self.child_branches,
137 0)
138- # Sanity check.
139- # TODO: write a function that compares the result of this parse with
140- # the branch that we built it from.
141- RecipeParser(manifest).parse()
142+ if validate:
143+ # Sanity check.
144+ # TODO: write a function that compares the result of this parse with
145+ # the branch that we built it from.
146+ RecipeParser(manifest).parse()
147 return manifest
148
149- def list_branch_names(self):
150- return self._list_child_names()
151-
152
153 class RecipeParseError(errors.BzrError):
154 _fmt = "Error parsing %(filename)s:%(line)s:%(char)s: %(problem)s."
155
156=== modified file 'setup.py'
157--- setup.py 2010-08-16 20:08:01 +0000
158+++ setup.py 2010-10-26 14:05:01 +0000
159@@ -4,7 +4,7 @@
160
161 if __name__ == '__main__':
162 setup(name="bzr-builder",
163- version="0.4",
164+ version="0.6",
165 description="Turn a recipe in to a bzr branch",
166 author="James Westby",
167 author_email="james.westby@canonical.com",
168
169=== modified file 'tests/test_recipe.py'
170--- tests/test_recipe.py 2010-08-26 14:34:55 +0000
171+++ tests/test_recipe.py 2010-10-26 14:05:01 +0000
172@@ -1040,6 +1040,53 @@
173 " nest nested2 nested2_url nested2\n"
174 "merge merged merged_url\n", manifest)
175
176+ def test_get_recipe_text(self):
177+ base_branch = BaseRecipeBranch("base_url", "1", 0.1)
178+ base_branch.revid = "base_revid"
179+ manifest = base_branch.get_recipe_text()
180+ self.assertEqual("# bzr-builder format 0.1 deb-version 1\n"
181+ "base_url revid:base_revid\n", manifest)
182+
183+ def test_get_recipe_doesnt_raise_on_invalid_recipe(self):
184+ base_branch = BaseRecipeBranch("base_url", "1", 0.1)
185+ base_branch.revid = "base_revid"
186+ nested_branch1 = RecipeBranch("nested1", "nested1_url",
187+ revspec="tag:foo")
188+ base_branch.nest_branch(".", nested_branch1)
189+ manifest = base_branch.get_recipe_text()
190+ self.assertEqual("# bzr-builder format 0.1 deb-version 1\n"
191+ "base_url revid:base_revid\n"
192+ "nest nested1 nested1_url . tag:foo\n", manifest)
193+
194+ def test_get_recipe_text_validate_True(self):
195+ base_branch = BaseRecipeBranch("base_url", "1", 0.1)
196+ base_branch.revid = "base_revid"
197+ nested_branch1 = RecipeBranch("nested1", "nested1_url",
198+ revspec="tag:foo")
199+ base_branch.nest_branch(".", nested_branch1)
200+ self.assertRaises(RecipeParseError, base_branch.get_recipe_text,
201+ validate=True)
202+
203+ def test_str_validates(self):
204+ base_branch = BaseRecipeBranch("base_url", "1", 0.1)
205+ base_branch.revid = "base_revid"
206+ nested_branch1 = RecipeBranch("nested1", "nested1_url",
207+ revspec="tag:foo")
208+ base_branch.nest_branch(".", nested_branch1)
209+ self.assertRaises(RecipeParseError, str, base_branch)
210+
211+ def test_with_nest_part(self):
212+ base_branch = BaseRecipeBranch("base_url", "1", 0.1)
213+ base_branch.revid = "base_revid"
214+ nested_branch1 = RecipeBranch("nested1", "nested1_url",
215+ revspec="tag:foo")
216+ base_branch.nest_part_branch(nested_branch1, "foo", "bar")
217+ manifest = base_branch.get_recipe_text()
218+ self.assertEqual("# bzr-builder format 0.1 deb-version 1\n"
219+ "base_url revid:base_revid\n"
220+ "nest-part nested1 nested1_url foo bar tag:foo\n",
221+ manifest)
222+
223
224 class RecipeBranchTests(TestCaseInTempDir):
225

Subscribers

People subscribed via source and target branches