Rev 416: Split out current transport into various protocol-specific transports. in file:///home/jelmer/bzr-svn/native/
Jelmer Vernooij
jelmer at samba.org
Fri Feb 2 20:13:32 GMT 2007
At file:///home/jelmer/bzr-svn/native/
------------------------------------------------------------
revno: 416
revision-id: jelmer at samba.org-20070202201250-i5eq4yp3uikabjuz
parent: jelmer at samba.org-20070202194945-ozoc7dfmlxb4kcv0
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: native
timestamp: Fri 2007-02-02 21:12:50 +0100
message:
Split out current transport into various protocol-specific transports.
added:
transport_file.py transport_file.py-20070202195533-c5p5vi6yie11tsax-1
transport_http.py transport_http.py-20070202195533-c5p5vi6yie11tsax-2
modified:
__init__.py __init__.py-20051008155114-eae558e6cf149e1d
transport.py transport.py-20060406231150-b3472d06b3a0818d
transport_svn.py transport_svn.py-20070117114238-elvrsw9ohhz0rtz4-1
=== added file 'transport_file.py'
--- a/transport_file.py 1970-01-01 00:00:00 +0000
+++ b/transport_file.py 2007-02-02 20:12:50 +0000
@@ -0,0 +1,25 @@
+# Copyright (C) 2006-2007 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
+
+from transport import SvnRaTransport
+
+# 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 SvnRaTransportFile(SvnRaTransport):
+ """Subversion Local File Transport."""
=== added file 'transport_http.py'
--- a/transport_http.py 1970-01-01 00:00:00 +0000
+++ b/transport_http.py 2007-02-02 20:12:50 +0000
@@ -0,0 +1,26 @@
+# Copyright (C) 2006-2007 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
+
+from transport import SvnRaTransport
+
+# 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 SvnRaTransportHttp(SvnRaTransport):
+ """Subversion HTTP/Webdav Transport."""
=== modified file '__init__.py'
--- a/__init__.py 2007-01-29 15:19:34 +0000
+++ b/__init__.py 2007-02-02 20:12:50 +0000
@@ -91,12 +91,12 @@
import branch
import convert
import format
-import transport
+import transport_svn
import checkout
from bzrlib.transport import register_transport
-register_transport('svn://', transport.SvnRaTransport)
-register_transport('svn+', transport.SvnRaTransport)
+register_transport('svn://', transport_svn.SvnRaTransportSvn)
+register_transport('svn+', transport_svn.SvnRaTransportSvn)
from bzrlib.bzrdir import BzrDirFormat
=== modified file 'transport.py'
--- a/transport.py 2007-02-02 19:48:10 +0000
+++ b/transport.py 2007-02-02 20:12:50 +0000
@@ -75,7 +75,21 @@
if isinstance(bzr_transport, SvnRaTransport):
return bzr_transport
- return SvnRaTransport(bzr_transport.base)
+ if (bzr_transport.base.startswith('http://') or
+ bzr_transport.base.startswith('https://')):
+ from transport_http import SvnRaTransportHttp
+ return SvnRaTransportHttp(bzr_transport.base)
+
+ if (bzr_transport.base.startswith('svn://') or
+ bzr_transport.base.startswith('svn+')):
+ from transport_svn import SvnRaTransportSvn
+ return SvnRaTransportSvn(bzr_transport.base)
+
+ if bzr_transport.base.startswith('file://'):
+ from transport_file import SvnRaTransportFile
+ return SvnRaTransportFile(bzr_transport.base)
+
+ assert 0, "Unknown url scheme passed to get_svn_ra_transport()"
def bzr_to_svn_url(url):
=== modified file 'transport_svn.py'
--- a/transport_svn.py 2007-01-22 18:36:21 +0000
+++ b/transport_svn.py 2007-02-02 20:12:50 +0000
@@ -16,174 +16,11 @@
from transport import SvnRaTransport
-import urllib
+# 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 SvnRaTransportSvn(SvnRaTransport):
- """Fake transport for Subversion-related namespaces.
-
- This implements just as much of Transport as is necessary
- to fool Bazaar. """
- def __init__(self, url=""):
- self.pool = Pool()
- self.is_locked = False
- # FIXME: Parse URL
-
- # FIXME: Connect to
- bzr_url = url
- self.svn_url = bzr_to_svn_url(url)
- Transport.__init__(self, bzr_url)
-
- try:
- mutter('opening SVN RA connection to %r' % self.svn_url)
- self._ra = svn.client.open_ra_session(self.svn_url.encode('utf8'),
- self._client, self.pool)
- except SubversionException, (msg, num):
- if num in (svn.core.SVN_ERR_RA_ILLEGAL_URL, \
- svn.core.SVN_ERR_RA_LOCAL_REPOS_OPEN_FAILED, \
- svn.core.SVN_ERR_BAD_URL):
- raise NotBranchError(path=url)
- raise
-
- def lock(self):
- assert (not self.is_locked)
- self.is_locked = True
-
- def unlock(self):
- assert self.is_locked
- self.is_locked = False
-
- def has(self, relpath):
- """See Transport.has()."""
- # TODO: Raise TransportNotPossible here instead and
- # catch it in bzrdir.py
- return False
-
- def get(self, relpath):
- """See Transport.get()."""
- # TODO: Raise TransportNotPossible here instead and
- # catch it in bzrdir.py
- raise NoSuchFile(path=relpath)
-
- def stat(self, relpath):
- """See Transport.stat()."""
- raise TransportNotPossible('stat not supported on Subversion')
-
- @need_lock
- def get_uuid(self):
- mutter('svn get-uuid')
- return svn.ra.get_uuid(self._ra)
-
- @need_lock
- def get_repos_root(self):
- mutter("svn get-repos-root")
- return svn.ra.get_repos_root(self._ra)
-
- @need_lock
- def get_latest_revnum(self):
- mutter("svn get-latest-revnum")
- return svn.ra.get_latest_revnum(self._ra)
-
- @need_lock
- def do_switch(self, switch_rev, switch_target, recurse, switch_url, *args, **kwargs):
- mutter('svn switch -r %d %r -> %r' % (switch_rev, switch_target, switch_url))
- return svn.ra.do_switch(self._ra, switch_rev, switch_target, recurse, switch_url, *args, **kwargs)
-
- @need_lock
- def get_log(self, path, from_revnum, to_revnum, *args, **kwargs):
- mutter('svn log %r:%r %r' % (from_revnum, to_revnum, path))
- return svn.ra.get_log(self._ra, [path], from_revnum, to_revnum, *args, **kwargs)
-
- @need_lock
- def reparent(self, url):
- url = url.rstrip("/")
- if url == self.svn_url:
- return
- self.base = url
- self.svn_url = url
- if hasattr(svn.ra, 'reparent'):
- mutter('svn reparent %r' % url)
- svn.ra.reparent(self._ra, url, self.pool)
- else:
- self._ra = svn.client.open_ra_session(self.svn_url.encode('utf8'),
- self._client, self.pool)
- @need_lock
- def get_dir(self, path, revnum, pool=None, kind=False):
- mutter("svn ls -r %d '%r'" % (revnum, path))
- path = path.rstrip("/")
- # ra_dav backends fail with strange errors if the path starts with a
- # slash while other backends don't.
- assert len(path) == 0 or path[0] != "/"
- if hasattr(svn.ra, 'get_dir2'):
- fields = 0
- if kind:
- fields += svn.core.SVN_DIRENT_KIND
- return svn.ra.get_dir2(self._ra, path, revnum, fields)
- else:
- return svn.ra.get_dir(self._ra, path, revnum)
-
- def list_dir(self, relpath):
- assert len(relpath) == 0 or relpath[0] != "/"
- if relpath == ".":
- relpath = ""
- try:
- (dirents, _, _) = self.get_dir(relpath.rstrip("/"),
- self.get_latest_revnum())
- except SubversionException, (msg, num):
- if num == svn.core.SVN_ERR_FS_NOT_DIRECTORY:
- raise NoSuchFile(relpath)
- raise
- return dirents.keys()
-
- @need_lock
- def check_path(self, path, revnum, *args, **kwargs):
- assert len(path) == 0 or path[0] != "/"
- mutter("svn check_path -r%d %s" % (revnum, path))
- return svn.ra.check_path(self._ra, path, revnum, *args, **kwargs)
-
- @need_lock
- def mkdir(self, relpath, mode=None):
- path = "%s/%s" % (self.svn_url, relpath)
- try:
- svn.client.mkdir([path.encode("utf-8")], self._client)
- except SubversionException, (msg, num):
- if num == svn.core.SVN_ERR_FS_NOT_FOUND:
- raise NoSuchFile(path)
- if num == svn.core.SVN_ERR_FS_ALREADY_EXISTS:
- raise FileExists(path)
- raise
-
- @need_lock
- def do_update(self, revnum, path, *args, **kwargs):
- mutter('svn update -r %r %r' % (revnum, path))
- return svn.ra.do_update(self._ra, revnum, path, *args, **kwargs)
-
- @need_lock
- def get_commit_editor(self, *args, **kwargs):
- return svn.ra.get_commit_editor(self._ra, *args, **kwargs)
-
- 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_write(self, relpath):
- """See Transport.lock_write()."""
- return self.PhonyLock()
-
- def lock_read(self, relpath):
- """See Transport.lock_read()."""
- return self.PhonyLock()
-
- def clone(self, offset=None):
- """See Transport.clone()."""
- if offset is None:
- return SvnRaTransport(self.base)
-
- return SvnRaTransport(urlutils.join(self.base, offset))
+ """Subversion Native Protocol Transport."""
More information about the bazaar-commits
mailing list