Merge lp:~jameinel/bzr-builddeb/no_revision_history into lp:bzr-builddeb

Proposed by John A Meinel
Status: Merged
Merged at revision: 640
Proposed branch: lp:~jameinel/bzr-builddeb/no_revision_history
Merge into: lp:bzr-builddeb
Diff against target: 382 lines (+87/-73)
3 files modified
tests/blackbox/test_import_dsc.py (+2/-2)
tests/test_import_dsc.py (+81/-67)
tests/test_merge_package.py (+4/-4)
To merge this branch: bzr merge lp:~jameinel/bzr-builddeb/no_revision_history
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+81149@code.launchpad.net

Commit message

Don't use Branch.revision_history() in the test suite. It is deprecated in bzr-2.5

Description of the change

This fixes bug #885690. We deprecated 'Branch.revision_history' in bzr-2.5 and that causes *lots* of test stipple for bzr-builddeb.

I tried to fix as many of them as possible to use branch.last_revision/last_revision_info/revno, as most of them just needed the tip, or were asserting the length of the history, etc.

For some of them, I did go ahead and use the test_fetch approach, copying the 'revision_history(branch)' helper and translating the calls as appropriate.

This should be mostly mechanical, but you may want to read some of it closely to make sure I didn't change the meaning of any tests.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

I also had a branch which fixed some of these but that I hadn't proposed for merging yet...

Anyway, yours is more thorough so let's merge that.

review: Approve
Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 11/03/2011 03:25 PM, Jelmer Vernooij wrote:
> Review: Approve
>
> I also had a branch which fixed some of these but that I hadn't
> proposed for merging yet...
>
> Anyway, yours is more thorough so let's merge that.

