Rev 1781: Use backoff mechanism for svk as well. in file:///data/jelmer/bzr-svn/trunk/

Jelmer Vernooij jelmer at samba.org
Tue Sep 2 11:11:45 BST 2008


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

------------------------------------------------------------
revno: 1781
revision-id: jelmer at samba.org-20080902101144-nsykrxuukvhrr132
parent: jelmer at samba.org-20080902094532-uvsc0zkuxilwvhhp
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Tue 2008-09-02 12:11:44 +0200
message:
  Use backoff mechanism for svk as well.
modified:
  repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
  revmeta.py                     revmeta.py-20080901215045-n8a6arqybs9ez5hl-1
  svk.py                         svk.py-20080201171509-m2eg9m6jrmlbwxg5-1
=== modified file 'repository.py'
--- a/repository.py	2008-09-02 09:45:32 +0000
+++ b/repository.py	2008-09-02 10:11:44 +0000
@@ -497,13 +497,15 @@
         return parent_map
 
     def _revmeta(self, path, revnum, changes=None, revprops=None, changed_fileprops=None, 
-                 consider_fileprops=True):
+                 consider_bzr_fileprops=True, consider_svk_fileprops=True):
         if (path, revnum) in self._revmeta_cache:
             cached = self._revmeta_cache[path,revnum]
             if changes is not None:
                 cached.paths = changes
-            if not consider_fileprops:
-                cached.consider_fileprops = False
+            if not consider_bzr_fileprops:
+                cached.consider_bzr_fileprops = False
+            if not consider_svk_fileprops:
+                cached.consider_svk_fileprops = False
             if cached._changed_fileprops is None:
                 cached._changed_fileprops = changed_fileprops
             return self._revmeta_cache[path,revnum]
@@ -513,7 +515,8 @@
 
         ret = revmeta.RevisionMetadata(self, path, revnum, changes, revprops, 
                                    changed_fileprops=changed_fileprops, 
-                                   consider_fileprops=consider_fileprops)
+                                   consider_bzr_fileprops=consider_bzr_fileprops,
+                                   consider_svk_fileprops=consider_svk_fileprops)
         self._revmeta_cache[path,revnum] = ret
         return ret
 
@@ -658,18 +661,30 @@
         """
         history_iter = self.iter_changes(branch_path, from_revnum, to_revnum, 
                                          mapping, pb=pb, limit=limit)
-        consider_fileprops = True
+        consider_bzr_fileprops = True
         fileprops_backoff = 0
+        consider_svk_fileprops = True
         for (bp, paths, revnum, revprops) in history_iter:
-            ret = self._revmeta(bp, revnum, paths, revprops, consider_fileprops=consider_fileprops)
-
-            if consider_fileprops and fileprops_backoff == 0:
-                ancestors = ret.estimate_bzr_ancestors()
-                if ancestors == 0:
-                    consider_fileprops = False
-                else:
-                    fileprops_backoff = ancestors - 1
-
+            ret = self._revmeta(bp, revnum, paths, revprops, consider_bzr_fileprops=consider_bzr_fileprops,
+                                consider_svk_fileprops=consider_svk_fileprops)
+
+            if ((consider_bzr_fileprops or consider_svk_fileprops) and 
+                    fileprops_backoff <= 0):
+                ancestors = 0
+                if consider_bzr_fileprops:
+                    bzr_ancestors = ret.estimate_bzr_fileprop_ancestors()
+                    if bzr_ancestors == 0:
+                        consider_bzr_fileprops = False
+                    else:
+                        ancestors = max(ancestors, bzr_ancestors)
+                if consider_svk_fileprops:
+                    svk_ancestors = ret.estimate_svk_fileprop_ancestors()
+                    if svk_ancestors == 0:
+                        consider_svk_fileprops = False
+                    else:
+                        ancestors = max(ancestors, svk_ancestors)
+
+            fileprops_backoff -= 1
             yield ret
 
     def get_config(self):

=== modified file 'revmeta.py'
--- a/revmeta.py	2008-09-02 09:45:32 +0000
+++ b/revmeta.py	2008-09-02 10:11:44 +0000
@@ -18,10 +18,10 @@
 from bzrlib.plugins.svn import changes, errors, properties
 from bzrlib.plugins.svn.mapping import is_bzr_revision_fileprops, is_bzr_revision_revprops, estimate_bzr_ancestors
 from bzrlib.plugins.svn.svk import (SVN_PROP_SVK_MERGE, svk_features_merged_since, 
-                 parse_svk_feature)
+                 parse_svk_feature, estimate_svk_ancestors)
 
 class RevisionMetadata(object):
-    def __init__(self, repository, branch_path, revnum, paths, revprops, changed_fileprops=None, consider_fileprops=True):
+    def __init__(self, repository, branch_path, revnum, paths, revprops, changed_fileprops=None, consider_bzr_fileprops=True, consider_svk_fileprops=True):
         self.repository = repository
         self.branch_path = branch_path
         self._paths = paths
@@ -29,7 +29,8 @@
         self.revprops = revprops
         self._changed_fileprops = changed_fileprops
         self.uuid = repository.uuid
-        self.consider_fileprops = consider_fileprops
+        self.consider_bzr_fileprops = consider_bzr_fileprops
+        self.consider_svk_fileprops = consider_svk_fileprops
 
     def __repr__(self):
         return "<RevisionMetadata for revision %d in repository %s>" % (self.revnum, self.repository.uuid)
@@ -73,11 +74,17 @@
         """Estimate how many ancestors with bzr file properties this revision has.
 
         """
-        if not self.consider_fileprops:
+        if not self.consider_bzr_fileprops:
             # This revisions descendant doesn't have bzr fileprops set, so this one can't have them either.
             return 0
         return estimate_bzr_ancestors(self.get_fileprops())
 
+    def estimate_svk_fileprop_ancestors(self):
+        if not self.consider_svk_fileprops:
+            # This revisions descendant doesn't have svk fileprops set, so this one can't have them either.
+            return 0
+        return estimate_svk_ancestors(self.get_fileprops())
+
     def is_bzr_revision(self):
         """Determine (with as few network requests as possible) if this is a bzr revision.
 
@@ -86,7 +93,7 @@
         order = []
         if self.repository.quick_log_revprops:
             order.append(lambda: is_bzr_revision_revprops(self.revprops))
-        if self.consider_fileprops:
+        if self.consider_bzr_fileprops:
             order.append(lambda: is_bzr_revision_fileprops(self.get_changed_fileprops()))
         # Only look for revprops if they could've been committed
         if (not self.repository.quick_log_revprops and 

=== modified file 'svk.py'
--- a/svk.py	2008-06-04 15:20:12 +0000
+++ b/svk.py	2008-09-02 10:11:44 +0000
@@ -59,3 +59,5 @@
     return "%s:/%s:%d" % (uuid, branch, revnum)
 
 
+def estimate_svk_ancestors(fileprops):
+    return len(fileprops.get(SVN_PROP_SVK_MERGE,"").splitlines())




More information about the bazaar-commits mailing list