Rev 462: Move use of ra module to separate python module. in file:///data/jelmer/bzr-svn/native/

Jelmer Vernooij jelmer at samba.org
Wed Mar 19 22:49:08 GMT 2008


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

------------------------------------------------------------
revno: 462
revision-id: jelmer at samba.org-20080319224907-r1ykcykl72th2yl4
parent: jelmer at samba.org-20080319171558-jhhfiam12yey1n4o
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: native
timestamp: Wed 2008-03-19 23:49:07 +0100
message:
  Move use of ra module to separate python module.
added:
  transport_native.py            transport_native.py-20080319211931-3h5daico23jg05i1-1
modified:
  transport.py                   transport.py-20060406231150-b3472d06b3a0818d
  transport_file.py              transport_file.py-20070202195533-c5p5vi6yie11tsax-1
  transport_http.py              transport_http.py-20070202195533-c5p5vi6yie11tsax-2
=== modified file 'transport.py'
--- a/transport.py	2008-03-19 17:15:58 +0000
+++ b/transport.py	2008-03-19 22:49:07 +0000
@@ -16,26 +16,9 @@
 """Simple transport for accessing Subversion smart servers."""
 
 from bzrlib import debug, urlutils
-from bzrlib.errors import (NoSuchFile, NotBranchError, TransportNotPossible, 
-                           FileExists, NotLocalUrl, InvalidURL)
-from bzrlib.trace import mutter
+from bzrlib.errors import (NoSuchFile, TransportNotPossible)
 from bzrlib.transport import Transport
 
-from core import SubversionException
-from auth import create_auth_baton
-import ra
-import core
-import constants
-
-from errors import convert_svn_error, NoSvnRepositoryPresent
-
-svn_config = core.get_config(None)
-
-def get_client_string():
-    """Return a string that can be send as part of the User Agent string."""
-    return "bzr%s+bzr-svn%s" % (bzrlib.__version__, bzrlib.plugins.svn.__version__)
-
-
 # Don't run any tests on SvnTransport as it is not intended to be 
 # a full implementation of Transport
 def get_test_permutations():
@@ -48,7 +31,9 @@
         return bzr_transport
 
     if (bzr_transport.base.startswith('http://') or 
-        bzr_transport.base.startswith('https://')):
+        bzr_transport.base.startswith('https://') or
+        bzr_transport.base.startswith('svn+http://') or 
+        bzr_transport.base.startswith('svn+https://')):
         from transport_http import SvnRaTransportHttp
         return SvnRaTransportHttp(bzr_transport.base)
 
@@ -61,7 +46,7 @@
         from transport_file import SvnRaTransportFile
         return SvnRaTransportFile(bzr_transport.base)
 
-    assert 0, "Unknown url scheme passed to get_svn_ra_transport()"
+    raise AssertionError("Unknown url scheme passed to get_svn_ra_transport()")
 
 
 def bzr_to_svn_url(url):
@@ -70,7 +55,6 @@
     This will possibly remove the svn+ prefix.
     """
     if (url.startswith("svn+http://") or 
-        url.startswith("svn+file://") or
         url.startswith("svn+https://")):
         url = url[len("svn+"):] # Skip svn+
 
@@ -83,36 +67,8 @@
     
     This implements just as much of Transport as is necessary 
     to fool Bazaar. """
-    @convert_svn_error
     def __init__(self, url="", _backing_url=None):
-        bzr_url = url
-        self.svn_url = bzr_to_svn_url(url)
-        self._root = None
-        # _backing_url is an evil hack so the root directory of a repository 
-        # can be accessed on some HTTP repositories. 
-        if _backing_url is None:
-            _backing_url = self.svn_url
-        self._backing_url = _backing_url.rstrip("/")
-        Transport.__init__(self, bzr_url)
-
-        try:
-            self.mutter('opening SVN RA connection to %r' % self._backing_url)
-            self._ra = ra.RemoteAccess(self._backing_url.encode('utf8'))
-            # FIXME: Callbacks
-            # FIXME: self._ra = create_auth_baton()
-        except SubversionException, (_, num):
-            if num in (constants.ERR_RA_SVN_REPOS_NOT_FOUND,):
-                raise NoSvnRepositoryPresent(url=url)
-            if num == constants.ERR_BAD_URL:
-                raise InvalidURL(url)
-            raise
-
-        from bzrlib.plugins.svn import lazy_check_versions
-        lazy_check_versions()
-
-    def mutter(self, text):
-        if 'transport' in debug.debug_flags:
-            mutter(text)
+        raise NotImplementedError
 
     def has(self, relpath):
         """See Transport.has()."""
