Move fileprop revid detection to mapping.
authorJelmer Vernooij <jelmer@samba.org>
Sat, 6 Sep 2008 21:56:26 +0000 (23:56 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Sat, 6 Sep 2008 21:56:26 +0000 (23:56 +0200)
mapping.py
revids.py
revmeta.py
transport.py

index e1b18bc78ed6d6bbafd96bb70d1bec1abd8a5556..ea8859d4411fdcc04b32412d3737ca9ccd71fa66 100644 (file)
@@ -718,3 +718,17 @@ def estimate_bzr_ancestors(fileprops):
         if k.startswith(SVN_PROP_BZR_PREFIX):
             return 1
     return 0
+
+
+def get_roundtrip_ancestor_revids(fileprops):
+    for propname, propvalue in fileprops.items():
+        if not propname.startswith(SVN_PROP_BZR_REVISION_ID):
+            continue
+        mapping_name = propname[len(SVN_PROP_BZR_REVISION_ID):]
+        for line in propvalue.splitlines():
+            try:
+                (revno, revid) = parse_revid_property(line)
+            except svn_errors.InvalidPropertyValue, ie:
+                mutter(str(ie))
+            yield (revid, revno, mapping_name)
+
index 2e56255f2a052bf838da31d2fc0daa62ddcb04a8..613f6b80132cd46888ffa4594c4ab3bd594c0c17 100644 (file)
--- a/revids.py
+++ b/revids.py
@@ -83,17 +83,10 @@ class RevidMap(object):
             revids = set()
             try:
                 revmeta = self.repos._revmeta_provider.get_revision(branch, revno)
-                for propname, propvalue in revmeta.get_fileprops().items():
-                    if not propname.startswith(SVN_PROP_BZR_REVISION_ID):
-                        continue
-                    mapping_name = propname[len(SVN_PROP_BZR_REVISION_ID):]
-                    for line in propvalue.splitlines():
-                        try:
-                            revids.add((parse_revid_property(line), mapping_name))
-                        except InvalidPropertyValue, ie:
-                            mutter(str(ie))
+                for revid, revno, mapping_name in revmeta.get_roundtrip_ancestor_revids():
+                    revids.add(((revno, revid), mapping_name))
             except SubversionException, (_, ERR_FS_NOT_DIRECTORY):
-                    continue
+                continue
 
             # If there are any new entries that are not yet in the cache, 
             # add them
index bb0c37755ab27e1e845253c7299dff668672cdad..b2685387a61de15e7f397aadb172eb2c573dd9c5 100644 (file)
@@ -17,7 +17,7 @@ from bzrlib import errors, ui
 from bzrlib.revision import NULL_REVISION, Revision
 
 from bzrlib.plugins.svn import changes, core, errors as svn_errors, logwalker, properties
-from bzrlib.plugins.svn.mapping import is_bzr_revision_fileprops, is_bzr_revision_revprops, estimate_bzr_ancestors, SVN_REVPROP_BZR_SIGNATURE
+from bzrlib.plugins.svn.mapping import is_bzr_revision_fileprops, is_bzr_revision_revprops, estimate_bzr_ancestors, SVN_REVPROP_BZR_SIGNATURE, get_roundtrip_ancestor_revids
 from bzrlib.plugins.svn.svk import (SVN_PROP_SVK_MERGE, svk_features_merged_since, 
                  parse_svk_feature, estimate_svk_ancestors)
 
@@ -265,6 +265,12 @@ class RevisionMetadata(object):
     def get_fileid_map(self, mapping):
         return mapping.import_fileid_map(self.get_revprops(), self.get_changed_fileprops())
 
+    def get_roundtrip_ancestor_revids(self):
+        if self.metabranch is not None and not self.metabranch.consider_bzr_fileprops(self):
+            # This revisions descendant doesn't have bzr fileprops set, so this one can't have them either.
+            return 0
+        return iter(get_roundtrip_ancestor_revids(self.get_fileprops()))
+
     def __hash__(self):
         return hash((self.__class__, self.uuid, self.branch_path, self.revnum))
 
index 1e0d2a2ff3e8f8b3cf2318c609a7d47f3834c1ce..3b2d7ba954e0ab35be47301e1f5bf96d3fc3ebba 100644 (file)
@@ -28,7 +28,7 @@ from bzrlib.plugins.svn import ra
 from bzrlib.plugins.svn.auth import create_auth_baton
 from bzrlib.plugins.svn.client import get_config
 from bzrlib.plugins.svn.core import SubversionException
-from bzrlib.plugins.svn.errors import convert_svn_error, NoSvnRepositoryPresent, ERR_BAD_URL, ERR_RA_SVN_REPOS_NOT_FOUND, ERR_FS_ALREADY_EXISTS, ERR_FS_NOT_DIRECTORY, ERR_RA_DAV_RELOCATED, ERR_RA_DAV_PATH_NOT_FOUND
+from bzrlib.plugins.svn.errors import convert_svn_error, NoSvnRepositoryPresent, ERR_BAD_URL, ERR_RA_SVN_REPOS_NOT_FOUND, ERR_FS_ALREADY_EXISTS, ERR_FS_NOT_DIRECTORY, ERR_RA_DAV_RELOCATED, ERR_RA_DAV_PATH_NOT_FOUND, ERR_UNKNOWN_CAPABILITY
 import urlparse
 import urllib
 
@@ -408,6 +408,10 @@ class SvnRaTransport(Transport):
         try:
             try:
                 self.capabilities[cap] = conn.has_capability(cap)
+            except SubversionException, (msg, num):
+                if num != ERR_UNKNOWN_CAPABILITY:
+                    raise
+                self.capabilities[cap] = None
             except NotImplementedError:
                 self.capabilities[cap] = None # None for unknown
             return self.capabilities[cap]