Rev 641: Always retrieve full list of branch properties rather than requesting them one-by-one. in file:///data/jelmer/bzr-svn/noschemes/

Jelmer Vernooij jelmer at samba.org
Sun Feb 3 15:26:36 GMT 2008


At file:///data/jelmer/bzr-svn/noschemes/

------------------------------------------------------------
revno: 641
revision-id:jelmer at samba.org-20080203152630-7taxpgohwudmeoa5
parent: jelmer at samba.org-20080203150225-l8qjw2lcvugoza9f
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: noschemes
timestamp: Sun 2008-02-03 16:26:30 +0100
message:
  Always retrieve full list of branch properties rather than requesting them one-by-one.
modified:
  branchprops.py                 branchprops.py-20061223204623-80lvm7pjrpsgk0dd-1
  cache.py                       cache.py-20070520185908-qbtlcet08bllgs0f-1
  repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
=== modified file 'branchprops.py'
--- a/branchprops.py	2008-02-03 14:52:23 +0000
+++ b/branchprops.py	2008-02-03 15:26:30 +0000
@@ -27,7 +27,7 @@
 class BranchPropertyList(CacheTable):
     """Simple class that retrieves file properties set on branches."""
     def __init__(self, log, cachedb=None):
-        super(BranchPropertyList, self).__init__(cachedb)
+        CacheTable.__init__(self, cachedb)
         self.log = log
 
     def _create_table(self):
@@ -91,21 +91,29 @@
 
         return proplist
 
-    def get_changed_property(self, path, revnum, name, default=None):
+    def get_changed_properties(self, path, revnum):
         """Get the contents of a Subversion file property.
 
         Will use the cache.
 
         :param path: Subversion path.
         :param revnum: Subversion revision number.
-        :param default: Default value to return if property wasn't found.
         :return: Contents of property or default if property didn't exist.
         """
         assert isinstance(revnum, int)
         assert isinstance(path, str)
-        if not self.touches_property(path, revnum, name):
-            return default
-        return self.get_property(path, revnum, name, default)
+        (prev_path, prev_revnum) = self.log.get_previous(path, revnum)
+        if prev_path is None and prev_revnum == -1:
+            previous = {}
+        else:
+            previous = self.get_properties(prev_path.encode("utf-8"), 
+                                          prev_revnum)
+        current = self.get_properties(path, revnum)
+        ret = {}
+        for key, val in current.items():
+            if previous.get(key) != val:
+                ret[key] = val
+        return ret
 
     def get_property(self, path, revnum, name, default=None):
         """Get the contents of a Subversion file property.

=== modified file 'cache.py'
--- a/cache.py	2008-02-03 14:52:23 +0000
+++ b/cache.py	2008-02-03 15:26:30 +0000
@@ -42,6 +42,7 @@
 """)
     return cache_dir
 
+
 def check_pysqlite_version(sqlite3):
     """Check that sqlite library is compatible.
 
@@ -66,6 +67,7 @@
 
 
 class CacheTable:
+    """Simple base class for SQLite-based caches."""
     def __init__(self, cache_db=None):
         if cache_db is None:
             self.cachedb = sqlite3.connect(":memory:")

=== modified file 'repository.py'
--- a/repository.py	2008-02-03 03:08:33 +0000
+++ b/repository.py	2008-02-03 15:26:30 +0000
@@ -280,8 +280,8 @@
         ancestry = [revision_id]
 
         svn_revprops = self.transport.revprop_list(revnum)
-        get_branch_fileprop = lambda name, default: self.branchprop_list.get_property(path, revnum, name, default)
-        ancestry.extend(mapping.get_rhs_ancestors(svn_revprops, get_branch_fileprop))
+        svn_fileprops = self.branchprop_list.get_properties(path, revnum)
+        ancestry.extend(mapping.get_rhs_ancestors(svn_revprops, svn_fileprops.get))
 
         if revnum > 0:
             for (branch, rev) in self.follow_branch(path, revnum - 1, mapping):
@@ -335,9 +335,9 @@
         (path, revnum, mapping) = self.lookup_revision_id(revid)
 
         svn_revprops = self.transport.revprop_list(revnum)
-        return mapping.import_fileid_map(svn_revprops, 
-                lambda name, default: self.branchprop_list.get_changed_property(path, revnum, name, default)
-                )
+        svn_fileprops = self.branchprop_list.get_changed_properties(path, revnum)
+
+        return mapping.import_fileid_map(svn_revprops, svn_fileprops.get)
 
     def _mainline_revision_parent(self, path, revnum, mapping):
         """Find the mainline parent of the specified revision.
@@ -395,7 +395,8 @@
             parent_ids.append(mainline_parent)
 
         if get_branch_fileprop is None:
-            get_branch_fileprop = lambda name, default: self.branchprop_list.get_changed_property(branch, revnum, name, default)
+            svn_fileprops = self.branchprop_list.get_changed_properties(branch, revnum)
+            get_branch_fileprop = svn_fileprops.get
 
         svn_revprops = self.transport.revprop_list(revnum)
 
@@ -418,9 +419,9 @@
 
         rev = LazySvnRevision(revision_id=revision_id, parent_ids=parent_ids)
         svn_revprops = self.transport.revprop_list(revnum)
+        svn_fileprops = self.branchprop_list.get_changed_properties(path, revnum)
 
-        mapping.import_revision(svn_revprops, 
-                lambda name, default: self.branchprop_list.get_changed_property(path, revnum, name, default), rev)
+        mapping.import_revision(svn_revprops, svn_fileprops.get, rev)
 
         return rev
 
@@ -443,6 +444,7 @@
         """
         assert isinstance(path, str)
         assert isinstance(revnum, int)
+        assert isinstance(mapping, BzrSvnMapping)
 
         # Look in the cache to see if it already has a revision id
         revid = self.revmap.lookup_branch_revnum(revnum, path, str(mapping.scheme))
@@ -456,8 +458,8 @@
             if num == svn.core.SVN_ERR_FS_NO_SUCH_REVISION:
                 raise NoSuchRevision(path, revnum)
             raise
-        (bzr_revno, revid) = mapping.get_revision_id(revprops, 
-                lambda name, default: self.branchprop_list.get_changed_property(path, revnum, name, default))
+        fileprops = self.branchprop_list.get_changed_properties(path, revnum)
+        (bzr_revno, revid) = mapping.get_revision_id(revprops, fileprops.get)
         # Or generate it
         if revid is None:
             revid = mapping.generate_revision_id(




More information about the bazaar-commits mailing list