I can't commit directly. Can you land it?

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk6ysTcACgkQJdeBCYSNAAPQ+gCfaNz8bYQS5XyGTp/Wc+Hvxh9p
nQ0AoLwqGqttkV08vx+Yx2NK6Sf6kCs3
=vVoL
-----END PGP SIGNATURE-----

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/blackbox/test_import_dsc.py'
2--- tests/blackbox/test_import_dsc.py 2011-07-19 15:05:54 +0000
3+++ tests/blackbox/test_import_dsc.py 2011-11-03 14:13:25 +0000
4@@ -113,7 +113,7 @@
5 self.check_inventory_shape(tree.inventory, expected_shape)
6 finally:
7 tree.unlock()
8- self.assertEqual(len(tree.branch.revision_history()), 3)
9+ self.assertEqual(3, tree.branch.revno())
10
11 def test_import_dsc(self):
12 self.requireFeature(PristineTarFeature)
13@@ -130,7 +130,7 @@
14 self.check_inventory_shape(tree.inventory, expected_shape)
15 finally:
16 tree.unlock()
17- self.assertEqual(len(tree.branch.revision_history()), 2)
18+ self.assertEqual(2, tree.branch.revno())
19
20 def test_import_no_files(self):
21 self.make_branch_and_tree('.')
22
23=== modified file 'tests/test_import_dsc.py'
24--- tests/test_import_dsc.py 2011-10-13 18:05:08 +0000
25+++ tests/test_import_dsc.py 2011-11-03 14:13:25 +0000
26@@ -32,6 +32,7 @@
27 from debian_bundle import deb822
28
29 from bzrlib import (
30+ revision as _mod_revision,
31 tests,
32 )
33 try:
34@@ -45,6 +46,19 @@
35 SymlinkFeature,
36 )
37
38+## Copied from bzrlib.tests.test_fetch from bzr-2.5
39+def revision_history(branch):
40+ branch.lock_read()
41+ try:
42+ graph = branch.repository.get_graph()
43+ history = list(graph.iter_lefthand_ancestry(branch.last_revision(),
44+ [_mod_revision.NULL_REVISION]))
45+ finally:
46+ branch.unlock()
47+ history.reverse()
48+ return history
49+
50+
51 from bzrlib.plugins.builddeb.import_dsc import (
52 DistributionBranch,
53 DistributionBranchSet,
54@@ -794,11 +808,11 @@
55 version = self.import_a_tree()
56 tree = self.up_tree1
57 branch = tree.branch
58- rh = branch.revision_history()
59- self.assertEqual(len(rh), 1)
60+ revno, rev_id = branch.last_revision_info()
61+ self.assertEqual(revno, 1)
62 self.assertEqual(self.db1.pristine_upstream_source.version_as_revisions(
63- "package", version.upstream_version), {None: rh[0]})
64- rev = branch.repository.get_revision(rh[0])
65+ "package", version.upstream_version), {None: rev_id})
66+ rev = branch.repository.get_revision(rev_id)
67 self.assertEqual(rev.message,
68 "Import upstream version %s" % str(version.upstream_version))
69 self.assertEqual(rev.properties.get('deb-md5'), None)
70@@ -832,18 +846,18 @@
71 { None: [self.up_tree1.branch.last_revision()] }, [(None, None, None)])
72 tree = self.up_tree1
73 branch = tree.branch
74- rh = branch.revision_history()
75- self.assertEqual(len(rh), 2)
76+ revno, rev_id = branch.last_revision_info()
77+ self.assertEqual(revno, 2)
78 self.assertEqual(
79 self.db1.pristine_upstream_source.version_as_revisions(
80 "package", version2.upstream_version),
81- {None: rh[1]})
82- rev = branch.repository.get_revision(rh[1])
83+ {None: rev_id})
84+ rev = branch.repository.get_revision(rev_id)
85 self.assertEqual(rev.message,
86 "Import upstream version %s" % str(version2.upstream_version))
87 self.assertIs(rev.properties.get('deb-md5'), None)
88- rev_tree1 = branch.repository.revision_tree(rh[0])
89- rev_tree2 = branch.repository.revision_tree(rh[1])
90+ rev_tree1 = branch.repository.revision_tree(rev.parent_ids[0])
91+ rev_tree2 = branch.repository.revision_tree(rev_id)
92 changes = rev_tree2.changes_from(rev_tree1)
93 self.check_changes(changes, added=["NEWS"], removed=["COPYING"],
94 modified=["README"])
95@@ -866,11 +880,11 @@
96 upstream_tarballs=[(os.path.abspath(tar_path), None, self.fake_md5_1)])
97 tree = self.up_tree1
98 branch = tree.branch
99- rh = branch.revision_history()
100- self.assertEqual(len(rh), 1)
101+ revno, rev_id = branch.last_revision_info()
102+ self.assertEqual(revno, 1)
103 self.assertEqual(self.db1.pristine_upstream_source.version_as_revisions(
104- "package", version.upstream_version), {None: rh[0]})
105- rev = branch.repository.get_revision(rh[0])
106+ "package", version.upstream_version), {None: rev_id})
107+ rev = branch.repository.get_revision(rev_id)
108 self.assertEqual(rev.message,
109 "Import upstream version %s" % str(version.upstream_version))
110 self.assertEqual(rev.properties['deb-md5'], self.fake_md5_1)
111@@ -894,11 +908,11 @@
112 {}, upstream_tarballs=[(os.path.abspath(tar_path), None, self.fake_md5_1)])
113 tree = self.up_tree1
114 branch = tree.branch
115- rh = branch.revision_history()
116- self.assertEqual(len(rh), 1)
117+ revno, rev_id = branch.last_revision_info()
118+ self.assertEqual(revno, 1)
119 self.assertEqual(self.db1.pristine_upstream_source.version_as_revisions(
120- "package", version.upstream_version), {None: rh[0]})
121- rev = branch.repository.get_revision(rh[0])
122+ "package", version.upstream_version), {None: rev_id})
123+ rev = branch.repository.get_revision(rev_id)
124 self.assertEqual(rev.message,
125 "Import upstream version %s" % str(version.upstream_version))
126 self.assertEqual(rev.properties['deb-md5'], self.fake_md5_1)
127@@ -943,11 +957,11 @@
128 {}, upstream_tarballs=[(os.path.abspath(tar_path), None, self.fake_md5_1)])
129 tree = self.up_tree1
130 branch = tree.branch
131- rh = branch.revision_history()
132- self.assertEqual(len(rh), 1)
133+ revno, rev_id = branch.last_revision_info()
134+ self.assertEqual(revno, 1)
135 self.assertEqual(self.db1.pristine_upstream_source.version_as_revisions(
136- "package", version.upstream_version), {None: rh[0]})
137- rev = branch.repository.get_revision(rh[0])
138+ "package", version.upstream_version), {None: rev_id})
139+ rev = branch.repository.get_revision(rev_id)
140 self.assertEqual(rev.message,
141 "Import upstream version %s" % str(version.upstream_version))
142 self.assertEqual(rev.properties['deb-md5'], self.fake_md5_1)
143@@ -965,8 +979,8 @@
144 builder.new_version(version2)
145 builder.build()
146 self.db2.import_package(builder.dsc_name())
147- self.assertEqual(len(self.up_tree2.branch.revision_history()), 2)
148- self.assertEqual(len(self.tree2.branch.revision_history()), 3)
149+ self.assertEqual(self.up_tree2.branch.revno(), 2)
150+ self.assertEqual(self.tree2.branch.revno(), 3)
151
152 def test_import_package_init_upstream_from_other(self):
153 self.requireFeature(PristineTarFeature)
154@@ -980,8 +994,8 @@
155 builder.new_version(version2)
156 builder.build()
157 self.db1.import_package(builder.dsc_name())
158- self.assertEqual(len(self.up_tree1.branch.revision_history()), 1)
159- self.assertEqual(len(self.tree1.branch.revision_history()), 3)
160+ self.assertEqual(self.up_tree1.branch.revno(), 1)
161+ self.assertEqual(self.tree1.branch.revno(), 3)
162
163 def import_package_single(self):
164 version1 = Version("0.1-1")
165@@ -990,8 +1004,8 @@
166 builder.add_default_control()
167 builder.build()
168 self.db1.import_package(builder.dsc_name())
169- self.assertEqual(len(self.up_tree1.branch.revision_history()), 1)
170- self.assertEqual(len(self.tree1.branch.revision_history()), 2)
171+ self.assertEqual(self.up_tree1.branch.revno(), 1)
172+ self.assertEqual(self.tree1.branch.revno(), 2)
173
174 def test_import_package_double(self):
175 self.requireFeature(PristineTarFeature)
176@@ -1016,8 +1030,8 @@
177 builder.remove_debian_file("COPYING")
178 builder.build()
179 self.db1.import_package(builder.dsc_name())
180- rh = self.tree1.branch.revision_history()
181- up_rh = self.up_tree1.branch.revision_history()
182+ rh = revision_history(self.tree1.branch)
183+ up_rh = revision_history(self.up_tree1.branch)
184 self.assertEqual(len(up_rh), 2)
185 self.assertEqual(len(rh), 3)
186 self.assertEqual(rh[0], up_rh[0])
187@@ -1069,10 +1083,10 @@
188 builder.add_default_control()
189 builder.build()
190 self.db1.import_package(builder.dsc_name())
191- rh1 = self.tree1.branch.revision_history()
192- rh2 = self.tree2.branch.revision_history()
193- up_rh1 = self.up_tree1.branch.revision_history()
194- up_rh2 = self.up_tree2.branch.revision_history()
195+ rh1 = revision_history(self.tree1.branch)
196+ rh2 = revision_history(self.tree2.branch)
197+ up_rh1 = revision_history(self.up_tree1.branch)
198+ up_rh2 = revision_history(self.up_tree2.branch)
199 self.assertEqual(len(rh1), 2)
200 self.assertEqual(len(rh2), 2)
201 self.assertEqual(len(up_rh1), 1)
202@@ -1118,10 +1132,10 @@
203 builder.build()
204 self.db1.import_package(builder.dsc_name())
205 self.db2.import_package(builder.dsc_name())
206- rh1 = self.tree1.branch.revision_history()
207- rh2 = self.tree2.branch.revision_history()
208- up_rh1 = self.up_tree1.branch.revision_history()
209- up_rh2 = self.up_tree2.branch.revision_history()
210+ rh1 = revision_history(self.tree1.branch)
211+ rh2 = revision_history(self.tree2.branch)
212+ up_rh1 = revision_history(self.up_tree1.branch)
213+ up_rh2 = revision_history(self.up_tree2.branch)
214 self.assertEqual(len(rh1), 3)
215 self.assertEqual(len(rh2), 4)
216 self.assertEqual(len(up_rh1), 2)
217@@ -1161,10 +1175,10 @@
218 builder.build()
219 self.db1.import_package(builder.dsc_name())
220 self.db2.import_package(builder.dsc_name())
221- self.assertEqual(3, len(self.tree1.branch.revision_history()))
222- self.assertEqual(2, len(self.up_tree1.branch.revision_history()))
223- self.assertEqual(3, len(self.tree2.branch.revision_history()))
224- self.assertEqual(2, len(self.up_tree2.branch.revision_history()))
225+ self.assertEqual(3, self.tree1.branch.revno())
226+ self.assertEqual(2, self.up_tree1.branch.revno())
227+ self.assertEqual(3, self.tree2.branch.revno())
228+ self.assertEqual(2, self.up_tree2.branch.revno())
229 self.assertEqual(self.tree1.last_revision(),
230 self.tree2.last_revision())
231 self.assertEqual(self.up_tree1.last_revision(),
232@@ -1188,14 +1202,14 @@
233 builder.add_default_control()
234 builder.build()
235 self.db1.import_package(builder.dsc_name())
236- rh1 = self.tree1.branch.revision_history()
237- up_rh1 = self.up_tree1.branch.revision_history()
238- self.assertEqual(len(rh1), 1)
239- self.assertEqual(len(up_rh1), 0)
240+ revno1, rev_id1 = self.tree1.branch.last_revision_info()
241+ up_revno1, up_rev_id1 = self.up_tree1.branch.last_revision_info()
242+ self.assertEqual(revno1, 1)
243+ self.assertEqual(up_revno1, 0)
244 self.tree1.lock_read()
245 self.addCleanup(self.tree1.unlock)
246 self.assertTrue(self.db1.is_version_native(version))
247- revtree = self.tree1.branch.repository.revision_tree(rh1[0])
248+ revtree = self.tree1.branch.repository.revision_tree(rev_id1)
249 config_fileid, current_config = self.db1._default_config_for_tree(revtree)
250 self.assertTrue(self.db1._is_tree_native(current_config))
251
252@@ -1214,8 +1228,8 @@
253 builder.add_debian_file("NEWS")
254 builder.build()
255 self.db1.import_package(builder.dsc_name())
256- rh1 = self.tree1.branch.revision_history()
257- up_rh1 = self.up_tree1.branch.revision_history()
258+ rh1 = revision_history(self.tree1.branch)
259+ up_rh1 = revision_history(self.up_tree1.branch)
260 self.assertEqual(len(rh1), 2)
261 self.assertEqual(len(up_rh1), 0)
262 rev_tree1 = self.tree1.branch.repository.revision_tree(rh1[0])
263@@ -1245,8 +1259,8 @@
264 builder.add_upstream_file("README", "bar")
265 builder.build()
266 self.db1.import_package(builder.dsc_name())
267- rh1 = self.tree1.branch.revision_history()
268- up_rh1 = self.up_tree1.branch.revision_history()
269+ rh1 = revision_history(self.tree1.branch)
270+ up_rh1 = revision_history(self.up_tree1.branch)
271 self.assertEqual(len(rh1), 2)
272 self.assertEqual(len(up_rh1), 0)
273 rev_tree1 = self.tree1.branch.repository.revision_tree(rh1[0])
274@@ -1280,8 +1294,8 @@
275 builder.add_upstream_file("NEWS")
276 builder.build()
277 self.db1.import_package(builder.dsc_name())
278- rh1 = self.tree1.branch.revision_history()
279- up_rh1 = self.up_tree1.branch.revision_history()
280+ rh1 = revision_history(self.tree1.branch)
281+ up_rh1 = revision_history(self.up_tree1.branch)
282 self.assertEqual(len(rh1), 3)
283 self.assertEqual(len(up_rh1), 1)
284 rev_tree1 = self.tree1.branch.repository.revision_tree(rh1[1])
285@@ -1316,8 +1330,8 @@
286 builder.add_upstream_file("NEWS")
287 builder.build()
288 self.db1.import_package(builder.dsc_name())
289- rh1 = self.tree1.branch.revision_history()
290- up_rh1 = self.up_tree1.branch.revision_history()
291+ rh1 = revision_history(self.tree1.branch)
292+ up_rh1 = revision_history(self.up_tree1.branch)
293 self.assertEqual(len(rh1), 2)
294 self.assertEqual(len(up_rh1), 2)
295 rev_tree1 = self.tree1.branch.repository.revision_tree(rh1[0])
296@@ -1369,8 +1383,8 @@
297 builder.new_version(version3)
298 builder.build()
299 self.db1.import_package(builder.dsc_name())
300- rh1 = self.tree1.branch.revision_history()
301- up_rh1 = self.up_tree1.branch.revision_history()
302+ rh1 = revision_history(self.tree1.branch)
303+ up_rh1 = revision_history(self.up_tree1.branch)
304 self.assertEqual(len(rh1), 4)
305 self.assertEqual(len(up_rh1), 1)
306 rev_tree1 = self.tree1.branch.repository.revision_tree(rh1[1])
307@@ -1418,8 +1432,8 @@
308 builder.new_version(version3)
309 builder.build()
310 self.db1.import_package(builder.dsc_name())
311- rh1 = self.tree1.branch.revision_history()
312- up_rh1 = self.up_tree1.branch.revision_history()
313+ rh1 = revision_history(self.tree1.branch)
314+ up_rh1 = revision_history(self.up_tree1.branch)
315 self.assertEqual(len(rh1), 4)
316 self.assertEqual(len(up_rh1), 2)
317 rev_tree1 = self.tree1.branch.repository.revision_tree(rh1[1])
318@@ -1475,8 +1489,8 @@
319 builder.new_version(version3)
320 builder.build()
321 self.db1.import_package(builder.dsc_name())
322- rh1 = self.tree1.branch.revision_history()
323- up_rh1 = self.up_tree1.branch.revision_history()
324+ rh1 = revision_history(self.tree1.branch)
325+ up_rh1 = revision_history(self.up_tree1.branch)
326 self.assertEqual(len(rh1), 4)
327 self.assertEqual(len(up_rh1), 2)
328 rev_tree1 = self.tree1.branch.repository.revision_tree(rh1[1])
329@@ -1528,10 +1542,10 @@
330 builder.build()
331 self.db1.import_package(builder.dsc_name())
332 self.db2.import_package(builder.dsc_name())
333- rh1 = self.tree1.branch.revision_history()
334- up_rh1 = self.up_tree1.branch.revision_history()
335- rh2 = self.tree2.branch.revision_history()
336- up_rh2 = self.up_tree2.branch.revision_history()
337+ rh1 = revision_history(self.tree1.branch)
338+ up_rh1 = revision_history(self.up_tree1.branch)
339+ rh2 = revision_history(self.tree2.branch)
340+ up_rh2 = revision_history(self.up_tree2.branch)
341 self.assertEqual(3, len(rh1))
342 self.assertEqual(2, len(up_rh1))
343 self.assertEqual(4, len(rh2))
344@@ -1694,8 +1708,8 @@
345 version1.upstream_version,
346 upstream_branch=upstream_tree.branch,
347 upstream_revisions={None: upstream_rev})
348- rh1 = tree.branch.revision_history()
349- self.assertEqual(2, len(rh1))
350+ revno1, rev_id1 = tree.branch.last_revision_info()
351+ self.assertEqual(2, revno1)
352 packaging_upstream_tip = tree.get_parent_ids()[1]
353 # We added the extra parent for the upstream branch
354 revtree = tree.branch.repository.revision_tree(packaging_upstream_tip)
355
356=== modified file 'tests/test_merge_package.py'
357--- tests/test_merge_package.py 2011-06-26 21:18:23 +0000
358+++ tests/test_merge_package.py 2011-11-03 14:13:25 +0000
359@@ -126,11 +126,11 @@
360 self.assertEqual(db1.pristine_upstream_source.has_version("package", v4), False)
361
362 # The ubuntu upstream branch tip.
363- ubuu_tip = ubuu.branch.revision_history()[-1]
364+ ubuu_tip = ubuu.branch.last_revision()
365 # The debian upstream branch tip.
366- debu_tip = debu.branch.revision_history()[-1]
367+ debu_tip = debu.branch.last_revision()
368 # The ubuntu packaging branch tip.
369- ubup_tip_pre_fix = ubup.branch.revision_history()[-1]
370+ ubup_tip_pre_fix = ubup.branch.last_revision()
371
372 # The first conflict is resolved by calling fix_ancestry_as_needed().
373 upstreams_diverged, t_upstream_reverted = MP.fix_ancestry_as_needed(ubup, debp.branch)
374@@ -150,7 +150,7 @@
375 self.assertEqual(db2.pristine_upstream_source.has_version("package", v4), True)
376
377 # Now let's take a look at the fixed ubuntu packaging branch.
378- ubup_tip_post_fix = ubup.branch.revision_history()[-1]
379+ ubup_tip_post_fix = ubup.branch.last_revision()
380 ubup_parents_post_fix = ubup.branch.repository.revision_tree(ubup_tip_post_fix).get_parent_ids()
381
382 # The tip of the fixed ubuntu packaging branch has 2 parents.

Subscribers

People subscribed via source and target branches