Bazaar Version Control System

Merge lp:~gz/bzr/dev_2.5_integration into lp:bzr

Proposed by Martin Packman on 2012-02-27
Status: Merged
Approved by: Martin Packman on 2012-02-27
Approved revision: no longer in the source branch.
Merged at revision: 6477
Proposed branch: lp:~gz/bzr/dev_2.5_integration
Merge into: lp:bzr
Diff against target: 144 lines (+24/-13) 3 files modified
To merge this branch: bzr merge lp:~gz/bzr/dev_2.5_integration
Reviewer Review Type Date Requested Status
bzr-core 2012-02-27 Pending
Review via email: mp+94781@code.launchpad.net

Commit Message

Merge 2.5 for fixes to texinfo doc script and btree tests

To post a comment you must log in.
Martin Packman (gz) wrote :

sent to pqm by email

lp:~gz/bzr/dev_2.5_integration updated on 2012-02-27
6477. By Patch Queue Manager <email address hidden> on 2012-02-27

(gz) Merge 2.5 for fixes to texinfo doc script and btree tests (Martin
 Packman)

Preview Diff

1=== modified file 'bzrlib/doc_generate/builders/texinfo.py'
2--- bzrlib/doc_generate/builders/texinfo.py 2012-02-24 10:07:50 +0000
3+++ bzrlib/doc_generate/builders/texinfo.py 2012-02-27 14:53:55 +0000
4@@ -41,5 +41,4 @@
5
6
7 def setup(app):
8- import pdb; pdb.set_trace()
9 app.add_builder(TexinfoBuilder)
10
11=== modified file 'bzrlib/tests/test_btree_index.py'
12--- bzrlib/tests/test_btree_index.py 2011-11-16 20:59:10 +0000
13+++ bzrlib/tests/test_btree_index.py 2012-02-27 14:53:55 +0000
14@@ -103,6 +103,16 @@
15 self.overrideAttr(btree_index, '_PAGE_SIZE')
16 btree_index._PAGE_SIZE = 2048
17
18+ def assertEqualsApproxCompressed(self, expected, actual, slop=6):
19+ """Check a count of compressed bytes is approximately as expected
20+
21+ Relying on compressed length being stable even with fixed inputs is
22+ slightly bogus, but zlib is stable enough that this mostly works.
23+ """
24+ if not expected - slop < actual < expected + slop:
25+ self.fail("Expected around %d bytes compressed but got %d" %
26+ (expected, actual))
27+
28
29 class TestBTreeBuilder(BTreeTestCase):
30
31@@ -199,7 +209,7 @@
32 temp_file = builder.finish()
33 content = temp_file.read()
34 del temp_file
35- self.assertEqual(9283, len(content))
36+ self.assertEqualsApproxCompressed(9283, len(content))
37 self.assertEqual(
38 "B+Tree Graph Index 2\nnode_ref_lists=0\nkey_elements=1\nlen=400\n"
39 "row_lengths=1,2\n",
40@@ -233,7 +243,7 @@
41 temp_file = builder.finish()
42 content = temp_file.read()
43 del temp_file
44- self.assertEqual(155, len(content))
45+ self.assertEqualsApproxCompressed(155, len(content))
46 self.assertEqual(
47 "B+Tree Graph Index 2\nnode_ref_lists=0\nkey_elements=1\nlen=10\n"
48 "row_lengths=1\n",
49@@ -255,7 +265,7 @@
50 temp_file = builder.finish()
51 content = temp_file.read()
52 del temp_file
53- self.assertEqual(9283, len(content))
54+ self.assertEqualsApproxCompressed(9283, len(content))
55 self.assertEqual(
56 "B+Tree Graph Index 2\nnode_ref_lists=0\nkey_elements=1\nlen=400\n"
57 "row_lengths=1,2\n",
58@@ -314,7 +324,7 @@
59 temp_file = builder.finish()
60 content = temp_file.read()
61 del temp_file
62- self.assertEqual(12643, len(content))
63+ self.assertEqualsApproxCompressed(12643, len(content))
64 self.assertEqual(
65 "B+Tree Graph Index 2\nnode_ref_lists=2\nkey_elements=2\nlen=200\n"
66 "row_lengths=1,3\n",
67@@ -700,7 +710,7 @@
68 # The entire index should have been read, as it is one page long.
69 self.assertEqual([('readv', 'index', [(0, size)], False, None)],
70 t._activity)
71- self.assertEqual(1173, size)
72+ self.assertEqualsApproxCompressed(1173, size)
73
74 def test_with_offset_no_size(self):
75 index = self.make_index_with_offset(key_elements=1, ref_lists=1,
76@@ -750,7 +760,7 @@
77 builder.add_node(*node)
78 t = transport.get_transport_from_url('trace+' + self.get_url(''))
79 size = t.put_file('index', builder.finish())
80- self.assertEqual(17692, size)
81+ self.assertEqualsApproxCompressed(17692, size)
82 index = btree_index.BTreeGraphIndex(t, 'index', size)
83 del t._activity[:]
84 self.assertEqual([], t._activity)
85@@ -773,7 +783,7 @@
86 # The entire index should have been read linearly.
87 self.assertEqual([('readv', 'index', [(0, size)], False, None)],
88 t._activity)
89- self.assertEqual(1488, size)
90+ self.assertEqualsApproxCompressed(1488, size)
91
92 def test_validate_two_pages(self):
93 builder = btree_index.BTreeBuilder(key_elements=2, reference_lists=2)
94@@ -783,15 +793,16 @@
95 t = transport.get_transport_from_url('trace+' + self.get_url(''))
96 size = t.put_file('index', builder.finish())
97 # Root page, 2 leaf pages
98- self.assertEqual(9339, size)
99+ self.assertEqualsApproxCompressed(9339, size)
100 index = btree_index.BTreeGraphIndex(t, 'index', size)
101 del t._activity[:]
102 self.assertEqual([], t._activity)
103 index.validate()
104+ rem = size - 8192 # Number of remaining bytes after second block
105 # The entire index should have been read linearly.
106 self.assertEqual(
107 [('readv', 'index', [(0, 4096)], False, None),
108- ('readv', 'index', [(4096, 4096), (8192, 1147)], False, None)],
109+ ('readv', 'index', [(4096, 4096), (8192, rem)], False, None)],
110 t._activity)
111 # XXX: TODO: write some badly-ordered nodes, and some pointers-to-wrong
112 # node and make validate find them.
113@@ -860,8 +871,6 @@
114 builder.add_node(*node)
115 t = transport.get_transport_from_url('trace+' + self.get_url(''))
116 size = t.put_file('index', builder.finish())
117- self.assertEqual(1303220, size, 'number of expected bytes in the'
118- ' output changed')
119 page_size = btree_index._PAGE_SIZE
120 del builder
121 index = btree_index.BTreeGraphIndex(t, 'index', size)
122@@ -883,7 +892,7 @@
123 # The entire index should have been read
124 total_pages = sum(index._row_lengths)
125 self.assertEqual(total_pages, index._row_offsets[-1])
126- self.assertEqual(1303220, size)
127+ self.assertEqualsApproxCompressed(1303220, size)
128 # The start of the leaves
129 first_byte = index._row_offsets[-2] * page_size
130 readv_request = []
131
132=== modified file 'doc/en/release-notes/bzr-2.4.txt'
133--- doc/en/release-notes/bzr-2.4.txt 2011-12-05 14:21:55 +0000
134+++ doc/en/release-notes/bzr-2.4.txt 2012-02-27 14:53:55 +0000
135@@ -79,6 +79,9 @@
136 suite. This can include new facilities for writing tests, fixes to
137 spurious test failures and changes to the way things should be tested.
138
139+* Account for slightly improved compression with newer versions of zlib in
140+ ``bt.test_btree_index`` tests. (Martin Packman, #940453)
141+
142
143 bzr 2.4.2
144 #########