Rev 1780: Back off checking for file properties. in file:///data/jelmer/bzr-svn/trunk/

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


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

------------------------------------------------------------
revno: 1780
revision-id: jelmer at samba.org-20080902094532-uvsc0zkuxilwvhhp
parent: jelmer at samba.org-20080902034031-trhsns72i57wmmcg
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Tue 2008-09-02 11:45:32 +0200
message:
  Back off checking for file properties.
modified:
  mapping.py                     mapping.py-20080128201303-6cp01phc0dmc0kiv-1
  repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
  revmeta.py                     revmeta.py-20080901215045-n8a6arqybs9ez5hl-1
  tests/mapping_implementations/test_repository.py test_repository.py-20080902013845-ity7d1ymye69sobm-2
=== modified file 'mapping.py'
--- a/mapping.py	2008-09-02 03:40:31 +0000
+++ b/mapping.py	2008-09-02 09:45:32 +0000
@@ -774,8 +774,14 @@
     return None
 
 
-def contains_bzr_fileprops(fileprops):
+def estimate_bzr_ancestors(fileprops):
+    found = []
+    for k, v in fileprops.items():
+        if k.startswith(SVN_PROP_BZR_REVISION_ID):
+            found.append(len(v.splitlines()))
+    if found != []:
+        return sorted(found, reverse=True)[0]
     for k in fileprops:
         if k.startswith(SVN_PROP_BZR_PREFIX):
-            return True
-    return False
+            return 1
+    return 0

=== modified file 'repository.py'
--- a/repository.py	2008-09-01 22:41:04 +0000
+++ b/repository.py	2008-09-02 09:45:32 +0000
@@ -659,11 +659,16 @@
         history_iter = self.iter_changes(branch_path, from_revnum, to_revnum, 
                                          mapping, pb=pb, limit=limit)
         consider_fileprops = True
+        fileprops_backoff = 0
         for (bp, paths, revnum, revprops) in history_iter:
             ret = self._revmeta(bp, revnum, paths, revprops, consider_fileprops=consider_fileprops)
 
-            if consider_fileprops:
-                consider_fileprops = ret.has_bzr_fileprop_ancestors()
+            if consider_fileprops and fileprops_backoff == 0:
+                ancestors = ret.estimate_bzr_ancestors()
+                if ancestors == 0:
+                    consider_fileprops = False
+                else:
+                    fileprops_backoff = ancestors - 1
 
             yield ret
 

=== modified file 'revmeta.py'
--- a/revmeta.py	2008-09-02 00:27:00 +0000
+++ b/revmeta.py	2008-09-02 09:45:32 +0000
@@ -16,7 +16,7 @@
 from bzrlib.revision import NULL_REVISION, Revision
 
 from bzrlib.plugins.svn import changes, errors, properties
-from bzrlib.plugins.svn.mapping import is_bzr_revision_fileprops, is_bzr_revision_revprops, contains_bzr_fileprops
+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)
 
@@ -69,16 +69,14 @@
             lhs_parent = self.repository.lhs_revision_parent(self.branch_path, self.revnum, mapping)
         return lhs_parent
 
-    def has_bzr_fileprop_ancestors(self):
-        """Check whether there are any bzr file properties present in this revision.
+    def estimate_bzr_fileprop_ancestors(self):
+        """Estimate how many ancestors with bzr file properties this revision has.
 
-        This can tell us whether one of the ancestors of this revision is a 
-        fileproperty-based bzr revision.
         """
         if not self.consider_fileprops:
             # This revisions descendant doesn't have bzr fileprops set, so this one can't have them either.
-            return False
-        return contains_bzr_fileprops(self.get_fileprops())
+            return 0
+        return estimate_bzr_ancestors(self.get_fileprops())
 
     def is_bzr_revision(self):
         """Determine (with as few network requests as possible) if this is a bzr revision.

=== modified file 'tests/mapping_implementations/test_repository.py'
--- a/tests/mapping_implementations/test_repository.py	2008-09-02 03:40:31 +0000
+++ b/tests/mapping_implementations/test_repository.py	2008-09-02 09:45:32 +0000
@@ -101,6 +101,8 @@
         dc.close()
 
         repos = Repository.open(repos_url)
+        if mapping.supports_roundtripping():
+            raise TestNotApplicable()
         revid = repos.generate_revision_id(1, "", repos.get_mapping())
         self.assertEquals("someid", revid)
 
@@ -112,6 +114,8 @@
         dc.close()
 
         repos = Repository.open(repos_url)
+        if mapping.supports_roundtripping():
+            raise TestNotApplicable()
         revid = repos.generate_revision_id(1, "", repos.get_mapping())
         self.assertEquals(
                 repos.get_mapping().revision_id_foreign_to_bzr((repos.uuid, 1, "")),




More information about the bazaar-commits mailing list