Rev 5083: use the new offset for the subset indexes. 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 18:49:01 GMT 2010


At http://bzr.arbash-meinel.com/branches/bzr/lp/2.2.0b2-contained-pack

------------------------------------------------------------
revno: 5083
revision-id: john at arbash-meinel.com-20100305184828-7w4d0sz875k13ws5
parent: john at arbash-meinel.com-20100305184358-cyfsv1yw0gpldq8s
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.2.0b2-contained-pack
timestamp: Fri 2010-03-05 12:48:28 -0600
message:
  use the new offset for the subset indexes.
-------------- next part --------------
=== modified file 'bzrlib/sack.py'
--- a/bzrlib/sack.py	2010-03-04 23:04:18 +0000
+++ b/bzrlib/sack.py	2010-03-05 18:48:28 +0000
@@ -27,7 +27,6 @@
     errors,
     btree_index,
     )
-from bzrlib.transport import file_view
 
 _HEADER_BASE = '\nBazaar Sack v'
 _VERSION = 1
@@ -93,23 +92,21 @@
     def __init__(self, version, start_offset):
         self.start_offset = start_offset
         self.version = version
-        # This is a transport.file_view.FileView which allows us to maps names
-        # into offsets in the backing transport
+        # Map the name to the start and size of each section
         self._section_file_map = {}
-        self._file_view = None
+        self._transport = None
+        self._filename = None
 
-    def _read_named_sections(self, base_transport, filename, end_of_file):
+    def _read_named_sections(self, end_of_file):
         expected_header = '%s%d\n' % (_HEADER_BASE, self.version)
-        _, start = base_transport.readv(filename,
+        _, start = self._transport.readv(self._filename,
             [(self.start_offset, len(expected_header))]).next()
         assert start == expected_header
         root_start = self.start_offset + len(expected_header)
         root_end = end_of_file - 12
         self._section_file_map['root-index'] = (root_start, root_end)
-        self._file_view = file_view.FileView(base_transport, filename,
-            self._section_file_map)
-        named_sections = btree_index.BTreeGraphIndex(
-            self._file_view, 'root-index', root_end - root_start)
+        named_sections = btree_index.BTreeGraphIndex(self._transport,
+            self._filename, root_end - root_start, offset=root_start)
         # Ensure that we have entries
         for _, key, value in named_sections.iter_all_entries():
             start, length = map(int, value.split())
@@ -131,7 +128,9 @@
         file_st = transport.stat(filename)
         _, tail = transport.readv(filename, [(file_st.st_size-12, 12)]).next()
         ti = TrailingIndex.parse_tail_bytes(tail)
-        ti._read_named_sections(transport, filename, file_st.st_size)
+        ti._transport = transport
+        ti._filename = filename
+        ti._read_named_sections(file_st.st_size)
         return ti
 
     def get_named_index(self, name, index_class, **kwargs):
@@ -143,7 +142,8 @@
             constructor
         """
         start, end = self._section_file_map[name]
-        return index_class(self._file_view, name, size=(end-start), **kwargs)
+        return index_class(self._transport, self._filename, size=(end-start),
+                           **kwargs)
 
 
 class Sack(object):



More information about the bazaar-commits mailing list