Rev 1295: Add revprop cache to logwalker. in http://people.samba.org/bzr/jelmer/bzr-svn/0.4
Jelmer Vernooij
jelmer at samba.org
Mon Jun 23 00:25:44 BST 2008
At http://people.samba.org/bzr/jelmer/bzr-svn/0.4
------------------------------------------------------------
revno: 1295
revision-id: jelmer at samba.org-20080622232542-uf8b4v0unb479ymv
parent: jelmer at samba.org-20080622232458-53wqnwocebckik9d
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Mon 2008-06-23 01:25:42 +0200
message:
Add revprop cache to logwalker.
modified:
logwalker.py logwalker.py-20060621215743-c13fhfnyzh1xzwh2-1
repository.py repository.py-20060306123302-1f8c5069b3fe0265
=== modified file 'logwalker.py'
--- a/logwalker.py 2008-06-22 22:58:50 +0000
+++ b/logwalker.py 2008-06-22 23:25:42 +0000
@@ -101,7 +101,7 @@
self._transport = actual._transport
self.find_children = actual.find_children
- self.saved_revnum = self.cachedb.execute("SELECT MAX(rev) FROM changed_path").fetchone()[0]
+ self.saved_revnum = self.cachedb.execute("SELECT MAX(rev) FROM revinfo").fetchone()[0]
if self.saved_revnum is None:
self.saved_revnum = 0
@@ -111,6 +111,11 @@
create index if not exists path_rev on changed_path(rev);
create unique index if not exists path_rev_path on changed_path(rev, path);
create unique index if not exists path_rev_path_action on changed_path(rev, path, action);
+ create table if not exists revprop(rev integer, name text, value text);
+ create table if not exists revinfo(rev integer, all_revprops int);
+ create index if not exists revprop_rev on revprop(rev);
+ create unique index if not exists revprop_rev_name on revprop(rev, name);
+ create unique index if not exists revinfo_rev on revinfo(rev);
""")
def find_latest_change(self, path, revnum):
@@ -183,7 +188,7 @@
else:
next = changes.find_prev_location(revpaths, path, revnum)
- revprops = lazy_dict({}, self._transport.revprop_list, revnum)
+ revprops = lazy_dict({}, self.revprop_list, revnum)
if changes.changes_path(revpaths, path, True):
assert isinstance(revnum, int)
@@ -247,6 +252,18 @@
return self._get_revision_paths(revnum)
+ def revprop_list(self, revnum):
+ self.mutter("revprop list: %r", revnum)
+
+ self.fetch_revisions(revnum)
+
+ has_all_revprops = self.cachedb.execute("SELECT all_revprops FROM revinfo WHERE rev=?", (revnum,)).fetchone()[0]
+ known_revprops = dict(self.cachedb.execute("select name, value from revprop where rev="+str(revnum)))
+ if has_all_revprops:
+ return known_revprops
+
+ return lazy_dict(known_revprops, self._transport.revprop_list, revnum)
+
def fetch_revisions(self, to_revnum=None):
"""Fetch information about all revisions in the remote repository
until to_revnum.
@@ -262,6 +279,12 @@
pb = ui.ui_factory.nested_progress_bar()
+ # Subversion 1.4 clients and servers can only deliver a limited set of revprops
+ if self._transport.has_capability("log-revprops"):
+ todo_revprops = None
+ else:
+ todo_revprops = ["svn:author", "svn:log", "svn:date"]
+
def rcvr(orig_paths, revision, revprops, has_children):
pb.update('fetching svn revision info', revision, to_revnum)
if orig_paths is None:
@@ -274,8 +297,11 @@
self.cachedb.execute(
"replace into changed_path (rev, path, action, copyfrom_path, copyfrom_rev) values (?, ?, ?, ?, ?)",
(revision, p.strip("/"), orig_paths[p][0], copyfrom_path, orig_paths[p][2]))
+ for k,v in revprops.items():
+ self.cachedb.execute("replace into revprop (rev, name, value) values (?,?,?)", (revision, k, v))
+ self.cachedb.execute("replace into revinfo (rev, all_revprops) values (?,?)", (revision, todo_revprops is None))
self.saved_revnum = revision
- if self.saved_revnum % 1000 == 0:
+ if self.saved_revnum % 5000 == 0:
self.cachedb.commit()
try:
@@ -333,6 +359,9 @@
return None
raise
+ def revprop_list(self, revnum):
+ return lazy_dict({}, self._transport.revprop_list, revnum)
+
def iter_changes(self, paths, from_revnum, to_revnum=0, limit=0, pb=None):
"""Return iterator over all the revisions between revnum and 0 named path or inside path.
@@ -365,7 +394,7 @@
if todo_revprops is None:
revprops = known_revprops
else:
- revprops = lazy_dict(known_revprops, self._transport.revprop_list, revnum)
+ revprops = lazy_dict(known_revprops, self.revprop_list, revnum)
yield (revpaths, revnum, revprops)
except SubversionException, (_, num):
if num == ERR_FS_NO_SUCH_REVISION:
=== modified file 'repository.py'
--- a/repository.py 2008-06-15 01:46:28 +0000
+++ b/repository.py 2008-06-22 23:25:42 +0000
@@ -454,7 +454,7 @@
if mainline_parent != NULL_REVISION:
svn_fileprops = logwalker.lazy_dict({}, self.branchprop_list.get_changed_properties, branch, revnum)
- svn_revprops = logwalker.lazy_dict({}, self.transport.revprop_list, revnum)
+ svn_revprops = self._log.revprop_list(revnum)
revmeta = RevisionMetadata(self, branch, None, revnum, svn_revprops, svn_fileprops)
parent_ids += revmeta.get_rhs_parents(mapping)
@@ -488,7 +488,7 @@
(path, revnum, mapping) = self.lookup_revision_id(revision_id)
- svn_revprops = logwalker.lazy_dict({}, self.transport.revprop_list, revnum)
+ svn_revprops = self._log.revprop_list(revnum)
svn_fileprops = logwalker.lazy_dict({}, self.branchprop_list.get_changed_properties, path, revnum)
revmeta = RevisionMetadata(self, path, None, revnum, svn_revprops, svn_fileprops)
@@ -522,7 +522,7 @@
assert isinstance(mapping, BzrSvnMapping)
if revprops is None:
- revprops = logwalker.lazy_dict({}, self.transport.revprop_list, revnum)
+ revprops = self._log.revprop_list(revnum)
if changed_fileprops is None:
changed_fileprops = logwalker.lazy_dict({}, self.branchprop_list.get_changed_properties, path, revnum)
@@ -632,7 +632,7 @@
(path, revnum, mapping) = self.lookup_revision_id(revision_id)
except NoSuchRevision:
return False
- revprops = self.transport.revprop_list(revnum)
+ revprops = self._log.revprop_list(revnum)
return revprops.has_key(SVN_REVPROP_BZR_SIGNATURE)
def get_signature_text(self, revision_id):
@@ -643,7 +643,7 @@
:raises NoSuchRevision: Always
"""
(path, revnum, mapping) = self.lookup_revision_id(revision_id)
- revprops = self.transport.revprop_list(revnum)
+ revprops = self._log.revprop_list(revnum)
try:
return revprops[SVN_REVPROP_BZR_SIGNATURE]
except KeyError:
More information about the bazaar-commits
mailing list