Merge lp:~jelmer/brz/python3-fix-index into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/python3-fix-index
Merge into: lp:brz
Diff against target: 195 lines (+25/-19)
3 files modified
breezy/bzr/index.py (+4/-3)
breezy/tests/test_index.py (+12/-12)
python3.passing (+9/-4)
To merge this branch: bzr merge lp:~jelmer/brz/python3-fix-index
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+353379@code.launchpad.net

Commit message

Fix the last few failing index tests on Python 3.

Description of the change

Fix the last few failing index tests on Python 3.

This requires using "()" rather than None, since comparing the latter to tuples of bytes fails when running bisect.bisect_right.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Looks good, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/bzr/index.py'
2--- breezy/bzr/index.py 2018-06-30 16:14:04 +0000
3+++ breezy/bzr/index.py 2018-08-20 01:35:26 +0000
4@@ -664,7 +664,8 @@
5 node_refs.append(tuple([self._keys_by_offset[ref][0] for ref in ref_list]))
6 return tuple(node_refs)
7
8- def _find_index(self, range_map, key):
9+ @staticmethod
10+ def _find_index(range_map, key):
11 """Helper for the _parsed_*_index calls.
12
13 Given a range map - [(start, end), ...], finds the index of the range
14@@ -702,7 +703,7 @@
15 asking for 'b' will return 1
16 asking for 'e' will return 1
17 """
18- search_key = (key, None)
19+ search_key = (key, b'')
20 return self._find_index(self._parsed_key_map, search_key)
21
22 def _is_parsed(self, offset):
23@@ -1000,7 +1001,7 @@
24 # calculate the bytes we have processed
25 header_end = (len(signature) + len(lines[0]) + len(lines[1]) +
26 len(lines[2]) + 3)
27- self._parsed_bytes(0, None, header_end, None)
28+ self._parsed_bytes(0, (), header_end, ())
29 # setup parsing state
30 self._expected_elements = 3 + self._key_length
31 # raw data keyed by offset
32
33=== modified file 'breezy/tests/test_index.py'
34--- breezy/tests/test_index.py 2018-08-04 13:00:08 +0000
35+++ breezy/tests/test_index.py 2018-08-20 01:35:26 +0000
36@@ -310,7 +310,7 @@
37 self.assertRaises(_mod_index.BadIndexKey, builder.add_node,
38 (b'a%skey' % int2byte(bad_char), ), b'data')
39 self.assertRaises(_mod_index.BadIndexKey, builder.add_node,
40- (b'', ), b'data')
41+ (), b'data')
42 self.assertRaises(_mod_index.BadIndexKey, builder.add_node,
43 b'not-a-tuple', b'data')
44 # not enough length
45@@ -544,7 +544,7 @@
46 # And the regions of the file that have been parsed should be in the
47 # parsed_byte_map and the parsed_key_map
48 self.assertEqual([(0, 4008), (5046, 8996)], index._parsed_byte_map)
49- self.assertEqual([(None, self.make_key(26)),
50+ self.assertEqual([((), self.make_key(26)),
51 (self.make_key(31), self.make_key(48))],
52 index._parsed_key_map)
53
54@@ -560,7 +560,7 @@
55 # and we should have a parse map that includes the header and the
56 # region that was parsed after trimming.
57 self.assertEqual([(0, 4008), (5046, 8996)], index._parsed_byte_map)
58- self.assertEqual([(None, self.make_key(26)),
59+ self.assertEqual([((), self.make_key(26)),
60 (self.make_key(31), self.make_key(48))],
61 index._parsed_key_map)
62
63@@ -584,7 +584,7 @@
64 # and we should have a parse map that includes the header and the
65 # region that was parsed after trimming.
66 self.assertEqual([(0, 4045), (11759, 15707)], index._parsed_byte_map)
67- self.assertEqual([(None, self.make_key(116)),
68+ self.assertEqual([((), self.make_key(116)),
69 (self.make_key(35), self.make_key(51))],
70 index._parsed_key_map)
71 # now ask for two keys, right before and after the parsed region
72@@ -608,7 +608,7 @@
73 [(index._size // 2, (b'40', ))])
74 # check the parse map, this determines the test validity
75 self.assertEqual([(0, 4008), (5046, 8996)], index._parsed_byte_map)
76- self.assertEqual([(None, self.make_key(26)),
77+ self.assertEqual([((), self.make_key(26)),
78 (self.make_key(31), self.make_key(48))],
79 index._parsed_key_map)
80 # reset the transport log
81@@ -632,7 +632,7 @@
82 [(index._size // 2, (b'40', ))])
83 # check the parse map, this determines the test validity
84 self.assertEqual([(0, 4008), (5046, 8996)], index._parsed_byte_map)
85- self.assertEqual([(None, self.make_key(26)),
86+ self.assertEqual([((), self.make_key(26)),
87 (self.make_key(31), self.make_key(48))],
88 index._parsed_key_map)
89 # reset the transport log
90@@ -659,10 +659,10 @@
91 [(index._size // 2, (b'30', ))])
92 # check the parse map, this determines the test validity
93 self.assertEqual([(0, 4008), (5046, 8996)], index._parsed_byte_map)
94- self.assertEqual([(None, self.make_key(26)),
95+ self.assertEqual([((), self.make_key(26)),
96 (self.make_key(31), self.make_key(48))],
97 index._parsed_key_map)
98- self.assertEqual([((index._size // 2, ('30', )), -1)],
99+ self.assertEqual([((index._size // 2, (b'30', )), -1)],
100 result)
101
102 def test_lookup_key_above_probed_area(self):
103@@ -675,7 +675,7 @@
104 [(index._size // 2, (b'50', ))])
105 # check the parse map, this determines the test validity
106 self.assertEqual([(0, 4008), (5046, 8996)], index._parsed_byte_map)
107- self.assertEqual([(None, self.make_key(26)),
108+ self.assertEqual([((), self.make_key(26)),
109 (self.make_key(31), self.make_key(48))],
110 index._parsed_key_map)
111 self.assertEqual([((index._size // 2, (b'50', )), +1)],
112@@ -698,7 +698,7 @@
113 # check the parse map - only the start and middle should have been
114 # parsed.
115 self.assertEqual([(0, 4027), (10198, 14028)], index._parsed_byte_map)
116- self.assertEqual([(None, self.make_key(17)),
117+ self.assertEqual([((), self.make_key(17)),
118 (self.make_key(44), self.make_key(5))],
119 index._parsed_key_map)
120 # and check the transport activity likewise.
121@@ -733,7 +733,7 @@
122 # check the parse map - only the start and middle should have been
123 # parsed.
124 self.assertEqual([(0, 3890), (6444, 10274)], index._parsed_byte_map)
125- self.assertEqual([(None, self.make_key(25)),
126+ self.assertEqual([((), self.make_key(25)),
127 (self.make_key(37), self.make_key(52))],
128 index._parsed_key_map)
129 # and check the transport activity likewise.
130@@ -1463,7 +1463,7 @@
131 index2_1, index2_2 = cgi2._indices
132 cgi1.set_sibling_indices([cgi2])
133 # Trigger a reordering in cgi1. cgi2 will be reordered as well.
134- list(cgi1.iter_entries([('index-1-2-key-1',)]))
135+ list(cgi1.iter_entries([(b'index-1-2-key-1',)]))
136 self.assertEqual([index2_2, index2_1], cgi2._indices)
137 self.assertEqual(['two', 'one'], cgi2._index_names)
138
139
140=== modified file 'python3.passing'
141--- python3.passing 2018-08-08 02:10:06 +0000
142+++ python3.passing 2018-08-20 01:35:26 +0000
143@@ -9130,16 +9130,16 @@
144 breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RemoteRepositoryFormat-v2)
145 breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormat2a)
146 breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormat2aSubtree)
147-breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RemoteRepositoryFormat-default)
148-breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RemoteRepositoryFormat-v2)
149-breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RepositoryFormat2a)
150-breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RepositoryFormat2aSubtree)
151 breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormatKnitPack5)
152 breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormatKnitPack5RichRoot)
153 breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormatKnitPack5RichRootBroken)
154 breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormatKnitPack6)
155 breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormatKnitPack6RichRoot)
156 breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormatPackDevelopment2Subtree)
157+breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RemoteRepositoryFormat-default)
158+breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RemoteRepositoryFormat-v2)
159+breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RepositoryFormat2a)
160+breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RepositoryFormat2aSubtree)
161 breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RepositoryFormatKnitPack5)
162 breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RepositoryFormatKnitPack5RichRoot)
163 breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RepositoryFormatKnitPack5RichRootBroken)
164@@ -25154,6 +25154,7 @@
165 breezy.tests.test_index.TestCombinedGraphIndex.test_key_count_sums_index_keys
166 breezy.tests.test_index.TestCombinedGraphIndex.test_open_missing_index_no_error
167 breezy.tests.test_index.TestCombinedGraphIndex.test_reorder_after_iter_entries
168+breezy.tests.test_index.TestCombinedGraphIndex.test_reorder_propagates_to_siblings
169 breezy.tests.test_index.TestCombinedGraphIndex.test_validate_bad_child_index_errors
170 breezy.tests.test_index.TestCombinedGraphIndex.test_validate_empty
171 breezy.tests.test_index.TestCombinedGraphIndex.test_validate_no_reload
172@@ -25218,6 +25219,7 @@
173 breezy.tests.test_index.TestGraphIndex.test_iter_all_keys
174 breezy.tests.test_index.TestGraphIndex.test_iteration_absent_skipped
175 breezy.tests.test_index.TestGraphIndex.test_iteration_absent_skipped_2_element_keys
176+breezy.tests.test_index.TestGraphIndex.test_iter_entries_buffers_by_bytes_read
177 breezy.tests.test_index.TestGraphIndex.test_iter_entries_buffers_once
178 breezy.tests.test_index.TestGraphIndex.test_iter_entries_references_2_refs_resolved
179 breezy.tests.test_index.TestGraphIndex.test_iter_entries_references_resolved
180@@ -25235,12 +25237,15 @@
181 breezy.tests.test_index.TestGraphIndex.test_key_count_one
182 breezy.tests.test_index.TestGraphIndex.test_key_count_two
183 breezy.tests.test_index.TestGraphIndex.test_lookup_key_above_probed_area
184+breezy.tests.test_index.TestGraphIndex.test_lookup_key_below_probed_area
185 breezy.tests.test_index.TestGraphIndex.test_lookup_key_can_buffer_all
186+breezy.tests.test_index.TestGraphIndex.test_lookup_key_resolves_references
187 breezy.tests.test_index.TestGraphIndex.test_lookup_key_via_location_buffers
188 breezy.tests.test_index.TestGraphIndex.test_lookup_missing_key_answers_without_io_when_map_permits
189 breezy.tests.test_index.TestGraphIndex.test_lookup_present_key_answers_without_io_when_map_permits
190 breezy.tests.test_index.TestGraphIndex.test_open_bad_index_no_error
191 breezy.tests.test_index.TestGraphIndex.test_open_sets_parsed_map_empty
192+breezy.tests.test_index.TestGraphIndex.test_parsing_data_handles_parsed_contained_regions
193 breezy.tests.test_index.TestGraphIndex.test_parsing_non_adjacent_data_trims
194 breezy.tests.test_index.TestGraphIndex.test_read_and_parse_tracks_real_read_value
195 breezy.tests.test_index.TestGraphIndex.test_read_and_parse_triggers_buffer_all

Subscribers

People subscribed via source and target branches