@@ -130,184 +86,69 @@
         """See Transport.stat()."""
         raise TransportNotPossible('stat not supported on Subversion')
 
-    @convert_svn_error
     def get_uuid(self):
-        self.mutter('svn get-uuid')
-        return self._ra.get_uuid()
+        raise NotImplementedError
 
     def get_repos_root(self):
-        root = self.get_svn_repos_root()
-        if (self.base.startswith("svn+http:") or 
-            self.base.startswith("svn+https:")):
-            return "svn+%s" % root
-        return root
+        raise NotImplementedError
 
-    @convert_svn_error
     def get_svn_repos_root(self):
-        if self._root is None:
-            self.mutter("svn get-repos-root")
-            self._root = self._ra.get_repos_root()
-        return self._root
+        raise NotImplementedError
 
-    @convert_svn_error
     def get_latest_revnum(self):
-        self.mutter("svn get-latest-revnum")
-        return self._ra.get_latest_revnum()
+        raise NotImplementedError
 
-    @convert_svn_error
     def do_switch(self, switch_rev, recurse, switch_url, editor):
-        self._open_real_transport()
-        self.mutter('svn switch -r %d -> %r' % (switch_rev, switch_url))
-        return self._ra.do_switch(switch_rev, "", recurse, switch_url, editor)
+        raise NotImplementedError
 
-    @convert_svn_error
     def get_log(self, path, from_revnum, to_revnum, limit, discover_changed_paths, 
                 strict_node_history, revprops, rcvr):
-        self.mutter('svn log %r:%r %r' % (from_revnum, to_revnum, path))
-        return self._ra.get_log(rcvr, [self._request_path(path)], 
-                              from_revnum, to_revnum, limit, discover_changed_paths, 
-                              strict_node_history, revprops)
-
-    def _open_real_transport(self):
-        if self._backing_url != self.svn_url:
-            self.reparent(self.base)
-        assert self._backing_url == self.svn_url
+        raise NotImplementedError
 
     def reparent_root(self):
-        if self._is_http_transport():
-            self.svn_url = self.get_svn_repos_root()
-            self.base = self.get_repos_root()
-        else:
-            self.reparent(self.get_repos_root())
+        raise NotImplementedError
 
-    @convert_svn_error
     def change_rev_prop(self, revnum, name, value):
-        self.mutter('svn revprop -r%d --set %s=%s' % (revnum, name, value))
-        self._ra.change_rev_prop(revnum, name, value)
+        raise NotImplementedError
 
-    @convert_svn_error
     def reparent(self, url):
-        url = url.rstrip("/")
-        self.base = url
-        self.svn_url = bzr_to_svn_url(url)
-        if self.svn_url == self._backing_url:
-            return
-        if hasattr(self._ra, 'reparent'):
-            self.mutter('svn reparent %r' % url)
-            self._ra.reparent(self.svn_url)
-        else:
-            self.mutter('svn reparent (reconnect) %r' % url)
-            self._ra = self._client.open_ra_session(self.svn_url.encode('utf8'))
-        self._backing_url = self.svn_url
+        raise NotImplementedError
 
-    @convert_svn_error
     def get_dir(self, path, revnum, kind=False):
