Rev 5090: Rename TrailingIndex to SectionInfo in http://bzr.arbash-meinel.com/branches/bzr/lp/2.2.0b2-contained-pack
John Arbash Meinel
john at arbash-meinel.com
Fri Mar 5 20:57:39 GMT 2010
At http://bzr.arbash-meinel.com/branches/bzr/lp/2.2.0b2-contained-pack
------------------------------------------------------------
revno: 5090
revision-id: john at arbash-meinel.com-20100305205705-fy99019bdtggwq70
parent: john at arbash-meinel.com-20100305205514-6mc90bgiikaarsjd
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.2.0b2-contained-pack
timestamp: Fri 2010-03-05 14:57:05 -0600
message:
Rename TrailingIndex to SectionInfo
-------------- next part --------------
=== modified file 'bzrlib/pack_collection.py'
--- a/bzrlib/pack_collection.py 2010-03-05 20:55:14 +0000
+++ b/bzrlib/pack_collection.py 2010-03-05 20:57:05 +0000
@@ -49,13 +49,14 @@
return sections
-class TrailingIndexBuilder(object):
- """This is the final bit that gets written to the sack content.
+class SectionInfoBuilder(object):
+ """This is the final bit that gets written to the pack content.
It describes the version of the file (also present at the beginning),
- as well as some basic information about where data can be found.
+ as well as some basic information about where various sections (indices)
+ can be found.
- | header | index info | 8-byte start-of-header | 4-byte version |
+ | header | section info | 8-byte start-of-header | 4-byte version |
The last two records are using fixed-width MSB encoding, so that we always
know how much to parse.
@@ -80,7 +81,7 @@
# TODO: Perhaps this should be more like BTreeBuilder and return a
# file-like object, alternatively it should take a 'writer'
# function so that we can stream the data into it. For now,
- # we don't expect the TrailingIndex to be big enough to worry
+ # we don't expect the SectionInfo to be big enough to worry
# about memory pressure, etc.
# Testing has shown it to be in the ~100bytes category, which is
# quite tiny
@@ -92,10 +93,10 @@
-class TrailingIndex(object):
+class SectionInfo(object):
"""Track the root-structure for the Sack.
- See TrailingIndexBuilder for the structure of this tail.
+ See SectionInfoBuilder for the structure of this tail.
"""
def __init__(self, transport, filename):
@@ -117,7 +118,7 @@
# TODO: We could predict the length of the tail, and read extra bytes,
# rather than wasting a round-trip...
_, tail = transport.readv(filename, [(file_st.st_size-12, 12)]).next()
- start_offset, version = TrailingIndex.parse_tail_bytes(tail)
+ start_offset, version = SectionInfo.parse_tail_bytes(tail)
expected_header = '%s%d\n' % (_HEADER_BASE, version)
_, tail = transport.readv(filename,
[(start_offset, file_st.st_size - start_offset)]).next()
=== modified file 'bzrlib/tests/test_pack_collection.py'
--- a/bzrlib/tests/test_pack_collection.py 2010-03-05 20:55:14 +0000
+++ b/bzrlib/tests/test_pack_collection.py 2010-03-05 20:57:05 +0000
@@ -45,7 +45,7 @@
assert_index_content(test, a_dict, index)
-class TestTrailingIndexBuilder(tests.TestCase):
+class TestSectionInfoBuilder(tests.TestCase):
def assertAsBytes(self, index_content, ti):
content = ti.finish()
@@ -60,16 +60,16 @@
self.assertEqual(index_content, index_dict)
def test_tail_info(self):
- self.assertAsBytes({}, pack_collection.TrailingIndexBuilder(0))
- self.assertAsBytes({}, pack_collection.TrailingIndexBuilder(12345))
- self.assertAsBytes({}, pack_collection.TrailingIndexBuilder(2**48-1))
- self.assertAsBytes({}, pack_collection.TrailingIndexBuilder(2**64-1))
- ti = pack_collection.TrailingIndexBuilder(2**64-1)
+ self.assertAsBytes({}, pack_collection.SectionInfoBuilder(0))
+ self.assertAsBytes({}, pack_collection.SectionInfoBuilder(12345))
+ self.assertAsBytes({}, pack_collection.SectionInfoBuilder(2**48-1))
+ self.assertAsBytes({}, pack_collection.SectionInfoBuilder(2**64-1))
+ ti = pack_collection.SectionInfoBuilder(2**64-1)
ti.version = 3
self.assertAsBytes({}, ti)
def test_with_content(self):
- builder = pack_collection.TrailingIndexBuilder(start_offset=500)
+ builder = pack_collection.SectionInfoBuilder(start_offset=500)
builder.add_section_info('revisions', 0, 100)
builder.add_section_info('inventories', 100, 50)
builder.add_section_info('texts', 150, 350)
@@ -79,11 +79,11 @@
}, builder)
-class TestTrailingIndex(tests.TestCase):
+class TestSectionInfo(tests.TestCase):
def assertTailBytes(self, start_offset, version, bytes):
self.assertEqual((start_offset, version),
- pack_collection.TrailingIndex.parse_tail_bytes(bytes))
+ pack_collection.SectionInfo.parse_tail_bytes(bytes))
def test_parse_tail_bytes(self):
self.assertTailBytes(12345, 1,
@@ -96,12 +96,12 @@
def test_from_transport(self):
# We should be able to bootstrap all info starting with just a path on
# disk
- builder = pack_collection.TrailingIndexBuilder(start_offset=500)
+ builder = pack_collection.SectionInfoBuilder(start_offset=500)
builder.add_section_info('texts', 150, 350)
content = builder.finish()
t = memory.MemoryTransport('')
t.put_bytes('test.pack', ' '*500 + content)
- ti = pack_collection.TrailingIndex.from_transport(t, 'test.pack')
+ ti = pack_collection.SectionInfo.from_transport(t, 'test.pack')
# We skip the 16-byte header at the beginning, and the 12-byte tail
self.assertEqual({'texts': (150, 350)}, ti._sections)
@@ -111,14 +111,14 @@
index_builder.add_node(('key2',), 'value2')
text_idx_content = index_builder.finish().read()
trail_start = len(text_idx_content)
- trailing_builder = pack_collection.TrailingIndexBuilder(
+ trailing_builder = pack_collection.SectionInfoBuilder(
start_offset=trail_start)
trailing_builder.add_section_info('texts', 0, trail_start)
trailing_content = trailing_builder.finish()
content = text_idx_content + trailing_content
t = memory.MemoryTransport('')
t.put_bytes('test.pack', content)
- ti = pack_collection.TrailingIndex.from_transport(t, 'test.pack')
+ ti = pack_collection.SectionInfo.from_transport(t, 'test.pack')
self.assertEqual({'texts': (0, trail_start)},
ti._sections)
text_index = ti.get_named_index('texts', btree_index.BTreeGraphIndex)
More information about the bazaar-commits
mailing list