Rev 1565: Move file id caching to a separate object. in http://people.samba.org/bzr/jelmer/bzr-svn/trunk

Jelmer Vernooij jelmer at samba.org
Fri Aug 8 23:34:40 BST 2008


At http://people.samba.org/bzr/jelmer/bzr-svn/trunk

------------------------------------------------------------
revno: 1565
revision-id: jelmer at samba.org-20080808223438-e4sgylu84rnt5mft
parent: jelmer at samba.org-20080808221026-waj0dycxa2weaxcx
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Sat 2008-08-09 00:34:38 +0200
message:
  Move file id caching to a separate object.
modified:
  fileids.py                     fileids.py-20060714013623-u5iiyqqnko11grcf-1
=== modified file 'fileids.py'
--- a/fileids.py	2008-08-02 21:19:27 +0000
+++ b/fileids.py	2008-08-08 22:34:38 +0000
@@ -207,14 +207,11 @@
                 map[parent] = map[parent][0], revid
 
 
-class CachingFileIdMap(object):
-    """A file id map that uses a cache."""
-    def __init__(self, cache_transport, actual):
+class FileIdMapCache(object):
+
+    def __init__(self, cache_transport):
         mapper = ConstantMapper("fileidmap-v%d" % FILEIDMAP_VERSION)
         self.idmap_knit = make_file_factory(True, mapper)(cache_transport)
-        self.actual = actual
-        self.apply_changes = actual.apply_changes
-        self.repos = actual.repos
 
     def save(self, revid, parent_revids, _map):
         mutter('saving file id map for %r', revid)
@@ -237,6 +234,15 @@
 
         return map
 
+
+class CachingFileIdMap(object):
+    """A file id map that uses a cache."""
+    def __init__(self, cache_transport, actual):
+        self.cache = FileIdMapCache(cache_transport)
+        self.actual = actual
+        self.apply_changes = actual.apply_changes
+        self.repos = actual.repos
+
     def get_map(self, uuid, revnum, branch, mapping):
         """Make sure the map is up to date until revnum."""
         # First, find the last cached map
@@ -255,7 +261,7 @@
                 pb.update("fetching changes for file ids", revnum-revmeta.revnum, revnum)
                 revid = revmeta.get_revision_id(mapping)
                 try:
-                    map = self.load(revid)
+                    map = self.cache.load(revid)
                     # found the nearest cached map
                     next_parent_revs = [revid]
                     break
@@ -290,7 +296,7 @@
 
                 parent_revs = next_parent_revs
                        
-                self.save(revid, parent_revs, map)
+                self.cache.save(revid, parent_revs, map)
                 next_parent_revs = [revid]
         finally:
             pb.finished()




More information about the bazaar-commits mailing list