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
=== modified file 'breezy/bzr/index.py'
--- breezy/bzr/index.py 2018-06-30 16:14:04 +0000
+++ breezy/bzr/index.py 2018-08-20 01:35:26 +0000
@@ -664,7 +664,8 @@
664 node_refs.append(tuple([self._keys_by_offset[ref][0] for ref in ref_list]))664 node_refs.append(tuple([self._keys_by_offset[ref][0] for ref in ref_list]))
665 return tuple(node_refs)665 return tuple(node_refs)
666666
667 def _find_index(self, range_map, key):667 @staticmethod
668 def _find_index(range_map, key):
668 """Helper for the _parsed_*_index calls.669 """Helper for the _parsed_*_index calls.
669670
670 Given a range map - [(start, end), ...], finds the index of the range671 Given a range map - [(start, end), ...], finds the index of the range
@@ -702,7 +703,7 @@
702 asking for 'b' will return 1703 asking for 'b' will return 1
703 asking for 'e' will return 1704 asking for 'e' will return 1
704 """705 """
705 search_key = (key, None)706 search_key = (key, b'')
706 return self._find_index(self._parsed_key_map, search_key)707 return self._find_index(self._parsed_key_map, search_key)
707708
708 def _is_parsed(self, offset):709 def _is_parsed(self, offset):
@@ -1000,7 +1001,7 @@
1000 # calculate the bytes we have processed1001 # calculate the bytes we have processed
1001 header_end = (len(signature) + len(lines[0]) + len(lines[1]) +1002 header_end = (len(signature) + len(lines[0]) + len(lines[1]) +
1002 len(lines[2]) + 3)1003 len(lines[2]) + 3)
1003 self._parsed_bytes(0, None, header_end, None)1004 self._parsed_bytes(0, (), header_end, ())
1004 # setup parsing state1005 # setup parsing state
1005 self._expected_elements = 3 + self._key_length1006 self._expected_elements = 3 + self._key_length
1006 # raw data keyed by offset1007 # raw data keyed by offset
10071008
=== modified file 'breezy/tests/test_index.py'
--- breezy/tests/test_index.py 2018-08-04 13:00:08 +0000
+++ breezy/tests/test_index.py 2018-08-20 01:35:26 +0000
@@ -310,7 +310,7 @@
310 self.assertRaises(_mod_index.BadIndexKey, builder.add_node,310 self.assertRaises(_mod_index.BadIndexKey, builder.add_node,
311 (b'a%skey' % int2byte(bad_char), ), b'data')311 (b'a%skey' % int2byte(bad_char), ), b'data')
312 self.assertRaises(_mod_index.BadIndexKey, builder.add_node,312 self.assertRaises(_mod_index.BadIndexKey, builder.add_node,
313 (b'', ), b'data')313 (), b'data')
314 self.assertRaises(_mod_index.BadIndexKey, builder.add_node,314 self.assertRaises(_mod_index.BadIndexKey, builder.add_node,
315 b'not-a-tuple', b'data')315 b'not-a-tuple', b'data')
316 # not enough length316 # not enough length
@@ -544,7 +544,7 @@
544 # And the regions of the file that have been parsed should be in the544 # And the regions of the file that have been parsed should be in the
545 # parsed_byte_map and the parsed_key_map545 # parsed_byte_map and the parsed_key_map
546 self.assertEqual([(0, 4008), (5046, 8996)], index._parsed_byte_map)546 self.assertEqual([(0, 4008), (5046, 8996)], index._parsed_byte_map)
547 self.assertEqual([(None, self.make_key(26)),547 self.assertEqual([((), self.make_key(26)),
548 (self.make_key(31), self.make_key(48))],548 (self.make_key(31), self.make_key(48))],
549 index._parsed_key_map)549 index._parsed_key_map)
550550
@@ -560,7 +560,7 @@
560 # and we should have a parse map that includes the header and the560 # and we should have a parse map that includes the header and the
561 # region that was parsed after trimming.561 # region that was parsed after trimming.
562 self.assertEqual([(0, 4008), (5046, 8996)], index._parsed_byte_map)562 self.assertEqual([(0, 4008), (5046, 8996)], index._parsed_byte_map)
563 self.assertEqual([(None, self.make_key(26)),563 self.assertEqual([((), self.make_key(26)),
564 (self.make_key(31), self.make_key(48))],564 (self.make_key(31), self.make_key(48))],
565 index._parsed_key_map)565 index._parsed_key_map)
566566
@@ -584,7 +584,7 @@
584 # and we should have a parse map that includes the header and the584 # and we should have a parse map that includes the header and the
585 # region that was parsed after trimming.585 # region that was parsed after trimming.
586 self.assertEqual([(0, 4045), (11759, 15707)], index._parsed_byte_map)586 self.assertEqual([(0, 4045), (11759, 15707)], index._parsed_byte_map)
587 self.assertEqual([(None, self.make_key(116)),587 self.assertEqual([((), self.make_key(116)),
588 (self.make_key(35), self.make_key(51))],588 (self.make_key(35), self.make_key(51))],
589 index._parsed_key_map)589 index._parsed_key_map)
590 # now ask for two keys, right before and after the parsed region590 # now ask for two keys, right before and after the parsed region
@@ -608,7 +608,7 @@
608 [(index._size // 2, (b'40', ))])608 [(index._size // 2, (b'40', ))])
609 # check the parse map, this determines the test validity609 # check the parse map, this determines the test validity
610 self.assertEqual([(0, 4008), (5046, 8996)], index._parsed_byte_map)610 self.assertEqual([(0, 4008), (5046, 8996)], index._parsed_byte_map)
611 self.assertEqual([(None, self.make_key(26)),611 self.assertEqual([((), self.make_key(26)),
612 (self.make_key(31), self.make_key(48))],612 (self.make_key(31), self.make_key(48))],
613 index._parsed_key_map)613 index._parsed_key_map)
614 # reset the transport log614 # reset the transport log
@@ -632,7 +632,7 @@
632 [(index._size // 2, (b'40', ))])632 [(index._size // 2, (b'40', ))])
633 # check the parse map, this determines the test validity633 # check the parse map, this determines the test validity
634 self.assertEqual([(0, 4008), (5046, 8996)], index._parsed_byte_map)634 self.assertEqual([(0, 4008), (5046, 8996)], index._parsed_byte_map)
635 self.assertEqual([(None, self.make_key(26)),635 self.assertEqual([((), self.make_key(26)),
636 (self.make_key(31), self.make_key(48))],636 (self.make_key(31), self.make_key(48))],
637 index._parsed_key_map)637 index._parsed_key_map)
638 # reset the transport log638 # reset the transport log
@@ -659,10 +659,10 @@
659 [(index._size // 2, (b'30', ))])659 [(index._size // 2, (b'30', ))])
660 # check the parse map, this determines the test validity660 # check the parse map, this determines the test validity
661 self.assertEqual([(0, 4008), (5046, 8996)], index._parsed_byte_map)661 self.assertEqual([(0, 4008), (5046, 8996)], index._parsed_byte_map)
662 self.assertEqual([(None, self.make_key(26)),662 self.assertEqual([((), self.make_key(26)),
663 (self.make_key(31), self.make_key(48))],663 (self.make_key(31), self.make_key(48))],
664 index._parsed_key_map)664 index._parsed_key_map)
665 self.assertEqual([((index._size // 2, ('30', )), -1)],665 self.assertEqual([((index._size // 2, (b'30', )), -1)],
666 result)666 result)
667667
668 def test_lookup_key_above_probed_area(self):668 def test_lookup_key_above_probed_area(self):
@@ -675,7 +675,7 @@
675 [(index._size // 2, (b'50', ))])675 [(index._size // 2, (b'50', ))])
676 # check the parse map, this determines the test validity676 # check the parse map, this determines the test validity
677 self.assertEqual([(0, 4008), (5046, 8996)], index._parsed_byte_map)677 self.assertEqual([(0, 4008), (5046, 8996)], index._parsed_byte_map)
678 self.assertEqual([(None, self.make_key(26)),678 self.assertEqual([((), self.make_key(26)),
679 (self.make_key(31), self.make_key(48))],679 (self.make_key(31), self.make_key(48))],
680 index._parsed_key_map)680 index._parsed_key_map)
681 self.assertEqual([((index._size // 2, (b'50', )), +1)],681 self.assertEqual([((index._size // 2, (b'50', )), +1)],
@@ -698,7 +698,7 @@
698 # check the parse map - only the start and middle should have been698 # check the parse map - only the start and middle should have been
699 # parsed.699 # parsed.
700 self.assertEqual([(0, 4027), (10198, 14028)], index._parsed_byte_map)700 self.assertEqual([(0, 4027), (10198, 14028)], index._parsed_byte_map)
701 self.assertEqual([(None, self.make_key(17)),701 self.assertEqual([((), self.make_key(17)),
702 (self.make_key(44), self.make_key(5))],702 (self.make_key(44), self.make_key(5))],
703 index._parsed_key_map)703 index._parsed_key_map)
704 # and check the transport activity likewise.704 # and check the transport activity likewise.
@@ -733,7 +733,7 @@
733 # check the parse map - only the start and middle should have been733 # check the parse map - only the start and middle should have been
734 # parsed.734 # parsed.
735 self.assertEqual([(0, 3890), (6444, 10274)], index._parsed_byte_map)735 self.assertEqual([(0, 3890), (6444, 10274)], index._parsed_byte_map)
736 self.assertEqual([(None, self.make_key(25)),736 self.assertEqual([((), self.make_key(25)),
737 (self.make_key(37), self.make_key(52))],737 (self.make_key(37), self.make_key(52))],
738 index._parsed_key_map)738 index._parsed_key_map)
739 # and check the transport activity likewise.739 # and check the transport activity likewise.
@@ -1463,7 +1463,7 @@
1463 index2_1, index2_2 = cgi2._indices1463 index2_1, index2_2 = cgi2._indices
1464 cgi1.set_sibling_indices([cgi2])1464 cgi1.set_sibling_indices([cgi2])
1465 # Trigger a reordering in cgi1. cgi2 will be reordered as well.1465 # Trigger a reordering in cgi1. cgi2 will be reordered as well.
1466 list(cgi1.iter_entries([('index-1-2-key-1',)]))1466 list(cgi1.iter_entries([(b'index-1-2-key-1',)]))
1467 self.assertEqual([index2_2, index2_1], cgi2._indices)1467 self.assertEqual([index2_2, index2_1], cgi2._indices)
1468 self.assertEqual(['two', 'one'], cgi2._index_names)1468 self.assertEqual(['two', 'one'], cgi2._index_names)
14691469
14701470
=== modified file 'python3.passing'
--- python3.passing 2018-08-08 02:10:06 +0000
+++ python3.passing 2018-08-20 01:35:26 +0000
@@ -9130,16 +9130,16 @@
9130breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RemoteRepositoryFormat-v2)9130breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RemoteRepositoryFormat-v2)
9131breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormat2a)9131breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormat2a)
9132breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormat2aSubtree)9132breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormat2aSubtree)
9133breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RemoteRepositoryFormat-default)
9134breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RemoteRepositoryFormat-v2)
9135breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RepositoryFormat2a)
9136breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RepositoryFormat2aSubtree)
9137breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormatKnitPack5)9133breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormatKnitPack5)
9138breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormatKnitPack5RichRoot)9134breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormatKnitPack5RichRoot)
9139breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormatKnitPack5RichRootBroken)9135breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormatKnitPack5RichRootBroken)
9140breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormatKnitPack6)9136breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormatKnitPack6)
9141breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormatKnitPack6RichRoot)9137breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormatKnitPack6RichRoot)
9142breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormatPackDevelopment2Subtree)9138breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormatPackDevelopment2Subtree)
9139breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RemoteRepositoryFormat-default)
9140breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RemoteRepositoryFormat-v2)
9141breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RepositoryFormat2a)
9142breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RepositoryFormat2aSubtree)
9143breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RepositoryFormatKnitPack5)9143breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RepositoryFormatKnitPack5)
9144breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RepositoryFormatKnitPack5RichRoot)9144breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RepositoryFormatKnitPack5RichRoot)
9145breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RepositoryFormatKnitPack5RichRootBroken)9145breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RepositoryFormatKnitPack5RichRootBroken)
@@ -25154,6 +25154,7 @@
25154breezy.tests.test_index.TestCombinedGraphIndex.test_key_count_sums_index_keys25154breezy.tests.test_index.TestCombinedGraphIndex.test_key_count_sums_index_keys
25155breezy.tests.test_index.TestCombinedGraphIndex.test_open_missing_index_no_error25155breezy.tests.test_index.TestCombinedGraphIndex.test_open_missing_index_no_error
25156breezy.tests.test_index.TestCombinedGraphIndex.test_reorder_after_iter_entries25156breezy.tests.test_index.TestCombinedGraphIndex.test_reorder_after_iter_entries
25157breezy.tests.test_index.TestCombinedGraphIndex.test_reorder_propagates_to_siblings
25157breezy.tests.test_index.TestCombinedGraphIndex.test_validate_bad_child_index_errors25158breezy.tests.test_index.TestCombinedGraphIndex.test_validate_bad_child_index_errors
25158breezy.tests.test_index.TestCombinedGraphIndex.test_validate_empty25159breezy.tests.test_index.TestCombinedGraphIndex.test_validate_empty
25159breezy.tests.test_index.TestCombinedGraphIndex.test_validate_no_reload25160breezy.tests.test_index.TestCombinedGraphIndex.test_validate_no_reload
@@ -25218,6 +25219,7 @@
25218breezy.tests.test_index.TestGraphIndex.test_iter_all_keys25219breezy.tests.test_index.TestGraphIndex.test_iter_all_keys
25219breezy.tests.test_index.TestGraphIndex.test_iteration_absent_skipped25220breezy.tests.test_index.TestGraphIndex.test_iteration_absent_skipped
25220breezy.tests.test_index.TestGraphIndex.test_iteration_absent_skipped_2_element_keys25221breezy.tests.test_index.TestGraphIndex.test_iteration_absent_skipped_2_element_keys
25222breezy.tests.test_index.TestGraphIndex.test_iter_entries_buffers_by_bytes_read
25221breezy.tests.test_index.TestGraphIndex.test_iter_entries_buffers_once25223breezy.tests.test_index.TestGraphIndex.test_iter_entries_buffers_once
25222breezy.tests.test_index.TestGraphIndex.test_iter_entries_references_2_refs_resolved25224breezy.tests.test_index.TestGraphIndex.test_iter_entries_references_2_refs_resolved
25223breezy.tests.test_index.TestGraphIndex.test_iter_entries_references_resolved25225breezy.tests.test_index.TestGraphIndex.test_iter_entries_references_resolved
@@ -25235,12 +25237,15 @@
25235breezy.tests.test_index.TestGraphIndex.test_key_count_one25237breezy.tests.test_index.TestGraphIndex.test_key_count_one
25236breezy.tests.test_index.TestGraphIndex.test_key_count_two25238breezy.tests.test_index.TestGraphIndex.test_key_count_two
25237breezy.tests.test_index.TestGraphIndex.test_lookup_key_above_probed_area25239breezy.tests.test_index.TestGraphIndex.test_lookup_key_above_probed_area
25240breezy.tests.test_index.TestGraphIndex.test_lookup_key_below_probed_area
25238breezy.tests.test_index.TestGraphIndex.test_lookup_key_can_buffer_all25241breezy.tests.test_index.TestGraphIndex.test_lookup_key_can_buffer_all
25242breezy.tests.test_index.TestGraphIndex.test_lookup_key_resolves_references
25239breezy.tests.test_index.TestGraphIndex.test_lookup_key_via_location_buffers25243breezy.tests.test_index.TestGraphIndex.test_lookup_key_via_location_buffers
25240breezy.tests.test_index.TestGraphIndex.test_lookup_missing_key_answers_without_io_when_map_permits25244breezy.tests.test_index.TestGraphIndex.test_lookup_missing_key_answers_without_io_when_map_permits
25241breezy.tests.test_index.TestGraphIndex.test_lookup_present_key_answers_without_io_when_map_permits25245breezy.tests.test_index.TestGraphIndex.test_lookup_present_key_answers_without_io_when_map_permits
25242breezy.tests.test_index.TestGraphIndex.test_open_bad_index_no_error25246breezy.tests.test_index.TestGraphIndex.test_open_bad_index_no_error
25243breezy.tests.test_index.TestGraphIndex.test_open_sets_parsed_map_empty25247breezy.tests.test_index.TestGraphIndex.test_open_sets_parsed_map_empty
25248breezy.tests.test_index.TestGraphIndex.test_parsing_data_handles_parsed_contained_regions
25244breezy.tests.test_index.TestGraphIndex.test_parsing_non_adjacent_data_trims25249breezy.tests.test_index.TestGraphIndex.test_parsing_non_adjacent_data_trims
25245breezy.tests.test_index.TestGraphIndex.test_read_and_parse_tracks_real_read_value25250breezy.tests.test_index.TestGraphIndex.test_read_and_parse_tracks_real_read_value
25246breezy.tests.test_index.TestGraphIndex.test_read_and_parse_triggers_buffer_all25251breezy.tests.test_index.TestGraphIndex.test_read_and_parse_triggers_buffer_all

Subscribers

People subscribed via source and target branches