Rev 1440: Make conditional commit interface generic. in http://people.samba.org/bzr/jelmer/bzr-svn/trunk
Jelmer Vernooij
jelmer at samba.org
Fri Jul 4 12:50:38 BST 2008
At http://people.samba.org/bzr/jelmer/bzr-svn/trunk
------------------------------------------------------------
revno: 1440
revision-id: jelmer at samba.org-20080704115036-z4ientqan4z6rh4b
parent: jelmer at samba.org-20080704103405-hkvyv91indtm4ulh
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Fri 2008-07-04 13:50:36 +0200
message:
Make conditional commit interface generic.
modified:
cache.py cache.py-20070520185908-qbtlcet08bllgs0f-1
logwalker.py logwalker.py-20060621215743-c13fhfnyzh1xzwh2-1
revids.py revids.py-20070416220458-36vfa0730cchevp1-1
=== modified file 'cache.py'
--- a/cache.py 2008-06-29 12:45:15 +0000
+++ b/cache.py 2008-07-04 11:50:36 +0000
@@ -81,8 +81,19 @@
self.cachedb = sqlite3.connect(":memory:")
else:
self.cachedb = cache_db
+ self._commit_interval = 500
self._create_table()
self.cachedb.commit()
+ self._commit_countdown = self._commit_interval
+
+ def commit(self):
+ self.cachedb.commit()
+ self._commit_countdown = self._commit_interval
+
+ def commit_conditionally(self):
+ self._commit_countdown -= 1
+ if self._commit_countdown <= 0:
+ self.commit()
def _create_table(self):
pass
=== modified file 'logwalker.py'
--- a/logwalker.py 2008-07-01 17:30:32 +0000
+++ b/logwalker.py 2008-07-04 11:50:36 +0000
@@ -99,7 +99,6 @@
def __init__(self, cache_db=None):
CacheTable.__init__(self, cache_db)
- self.commit_countdown = 1000
def _create_table(self):
self.cachedb.executescript("""
@@ -114,6 +113,7 @@
create unique index if not exists revprop_rev_name on revprop(rev, name);
create unique index if not exists revinfo_rev on revinfo(rev);
""")
+ self._commit_interval = 1000
def find_latest_change(self, path, revnum):
if path == "":
@@ -244,16 +244,6 @@
return 0
return saved_revnum
- def commit(self):
- """Commit the cache database."""
- self.cachedb.commit()
- self.commit_countdown = 1000
-
- def commit_conditionally(self):
- self.commit_countdown -= 1
- if self.commit_countdown <= 0:
- self.commit()
-
class CachingLogWalker(CacheTable):
"""Subversion log browser."""
=== modified file 'revids.py'
--- a/revids.py 2008-07-04 02:18:16 +0000
+++ b/revids.py 2008-07-04 11:50:36 +0000
@@ -199,6 +199,8 @@
create table if not exists revids_seen (scheme text, max_revnum int);
create unique index if not exists scheme on revids_seen (scheme);
""")
+ # Revisions ids are quite expensive
+ self._commit_interval = 5
def set_last_revnum_checked(self, layout, revnum):
"""Remember the latest revision number that has been checked
@@ -208,6 +210,7 @@
:param revnum: Revision number.
"""
self.cachedb.execute("replace into revids_seen (scheme, max_revnum) VALUES (?, ?)", (layout, revnum))
+ self.commit_conditionally()
def last_revnum_checked(self, layout):
"""Retrieve the latest revision number that has been checked
@@ -281,3 +284,4 @@
self.cachedb.execute(
"insert into revmap (revid,path,min_revnum,max_revnum,scheme) VALUES (?,?,?,?,?)",
(revid, branch, min_revnum, max_revnum, scheme))
+ self.commit_conditionally()
More information about the bazaar-commits
mailing list