Rev 638: Refactor some of the caching code. in file:///data/jelmer/bzr-svn/noschemes/
Jelmer Vernooij
jelmer at samba.org
Sun Feb 3 14:52:23 GMT 2008
At file:///data/jelmer/bzr-svn/noschemes/
------------------------------------------------------------
revno: 638
revision-id:jelmer at samba.org-20080203145223-rxhhftivnc2pg9up
parent: jelmer at samba.org-20080203144105-gwb7gr0y3lgvakuc
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: noschemes
timestamp: Sun 2008-02-03 15:52:23 +0100
message:
Refactor some of the caching code.
modified:
branchprops.py branchprops.py-20061223204623-80lvm7pjrpsgk0dd-1
cache.py cache.py-20070520185908-qbtlcet08bllgs0f-1
fileids.py fileids.py-20060714013623-u5iiyqqnko11grcf-1
revids.py revids.py-20070416220458-36vfa0730cchevp1-1
=== modified file 'branchprops.py'
--- a/branchprops.py 2008-02-01 17:34:47 +0000
+++ b/branchprops.py 2008-02-03 14:52:23 +0000
@@ -19,23 +19,24 @@
from bzrlib.errors import NoSuchRevision
from bzrlib.trace import mutter
+from cache import CacheTable
+
from svn.core import SubversionException, Pool
import svn.core
-class BranchPropertyList:
+class BranchPropertyList(CacheTable):
"""Simple class that retrieves file properties set on branches."""
- def __init__(self, log, cachedb):
+ def __init__(self, log, cachedb=None):
+ super(BranchPropertyList, self).__init__(cachedb)
self.log = log
- self.cachedb = cachedb
+ def _create_table(self):
self.cachedb.executescript("""
create table if not exists branchprop (name text, value text, branchpath text, revnum integer);
create index if not exists branch_path_revnum on branchprop (branchpath, revnum);
create index if not exists branch_path_revnum_name on branchprop (branchpath, revnum, name);
""")
- self.pool = Pool()
-
def _get_dir_props(self, path, revnum):
"""Obtain all the directory properties set on a path/revnum pair.
@@ -48,7 +49,7 @@
try:
(_, _, props) = self.log._get_transport().get_dir(path,
- revnum, pool=self.pool)
+ revnum)
except SubversionException, (_, num):
if num == svn.core.SVN_ERR_FS_NO_SUCH_REVISION:
raise NoSuchRevision(self, revnum)
=== modified file 'cache.py'
--- a/cache.py 2007-08-09 14:54:13 +0000
+++ b/cache.py 2008-02-03 14:52:23 +0000
@@ -63,3 +63,16 @@
warning('Needs at least Python2.5 or Python2.4 with the pysqlite2 '
'module')
raise bzrlib.errors.BzrError("missing sqlite library")
+
+
+class CacheTable:
+ def __init__(self, cache_db=None):
+ if cache_db is None:
+ self.cachedb = sqlite3.connect(":memory:")
+ else:
+ self.cachedb = cache_db
+ self._create_table()
+ self.cachedb.commit()
+
+ def _create_table(self):
+ pass
=== modified file 'fileids.py'
--- a/fileids.py 2008-02-03 14:41:05 +0000
+++ b/fileids.py 2008-02-03 14:52:23 +0000
@@ -55,8 +55,8 @@
FILEIDMAP_VERSION = 1
-class FileIdMap(object):
- """ File id store.
+class FileIdMap:
+ """File id store.
Keeps a map
=== modified file 'revids.py'
--- a/revids.py 2008-01-28 22:52:09 +0000
+++ b/revids.py 2008-02-03 14:52:23 +0000
@@ -18,19 +18,15 @@
from bzrlib.errors import (InvalidRevisionId, NoSuchRevision)
+from cache import CacheTable
from mapping import default_mapping
-class RevidMap(object):
+class RevidMap(CacheTable):
"""Revision id mapping store.
Stores mapping from revid -> (path, revnum, scheme)
"""
- def __init__(self, cache_db=None):
- if cache_db is None:
- from cache import sqlite3
- self.cachedb = sqlite3.connect(":memory:")
- else:
- self.cachedb = cache_db
+ def _create_table(self):
self.cachedb.executescript("""
create table if not exists revmap (revid text, path text, min_revnum integer, max_revnum integer, scheme text);
create index if not exists revid on revmap (revid);
@@ -42,7 +38,6 @@
create table if not exists revids_seen (scheme text, max_revnum int);
create unique index if not exists scheme on revids_seen (scheme);
""")
- self.cachedb.commit()
def set_last_revnum_checked(self, scheme, revnum):
"""Remember the latest revision number that has been checked
More information about the bazaar-commits
mailing list