-        self.mutter("svn ls -r %d '%r'" % (revnum, path))
-        assert len(path) == 0 or path[0] != "/"
-        path = self._request_path(path)
-        # ra_dav backends fail with strange errors if the path starts with a 
-        # slash while other backends don't.
-        fields = 0
-        if kind:
-            fields += core.SVN_DIRENT_KIND
-        return self._ra.get_dir(path, revnum, fields)
-
-    def _request_path(self, relpath):
-        if self._backing_url == self.svn_url:
-            return relpath.strip("/")
-        newrelpath = urlutils.join(
-                urlutils.relative_url(self._backing_url+"/", self.svn_url+"/"),
-                relpath).strip("/")
-        self.mutter('request path %r -> %r' % (relpath, newrelpath))
-        return newrelpath
-
-    @convert_svn_error
+        raise NotImplementedError
+
     def list_dir(self, relpath):
-        assert len(relpath) == 0 or relpath[0] != "/"
-        if relpath == ".":
-            relpath = ""
-        try:
-            (dirents, _, _) = self.get_dir(self._request_path(relpath),
-                                           self.get_latest_revnum())
-        except SubversionException, (msg, num):
-            if num == constants.ERR_FS_NOT_DIRECTORY:
-                raise NoSuchFile(relpath)
-            raise
-        return dirents.keys()
+        raise NotImplementedError
 
-    @convert_svn_error
     def get_lock(self, path):
-        return self._ra.get_lock(path)
-
-    class SvnLock:
-        def __init__(self, transport, tokens):
-            self._tokens = tokens
-            self._transport = transport
-
-        def unlock(self):
-            self.transport.unlock(self.locks)
-
-    @convert_svn_error
+        raise NotImplementedError
+
     def unlock(self, locks, break_lock=False):
-        def lock_cb(baton, path, do_lock, lock, ra_err):
-            pass
-        return self._ra.unlock(locks, break_lock, lock_cb)
+        raise NotImplementedError
 
-    @convert_svn_error
     def lock_write(self, path_revs, comment=None, steal_lock=False):
-        return self.PhonyLock() # FIXME
-        tokens = {}
-        def lock_cb(baton, path, do_lock, lock, ra_err):
-            tokens[path] = lock
-        self._ra.lock(path_revs, comment, steal_lock, lock_cb)
-        return SvnLock(self, tokens)
+        raise NotImplementedError
 
-    @convert_svn_error
     def check_path(self, path, revnum):
-        assert len(path) == 0 or path[0] != "/"
-        path = self._request_path(path)
-        self.mutter("svn check_path -r%d %s" % (revnum, path))
-        return self._ra.check_path(path.encode('utf-8'), revnum)
+        raise NotImplementedError
 
-    @convert_svn_error
     def mkdir(self, relpath, mode=None):
-        assert len(relpath) == 0 or relpath[0] != "/"
-        path = urlutils.join(self.svn_url, relpath)
-        try:
-            self._client.mkdir([path.encode("utf-8")])
-        except SubversionException, (msg, num):
-            if num == constants.ERR_FS_NOT_FOUND:
-                raise NoSuchFile(path)
-            if num == constants.ERR_FS_ALREADY_EXISTS:
-                raise FileExists(path)
-            raise
+        raise NotImplementedError
 
-    @convert_svn_error
     def replay(self, revision, low_water_mark, editor, send_deltas=True):
-        self._open_real_transport()
-        self.mutter('svn replay -r%r:%r' % (low_water_mark, revision))
-        self._ra.replay(revision, low_water_mark, editor, send_deltas)
+        raise NotImplementedError
 
-    @convert_svn_error
     def do_update(self, revnum, recurse, editor):
-        self._open_real_transport()
-        self.mutter('svn update -r %r' % revnum)
-        return self._ra.do_update(revnum, "", recurse, editor)
+        raise NotImplementedError
 
-    @convert_svn_error
     def has_capability(self, cap):
-        return self._ra.has_capability(cap)
+        raise NotImplementedError
 
-    @convert_svn_error
     def revprop_list(self, revnum):
-        self.mutter('svn revprop-list -r %r' % revnum)
-        return self._ra.rev_proplist(revnum)
+        raise NotImplementedError
 
-    @convert_svn_error
     def get_commit_editor(self, revprops, done_cb, lock_token, keep_locks):
