Rev 463: Add externals check when opening branch. in file:///data/jelmer/bzr-svn/nestedtrees/
Jelmer Vernooij
jelmer at samba.org
Tue Jul 8 05:15:04 BST 2008
At file:///data/jelmer/bzr-svn/nestedtrees/
------------------------------------------------------------
revno: 463
revision-id: jelmer at samba.org-20080708041503-8dyqwzy8sl3pc9ei
parent: jelmer at samba.org-20080708034613-i6h7blv6o0snrvn5
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: nestedtrees
timestamp: Tue 2008-07-08 06:15:03 +0200
message:
Add externals check when opening branch.
modified:
branch.py svnbranch.py-20051017135706-11c749eb0dab04a7
=== modified file 'branch.py'
--- a/branch.py 2008-07-08 00:48:56 +0000
+++ b/branch.py 2008-07-08 04:15:03 +0000
@@ -20,14 +20,14 @@
from bzrlib.bzrdir import BzrDir
from bzrlib.errors import (NoSuchFile, DivergedBranches, NoSuchRevision,
NoSuchTag, NotBranchError, UnstackableBranchFormat,
- UnrelatedBranches)
+ UnrelatedBranches, RedirectRequested)
from bzrlib.inventory import (Inventory)
from bzrlib.revision import is_null, ensure_null, NULL_REVISION
from bzrlib.tag import BasicTags
from bzrlib.trace import mutter
from bzrlib.workingtree import WorkingTree
-from bzrlib.plugins.svn import core, wc
+from bzrlib.plugins.svn import core, properties, wc
from bzrlib.plugins.svn.auth import create_auth_baton
from bzrlib.plugins.svn.client import Client, get_config
from bzrlib.plugins.svn.commit import push
@@ -140,6 +140,31 @@
self.delete_tag(k)
+def check_path_with_externals(transport, path, revnum):
+ conn = transport.get_connection()
+ try:
+ pts = path.split("/")
+ for x in range(len(pts), 0, -1):
+ basepath = "/".join(pts[:x])
+ endpath = "/".join(pts[x:])
+ t = conn.check_path(basepath, revnum)
+ if endpath == "" and t != core.NODE_NONE:
+ return t
+ if t == core.NODE_FILE:
+ return core.NODE_NONE
+ if t == core.NODE_DIR:
+ (_, _, props) = conn.get_dir(basepath, revnum)
+ if not properties.PROP_EXTERNALS in props:
+ return core.NODE_NONE
+ externals = properties.parse_externals_description(urlutils.join(conn.url, basepath),
+ props[properties.PROP_EXTERNALS])
+ if not endpath in externals:
+ return core.NODE_NONE
+ raise RedirectRequested(urlutils.join(conn.url, path), externals[endpath][1])
+ finally:
+ transport.add_connection(conn)
+
+
class SvnBranch(Branch):
"""Maps to a Branch in a Subversion repository """
def __init__(self, repository, branch_path):
@@ -164,14 +189,17 @@
self._revmeta_cache = None
assert isinstance(self._branch_path, str)
try:
- revnum = self.get_revnum()
- if self.repository.transport.check_path(self._branch_path,
+ if check_path_with_externals(self.repository.transport, self._branch_path,
revnum) != core.NODE_DIR:
raise NotBranchError(self.base)
except SubversionException, (_, num):
if num == ERR_FS_NO_SUCH_REVISION:
raise NotBranchError(self.base)
raise
+ except RedirectRequested, e:
+ mutter("Redirected to %s", e.target)
+
+ revnum = self.get_revnum()
if not self.mapping.is_branch(branch_path):
raise NotSvnBranchPath(branch_path, mapping=self.mapping)
More information about the bazaar-commits
mailing list