Rev 4783: Finish testing the 4096 and 65536 variants. in http://bazaar.launchpad.net/~jameinel/bzr/chk-index
John Arbash Meinel
john at arbash-meinel.com
Wed Oct 28 01:45:32 GMT 2009
At http://bazaar.launchpad.net/~jameinel/bzr/chk-index
------------------------------------------------------------
revno: 4783
revision-id: john at arbash-meinel.com-20091028014525-fix7mtqbbr9ie7sy
parent: john at arbash-meinel.com-20091027221740-2eyjx8c3fjopsf71
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: chk-index
timestamp: Tue 2009-10-27 20:45:25 -0500
message:
Finish testing the 4096 and 65536 variants.
-------------- next part --------------
=== modified file 'bzrlib/chk_index.py'
--- a/bzrlib/chk_index.py 2009-10-27 22:17:40 +0000
+++ b/bzrlib/chk_index.py 2009-10-28 01:45:25 +0000
@@ -305,16 +305,19 @@
c = ord(bit_key[0])
return c & 0x0F
+
def _bit_key_to_offset_256(bit_key):
# The first byte
return ord(bit_key[0])
+
_struct_H = Struct('<H')
def _bit_key_to_offset_4096(bit_key):
- return _struct_H.unpack(bit_key) & 0x0FFF
+ return _struct_H.unpack(bit_key[:2])[0] & 0x0FFF
+
def _bit_key_to_offset_65536(bit_key):
- return _struct_H.unpack(bit_key)
+ return _struct_H.unpack(bit_key[:2])[0]
class CHKIndexBuilder(object):
=== modified file 'bzrlib/tests/test_chk_index.py'
--- a/bzrlib/tests/test_chk_index.py 2009-10-27 22:17:40 +0000
+++ b/bzrlib/tests/test_chk_index.py 2009-10-28 01:45:25 +0000
@@ -205,15 +205,18 @@
def test__get_bit_key_to_mini_index_4096(self):
offset_func = chk_index.CHKIndexBuilder._get_bit_key_to_mini_index(4096)
- # da39... maps to 'da'
- self.assertEqual(0xda, offset_func(self.bit_k1))
- self.assertEqual(0x86, offset_func(self.bit_k2))
- self.assertEqual(0xe9, offset_func(self.bit_k3))
-# k1 = ('sha1:da39a3ee5e6b4b0d3255bfef95601890afd80709',)
-# k2 = ('sha1:86f7e437faa5a7fce15d1ddcb9eaeaea377667b8',)
-# k3 = ('sha1:e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98',)
+ # da39... maps to 0x9da'
+ self.assertEqual(0x9da, offset_func(self.bit_k1))
+ self.assertEqual(0x786, offset_func(self.bit_k2))
+ self.assertEqual(0x7e9, offset_func(self.bit_k3))
- # TODO: We need to test 65536 and more?
+ def test__get_bit_key_to_mini_index_65536(self):
+ offset_func = chk_index.CHKIndexBuilder._get_bit_key_to_mini_index(
+ 65536)
+ # da39... maps to 0x39da
+ self.assertEqual(0x39da, offset_func(self.bit_k1))
+ self.assertEqual(0xf786, offset_func(self.bit_k2))
+ self.assertEqual(0xd7e9, offset_func(self.bit_k3))
def test__build_mini_index_and_entries_16(self):
builder = chk_index.CHKIndexBuilder()
More information about the bazaar-commits
mailing list