Rev 2755: Move start/abort/commit hash_index into RepositoryPackCollection in http://sourcefrog.net/bzr/pack-hashes

Martin Pool mbp at sourcefrog.net
Wed Sep 5 08:47:27 BST 2007


At http://sourcefrog.net/bzr/pack-hashes

------------------------------------------------------------
revno: 2755
revision-id: mbp at sourcefrog.net-20070905074726-byyfnffgevy4nitk
parent: mbp at sourcefrog.net-20070905072839-tduw1w5jgqub0ii9
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: pack-hashes
timestamp: Wed 2007-09-05 17:47:26 +1000
message:
  Move start/abort/commit hash_index into RepositoryPackCollection
modified:
  bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
=== modified file 'bzrlib/repofmt/pack_repo.py'
--- a/bzrlib/repofmt/pack_repo.py	2007-09-05 07:28:39 +0000
+++ b/bzrlib/repofmt/pack_repo.py	2007-09-05 07:47:26 +0000
@@ -121,7 +121,7 @@
             key = (h, )
             value = "%d %d" % (offset, length)
             index_updates.append((key, value))
-        self.repo._hash_write_index.add_nodes(index_updates)
+        self._hash_write_index.add_nodes(index_updates)
 
     def add_pack_to_memory(self, pack):
         """Make a Pack object available to the repository to satisfy queries.
@@ -843,7 +843,20 @@
         # cannot add names if we're not in a 'write lock'.
         if self.repo.control_files._lock_mode != 'w':
             raise errors.NotWriteLocked(self)
-
+        self._start_hash_index()
+
+    def _start_hash_index(self):
+        self._hash_write_index = InMemoryGraphIndex(reference_lists=0)
+
+    def _abort_hash_index(self):
+        del self._hash_write_index
+
+    def _commit_hash_index(self, new_pack_name):
+        new_hash_index_name = new_pack_name + _HASH_INDEX_SUFFIX
+        self._index_transport.put_file_non_atomic(new_hash_index_name,
+            self._hash_write_index.finish())
+        del self._hash_write_index
+                    
 
 class GraphKnitRevisionStore(KnitRevisionStore):
     """An object to adapt access from RevisionStore's to use GraphKnits.
@@ -1270,18 +1283,6 @@
     they simulate - this just provides common delegated implementations.
     """
 
-    def _start_hash_index(self):
-        self._hash_write_index = InMemoryGraphIndex(reference_lists=0)
-
-    def _abort_hash_index(self):
-        del self._hash_write_index
-
-    def _commit_hash_index(self, new_pack_name):
-        new_hash_index_name = new_pack_name + _HASH_INDEX_SUFFIX
-        self._index_transport.put_file_non_atomic(new_hash_index_name,
-                self._hash_write_index.finish())
-        del self._hash_write_index
-                    
     def _start_write_group(self):
         random_name = self.control_files._lock.nonce
         self._open_pack_tuple = (self._upload_transport, random_name + '.pack')
@@ -1297,7 +1298,6 @@
         self._revision_store.setup()
         self.weave_store.setup()
         self._inv_thunk.setup()
-        self._start_hash_index()
 
     def _abort_write_group(self):
         # FIXME: just drop the transient index.
@@ -1313,7 +1313,7 @@
         data_inserted = (self._revision_store.data_inserted() or
             self.weave_store.data_inserted() or 
             self._inv_thunk.data_inserted() or
-            self._hash_write_index.key_count() > 0)
+            self._packs._hash_write_index.key_count() > 0)
         if data_inserted:
             self._open_pack_writer.end()
             new_name = self._open_pack_hash.hexdigest()
@@ -1328,7 +1328,7 @@
             self.weave_store.flush(new_name, new_pack)
             self._inv_thunk.flush(new_name, new_pack)
             self._revision_store.flush(new_name, new_pack)
-            self._commit_hash_index(new_name)
+            self._packs._commit_hash_index(new_name)
             self._write_stream.close()
             self._upload_transport.rename(self._open_pack_tuple[1],
                 '../packs/' + new_name + '.pack')




More information about the bazaar-commits mailing list