Rev 5106: Start thinking about how we want to expose the PackCollection as an entity. in http://bzr.arbash-meinel.com/branches/bzr/lp/2.2.0b2-contained-pack

John Arbash Meinel john at arbash-meinel.com
Mon Mar 8 22:41:32 GMT 2010


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

------------------------------------------------------------
revno: 5106
revision-id: john at arbash-meinel.com-20100308224127-lbefzxzk450rm612
parent: john at arbash-meinel.com-20100308221511-nhnn2px5i1vovlf6
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.2.0b2-contained-pack
timestamp: Mon 2010-03-08 16:41:27 -0600
message:
  Start thinking about how we want to expose the PackCollection as an entity.
-------------- next part --------------
=== modified file 'bzrlib/pack_collection.py'
--- a/bzrlib/pack_collection.py	2010-03-08 22:15:11 +0000
+++ b/bzrlib/pack_collection.py	2010-03-08 22:41:27 +0000
@@ -407,6 +407,46 @@
         pass
 
 
+class RepositoryLockingPolicy(LockingPolicy):
+    """Check read/write/etc locks for a Repository."""
+
+    def __init__(self, repo):
+        self.repo = repo
+
+    def safe_to_cache(self):
+        """See LockingPolicy.safe_to_cache()"""
+        if not self.repo.is_locked():
+            raise errors.ObjectNotLocked(self.repo)
+
+    def lock_write(self):
+        """See LockingPolicy.lock_write()"""
+        self.repo.control_files.lock_write()
+
+    def unlock(self):
+        """See LockingPolicy.unlock()"""
+        self.repo.control_files.unlock()
+
+
+class Pack(object):
+    """Tracks a bunch of content and some associated indices."""
+
+    def __init__(self):
+        self._indexes = {}
+
+    def get_index_memo(self):
+        """Return a byte string that can be used to initialize indexes."""
+        raise NotImplementedError(self.get_index_memo)
+
+    @classmethod
+    def from_index_memo(cls, memo):
+        """Return a new Pack instance, initialized from the given index memo.
+
+        :param memo: A memo that was returned by 'get_index_memo' at some point
+            previously.
+        :return: A Pack instance
+        """
+
+
 class PackCollection(object):
     """This manages a collection of pack files.
 
@@ -416,3 +456,14 @@
     repacked, and triggers that at an appropriate time.
     """
 
+    def __init__(self, memo_tracker):
+        self.memo_tracker = memo_tracker
+        self._packs = {}
+
+
+    def get_vf_interface(self, index):
+        """Get a VersionedFiles abstraction for the given named index."""
+
+
+class PackCollectionUpdatePolicy(UpdatePolicy):
+    """Update the pack collection as items are added and removed."""



More information about the bazaar-commits mailing list