-        self._open_real_transport()
-        return self._ra.get_commit_editor(revprops, done_cb, lock_token, 
-                                          keep_locks)
+        raise NotImplementedError
 
     def listable(self):
         """See Transport.listable().
@@ -325,29 +166,14 @@
         """See Transport.lock_read()."""
         return self.PhonyLock()
 
-    def _is_http_transport(self):
-        return (self.svn_url.startswith("http://") or 
-                self.svn_url.startswith("https://"))
-
     def clone_root(self):
-        if self._is_http_transport():
-            return SvnRaTransport(self.get_repos_root(), 
-                                  bzr_to_svn_url(self.base))
-        return SvnRaTransport(self.get_repos_root())
+        raise NotImplementedError
 
     def clone(self, offset=None):
-        """See Transport.clone()."""
-        if offset is None:
-            return SvnRaTransport(self.base)
-
-        return SvnRaTransport(urlutils.join(self.base, offset))
+        raise NotImplementedError
 
     def local_abspath(self, relpath):
-        """See Transport.local_abspath()."""
-        absurl = self.abspath(relpath)
-        if self.base.startswith("file:///"):
-            return urlutils.local_path_from_url(absurl)
-        raise NotLocalUrl(absurl)
+        raise NotImplementedError
 
     def abspath(self, relpath):
         """See Transport.abspath()."""

=== modified file 'transport_file.py'
--- a/transport_file.py	2007-02-02 20:12:50 +0000
+++ b/transport_file.py	2008-03-19 22:49:07 +0000
@@ -14,6 +14,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+import repos
 from transport import SvnRaTransport
 
 # Don't run any tests on SvnTransport as it is not intended to be 
@@ -23,3 +24,81 @@
 
 class SvnRaTransportFile(SvnRaTransport):
     """Subversion Local File Transport."""
+    def __init__(self, url=""):
+        # FIXME: Convert URL to path
+        self.fs = repos.Repository(local_path)
+
+    def get_uuid(self):
+        return self.fs.get_uuid()
+
+    def get_repos_root(self):
+        raise NotImplementedError
+
+    def get_svn_repos_root(self):
+        raise NotImplementedError
+
+    def get_latest_revnum(self):
+        raise NotImplementedError
+
+    def do_switch(self, switch_rev, recurse, switch_url, editor):
+        raise NotImplementedError
+
+    def get_log(self, path, from_revnum, to_revnum, limit, discover_changed_paths, 
+                strict_node_history, revprops, rcvr):
+        raise NotImplementedError
+
+    def reparent_root(self):
+        raise NotImplementedError
+
+    def change_rev_prop(self, revnum, name, value):
+        raise NotImplementedError
+
+    def reparent(self, url):
+        raise NotImplementedError
+
+    def get_dir(self, path, revnum, kind=False):
+        raise NotImplementedError
+
+    def list_dir(self, relpath):
+        raise NotImplementedError
+
+    def get_lock(self, path):
+        raise NotImplementedError
+
+    def unlock(self, locks, break_lock=False):
+        raise NotImplementedError
+
+    def lock_write(self, path_revs, comment=None, steal_lock=False):
+        raise NotImplementedError
+
+    def check_path(self, path, revnum):
+        raise NotImplementedError
+
+    def mkdir(self, relpath, mode=None):
+        raise NotImplementedError
+
+    def replay(self, revision, low_water_mark, editor, send_deltas=True):
+        raise NotImplementedError
+
+    def do_update(self, revnum, recurse, editor):
+        raise NotImplementedError
+
+    def has_capability(self, cap):
+        raise NotImplementedError
+
+    def revprop_list(self, revnum):
+        raise NotImplementedError
+
+    def get_commit_editor(self, revprops, done_cb, lock_token, keep_locks):
+        raise NotImplementedError
+
+    def clone_root(self):
+        raise NotImplementedError
+
+    def clone(self, offset=None):
+        raise NotImplementedError
+
+    def local_abspath(self, relpath):
+        raise NotImplementedError
+
+

=== modified file 'transport_http.py'
--- a/transport_http.py	2007-02-02 20:12:50 +0000
+++ b/transport_http.py	2008-03-19 22:49:07 +0000
@@ -14,13 +14,40 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+"""Implementation of the Subversion Webdav RA protocol."""
+
 from transport import SvnRaTransport
 
+from bzrlib.transport.http import (
+    _urllib,
+    _urllib2_wrappers,
+    )
+
 # Don't run any tests on SvnTransport as it is not intended to be 
 # a full implementation of Transport
 def get_test_permutations():
     return []
 
 
+class REPORTRequest(_urllib2_wrappers.Request):
+    pass
+
+class PROPFINDRequest(_urllib2_wrappers.Request):
+    pass
+
+
+class SubversionResponse(_urllib2_wrappers.Response):
+    """Custom SubversionResponse.
+    """
+
+
+class SubversionHTTPSConnection(_urllib2_wrappers.HTTPSConnection):
+    response_class = SubversionResponse
+
+
+class SubversionHTTPConnection(_urllib2_wrappers.HTTPConnection):
+    response_class = SubversionResponse
+
+
 class SvnRaTransportHttp(SvnRaTransport):
     """Subversion HTTP/Webdav Transport."""

=== added file 'transport_native.py'
--- a/transport_native.py	1970-01-01 00:00:00 +0000
+++ b/transport_native.py	2008-03-19 22:49:07 +0000
@@ -0,0 +1,302 @@
+# Copyright (C) 2006 Jelmer Vernooij <jelmer at samba.org>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+"""Simple transport for accessing Subversion smart servers."""
+
+from bzrlib import debug, urlutils
+from bzrlib.errors import (NoSuchFile, NotBranchError, TransportNotPossible, 
+                           FileExists, NotLocalUrl, InvalidURL)
+from bzrlib.trace import mutter
+from bzrlib.transport import Transport
+
+from core import SubversionException
+from auth import create_auth_baton
+import ra
+import core
+import constants
+
+from errors import convert_svn_error, NoSvnRepositoryPresent
+
+svn_config = core.get_config(None)
+
+# Don't run any tests on SvnTransport as it is not intended to be 
+# a full implementation of Transport
+def get_test_permutations():
+    return []
+
+
+def get_client_string():
+    """Return a string that can be send as part of the User Agent string."""
+    return "bzr%s+bzr-svn%s" % (bzrlib.__version__, bzrlib.plugins.svn.__version__)
+
+
+class SvnNativeRaTransport(Transport):
+    """Fake transport for Subversion-related namespaces.
+    
+    This implements just as much of Transport as is necessary 
+    to fool Bazaar. """
+    @convert_svn_error
+    def __init__(self, url="", _backing_url=None):
+        bzr_url = url
+        self.svn_url = bzr_to_svn_url(url)
+        self._root = None
+        # _backing_url is an evil hack so the root directory of a repository 
+        # can be accessed on some HTTP repositories. 
+        if _backing_url is None:
+            _backing_url = self.svn_url
+        self._backing_url = _backing_url.rstrip("/")
+        Transport.__init__(self, bzr_url)
+
+        try:
+            self.mutter('opening SVN RA connection to %r' % self._backing_url)
+            self._ra = ra.RemoteAccess(self._backing_url.encode('utf8'))
+            # FIXME: Callbacks
+            # FIXME: self._ra = create_auth_baton()
+        except SubversionException, (_, num):
+            if num in (constants.ERR_RA_SVN_REPOS_NOT_FOUND,):
+                raise NoSvnRepositoryPresent(url=url)
+            if num == constants.ERR_BAD_URL:
+                raise InvalidURL(url)
+            raise
+
+        from bzrlib.plugins.svn import lazy_check_versions
+        lazy_check_versions()
+
+    def mutter(self, text):
+        if 'transport' in debug.debug_flags:
+            mutter(text)
+
+    @convert_svn_error
+    def get_uuid(self):
+        self.mutter('svn get-uuid')
+        return self._ra.get_uuid()
+
+    def get_repos_root(self):
+        root = self.get_svn_repos_root()
+        if (self.base.startswith("svn+http:") or 
+            self.base.startswith("svn+https:")):
+            return "svn+%s" % root
+        return root
+
+    @convert_svn_error
+    def get_svn_repos_root(self):
+        if self._root is None:
+            self.mutter("svn get-repos-root")
+            self._root = self._ra.get_repos_root()
+        return self._root
+
+    @convert_svn_error
+    def get_latest_revnum(self):
+        self.mutter("svn get-latest-revnum")
+        return self._ra.get_latest_revnum()
+
+    @convert_svn_error
+    def do_switch(self, switch_rev, recurse, switch_url, editor):
+        self._open_real_transport()
+        self.mutter('svn switch -r %d -> %r' % (switch_rev, switch_url))
+        return self._ra.do_switch(switch_rev, "", recurse, switch_url, editor)
+
+    @convert_svn_error
+    def get_log(self, path, from_revnum, to_revnum, limit, discover_changed_paths, 
+                strict_node_history, revprops, rcvr):
+        self.mutter('svn log %r:%r %r' % (from_revnum, to_revnum, path))
+        return self._ra.get_log(rcvr, [self._request_path(path)], 
+                              from_revnum, to_revnum, limit, discover_changed_paths, 
+                              strict_node_history, revprops)
+
+    def _open_real_transport(self):
+        if self._backing_url != self.svn_url:
+            self.reparent(self.base)
+        assert self._backing_url == self.svn_url
+
+    def reparent_root(self):
+        if self._is_http_transport():
+            self.svn_url = self.get_svn_repos_root()
+            self.base = self.get_repos_root()
+        else:
+            self.reparent(self.get_repos_root())
+
+    @convert_svn_error
+    def change_rev_prop(self, revnum, name, value):
+        self.mutter('svn revprop -r%d --set %s=%s' % (revnum, name, value))
+        self._ra.change_rev_prop(revnum, name, value)
+
+    @convert_svn_error
+    def reparent(self, url):
+        url = url.rstrip("/")
+        self.base = url
+        self.svn_url = bzr_to_svn_url(url)
+        if self.svn_url == self._backing_url:
+            return
+        if hasattr(self._ra, 'reparent'):
+            self.mutter('svn reparent %r' % url)
+            self._ra.reparent(self.svn_url)
+        else:
+            self.mutter('svn reparent (reconnect) %r' % url)
+            self._ra = self._client.open_ra_session(self.svn_url.encode('utf8'))
+        self._backing_url = self.svn_url
+
+    @convert_svn_error
+    def get_dir(self, path, revnum, kind=False):
+        self.mutter("svn ls -r %d '%r'" % (revnum, path))
+        assert len(path) == 0 or path[0] != "/"
+        path = self._request_path(path)
+        # ra_dav backends fail with strange errors if the path starts with a 
+        # slash while other backends don't.
+        fields = 0
+        if kind:
+            fields += core.SVN_DIRENT_KIND
+        return self._ra.get_dir(path, revnum, fields)
+
+    def _request_path(self, relpath):
+        if self._backing_url == self.svn_url:
+            return relpath.strip("/")
+        newrelpath = urlutils.join(
+                urlutils.relative_url(self._backing_url+"/", self.svn_url+"/"),
+                relpath).strip("/")
+        self.mutter('request path %r -> %r' % (relpath, newrelpath))
+        return newrelpath
+
+    @convert_svn_error
+    def list_dir(self, relpath):
+        assert len(relpath) == 0 or relpath[0] != "/"
+        if relpath == ".":
+            relpath = ""
+        try:
+            (dirents, _, _) = self.get_dir(self._request_path(relpath),
+                                           self.get_latest_revnum())
+        except SubversionException, (msg, num):
+            if num == constants.ERR_FS_NOT_DIRECTORY:
+                raise NoSuchFile(relpath)
+            raise
+        return dirents.keys()
+
+    @convert_svn_error
+    def get_lock(self, path):
+        return self._ra.get_lock(path)
+
+    class SvnLock:
+        def __init__(self, transport, tokens):
+            self._tokens = tokens
+            self._transport = transport
+
+        def unlock(self):
+            self.transport.unlock(self.locks)
+
+    @convert_svn_error
+    def unlock(self, locks, break_lock=False):
+        def lock_cb(baton, path, do_lock, lock, ra_err):
+            pass
+        return self._ra.unlock(locks, break_lock, lock_cb)
+
+    @convert_svn_error
+    def lock_write(self, path_revs, comment=None, steal_lock=False):
+        return self.PhonyLock() # FIXME
+        tokens = {}
+        def lock_cb(baton, path, do_lock, lock, ra_err):
+            tokens[path] = lock
+        self._ra.lock(path_revs, comment, steal_lock, lock_cb)
+        return SvnLock(self, tokens)
+
+    @convert_svn_error
+    def check_path(self, path, revnum):
+        assert len(path) == 0 or path[0] != "/"
+        path = self._request_path(path)
+        self.mutter("svn check_path -r%d %s" % (revnum, path))
+        return self._ra.check_path(path.encode('utf-8'), revnum)
+
+    @convert_svn_error
+    def mkdir(self, relpath, mode=None):
+        assert len(relpath) == 0 or relpath[0] != "/"
+        path = urlutils.join(self.svn_url, relpath)
+        try:
+            self._client.mkdir([path.encode("utf-8")])
+        except SubversionException, (msg, num):
+            if num == constants.ERR_FS_NOT_FOUND:
+                raise NoSuchFile(path)
+            if num == constants.ERR_FS_ALREADY_EXISTS:
+                raise FileExists(path)
+            raise
+
+    @convert_svn_error
+    def replay(self, revision, low_water_mark, editor, send_deltas=True):
+        self._open_real_transport()
+        self.mutter('svn replay -r%r:%r' % (low_water_mark, revision))
+        self._ra.replay(revision, low_water_mark, editor, send_deltas)
+
+    @convert_svn_error
+    def do_update(self, revnum, recurse, editor):
+        self._open_real_transport()
+        self.mutter('svn update -r %r' % revnum)
+        return self._ra.do_update(revnum, "", recurse, editor)
+
+    @convert_svn_error
+    def has_capability(self, cap):
+        return self._ra.has_capability(cap)
+
+    @convert_svn_error
+    def revprop_list(self, revnum):
+        self.mutter('svn revprop-list -r %r' % revnum)
+        return self._ra.rev_proplist(revnum)
+
+    @convert_svn_error
+    def get_commit_editor(self, revprops, done_cb, lock_token, keep_locks):
+        self._open_real_transport()
+        return self._ra.get_commit_editor(revprops, done_cb, lock_token, 
+                                          keep_locks)
+
+    def listable(self):
+        """See Transport.listable().
+        """
+        return True
+
+    # There is no real way to do locking directly on the transport 
+    # nor is there a need to as the remote server will take care of 
+    # locking
+    class PhonyLock:
+        def unlock(self):
+            pass
+
+    def lock_read(self, relpath):
+        """See Transport.lock_read()."""
+        return self.PhonyLock()
+
+    def _is_http_transport(self):
+        return (self.svn_url.startswith("http://") or 
+                self.svn_url.startswith("https://"))
+
+    def clone_root(self):
+        if self._is_http_transport():
+            return SvnRaTransport(self.get_repos_root(), 
+                                  bzr_to_svn_url(self.base))
+        return SvnRaTransport(self.get_repos_root())
+
+    def clone(self, offset=None):
+        """See Transport.clone()."""
+        if offset is None:
+            return SvnRaTransport(self.base)
+
+        return SvnRaTransport(urlutils.join(self.base, offset))
+
+    def local_abspath(self, relpath):
+        """See Transport.local_abspath()."""
+        absurl = self.abspath(relpath)
+        if self.base.startswith("file:///"):
+            return urlutils.local_path_from_url(absurl)
+        raise NotLocalUrl(absurl)
+
+    def abspath(self, relpath):
+        """See Transport.abspath()."""
+        return urlutils.join(self.base, relpath)




More information about the bazaar-commits mailing list