Rev 6045: (jelmer) Add get_transport_from_url and get_transport_from_path functions. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Mon Jul 25 14:01:33 UTC 2011
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6045 [merge]
revision-id: pqm at pqm.ubuntu.com-20110725140128-croovh96z0rs57yy
parent: pqm at pqm.ubuntu.com-20110725110854-j5yzc917io5sam3e
parent: jelmer at samba.org-20110725123226-s0e8t1yn6agdsyjj
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2011-07-25 14:01:28 +0000
message:
(jelmer) Add get_transport_from_url and get_transport_from_path functions.
(Jelmer Vernooij)
modified:
bzrlib/bundle/__init__.py changeset.py-20050513021216-b02ab57fb9738913
bzrlib/config.py config.py-20051011043216-070c74f4e9e338e8
bzrlib/msgeditor.py msgeditor.py-20050901111708-ef6d8de98f5d8f2f
bzrlib/mutabletree.py mutabletree.py-20060906023413-4wlkalbdpsxi2r4y-2
bzrlib/plugins/launchpad/account.py account.py-20071011033320-50y6vfftywf4yllw-1
bzrlib/smart/server.py server.py-20061110062051-chzu10y32vx8gvur-1
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/http_utils.py HTTPTestUtil.py-20050914180604-247d3aafb7a43343
bzrlib/tests/per_branch/test_branch.py testbranch.py-20050711070244-121d632bc37d7253
bzrlib/tests/per_branch/test_push.py test_push.py-20070130153159-fhfap8uoifevg30j-1
bzrlib/tests/test_transport.py testtransport.py-20050718175618-e5cdb99f4555ddce
bzrlib/transport/__init__.py transport.py-20050711165921-4978aa7ce1285ad5
bzrlib/transport/gio_transport.py __init__.py-20100430125031-jb4f7q7mtyz55kz3-2
bzrlib/transport/sftp.py sftp.py-20051019050329-ab48ce71b7e32dfe
doc/en/release-notes/bzr-2.5.txt bzr2.5.txt-20110708125756-587p0hpw7oke4h05-1
=== modified file 'bzrlib/bundle/__init__.py'
--- a/bzrlib/bundle/__init__.py 2011-01-26 19:34:58 +0000
+++ b/bzrlib/bundle/__init__.py 2011-07-23 16:33:38 +0000
@@ -54,7 +54,7 @@
exclude_trailing_slash=False)
if not filename:
raise errors.NotABundle('A directory cannot be a bundle')
- return _mod_transport.get_transport(url)
+ return _mod_transport.get_transport_from_url(url)
try:
bytef, transport = _mod_transport.do_catching_redirections(
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2011-07-11 12:03:39 +0000
+++ b/bzrlib/config.py 2011-07-23 16:33:38 +0000
@@ -2562,7 +2562,7 @@
class GlobalStore(LockableIniFileStore):
def __init__(self, possible_transports=None):
- t = transport.get_transport(config_dir(),
+ t = transport.get_transport_from_path(config_dir(),
possible_transports=possible_transports)
super(GlobalStore, self).__init__(t, 'bazaar.conf')
@@ -2570,7 +2570,7 @@
class LocationStore(LockableIniFileStore):
def __init__(self, possible_transports=None):
- t = transport.get_transport(config_dir(),
+ t = transport.get_transport_from_path(config_dir(),
possible_transports=possible_transports)
super(LocationStore, self).__init__(t, 'locations.conf')
=== modified file 'bzrlib/msgeditor.py'
--- a/bzrlib/msgeditor.py 2011-06-09 11:52:35 +0000
+++ b/bzrlib/msgeditor.py 2011-07-23 16:33:38 +0000
@@ -144,7 +144,7 @@
if not msgfilename:
return None
basename = osutils.basename(msgfilename)
- msg_transport = transport.get_transport(osutils.dirname(msgfilename))
+ msg_transport = transport.get_transport_from_path(osutils.dirname(msgfilename))
reference_content = msg_transport.get_bytes(basename)
if not _run_editor(msgfilename):
return None
=== modified file 'bzrlib/mutabletree.py'
--- a/bzrlib/mutabletree.py 2011-06-19 02:24:39 +0000
+++ b/bzrlib/mutabletree.py 2011-07-23 16:33:38 +0000
@@ -718,7 +718,7 @@
if kind == 'directory' and directory != '':
try:
- transport = _mod_transport.get_transport(abspath)
+ transport = _mod_transport.get_transport_from_path(abspath)
controldir.ControlDirFormat.find_format(transport)
sub_tree = True
except errors.NotBranchError:
=== modified file 'bzrlib/plugins/launchpad/account.py'
--- a/bzrlib/plugins/launchpad/account.py 2010-06-20 11:18:38 +0000
+++ b/bzrlib/plugins/launchpad/account.py 2011-07-23 16:33:38 +0000
@@ -100,7 +100,7 @@
uploaded SSH keys.
"""
if _transport is None:
- _transport = transport.get_transport(LAUNCHPAD_BASE)
+ _transport = transport.get_transport_from_url(LAUNCHPAD_BASE)
try:
data = _transport.get_bytes('~%s/+sshkeys' % username)
=== modified file 'bzrlib/smart/server.py'
--- a/bzrlib/smart/server.py 2011-05-28 09:10:36 +0000
+++ b/bzrlib/smart/server.py 2011-07-23 16:33:38 +0000
@@ -330,14 +330,14 @@
chroot_server = chroot.ChrootServer(transport)
chroot_server.start_server()
self.cleanups.append(chroot_server.stop_server)
- transport = _mod_transport.get_transport(chroot_server.get_url())
+ transport = _mod_transport.get_transport_from_url(chroot_server.get_url())
if self.base_path is not None:
# Decorate the server's backing transport with a filter that can
# expand homedirs.
expand_userdirs = self._make_expand_userdirs_filter(transport)
expand_userdirs.start_server()
self.cleanups.append(expand_userdirs.stop_server)
- transport = _mod_transport.get_transport(expand_userdirs.get_url())
+ transport = _mod_transport.get_transport_from_url(expand_userdirs.get_url())
self.transport = transport
def _make_smart_server(self, host, port, inet):
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py 2011-07-25 02:51:30 +0000
+++ b/bzrlib/tests/__init__.py 2011-07-25 11:19:19 +0000
@@ -1161,7 +1161,7 @@
def permit_dir(self, name):
"""Permit a directory to be used by this test. See permit_url."""
- name_transport = _mod_transport.get_transport(name)
+ name_transport = _mod_transport.get_transport_from_path(name)
self.permit_url(name)
self.permit_url(name_transport.base)
@@ -1246,7 +1246,7 @@
self.addCleanup(transport_server.stop_server)
# Obtain a real transport because if the server supplies a password, it
# will be hidden from the base on the client side.
- t = _mod_transport.get_transport(transport_server.get_url())
+ t = _mod_transport.get_transport_from_url(transport_server.get_url())
# Some transport servers effectively chroot the backing transport;
# others like SFTPServer don't - users of the transport can walk up the
# transport to read the entire backing transport. This wouldn't matter
@@ -2364,7 +2364,7 @@
:param relpath: a path relative to the base url.
"""
- t = _mod_transport.get_transport(self.get_url(relpath))
+ t = _mod_transport.get_transport_from_url(self.get_url(relpath))
self.assertFalse(t.is_readonly())
return t
@@ -2595,7 +2595,7 @@
backing_server = self.get_server()
smart_server = test_server.SmartTCPServer_for_testing()
self.start_server(smart_server, backing_server)
- remote_transport = _mod_transport.get_transport(smart_server.get_url()
+ remote_transport = _mod_transport.get_transport_from_url(smart_server.get_url()
).clone(path)
return remote_transport
@@ -2618,14 +2618,15 @@
def setUp(self):
super(TestCaseWithMemoryTransport, self).setUp()
# Ensure that ConnectedTransport doesn't leak sockets
- def get_transport_with_cleanup(*args, **kwargs):
- t = orig_get_transport(*args, **kwargs)
+ def get_transport_from_url_with_cleanup(*args, **kwargs):
+ t = orig_get_transport_from_url(*args, **kwargs)
if isinstance(t, _mod_transport.ConnectedTransport):
self.addCleanup(t.disconnect)
return t
- orig_get_transport = self.overrideAttr(_mod_transport, 'get_transport',
- get_transport_with_cleanup)
+ orig_get_transport_from_url = self.overrideAttr(
+ _mod_transport, 'get_transport_from_url',
+ get_transport_from_url_with_cleanup)
self._make_test_root()
self.addCleanup(os.chdir, os.getcwdu())
self.makeAndChdirToTestDir()
=== modified file 'bzrlib/tests/http_utils.py'
--- a/bzrlib/tests/http_utils.py 2011-06-07 11:11:08 +0000
+++ b/bzrlib/tests/http_utils.py 2011-07-23 16:33:38 +0000
@@ -51,12 +51,12 @@
def do_POST(self):
"""Hand the request off to a smart server instance."""
- backing = transport.get_transport(
+ backing = transport.get_transport_from_path(
self.server.test_case_server._home_dir)
chroot_server = chroot.ChrootServer(backing)
chroot_server.start_server()
try:
- t = transport.get_transport(chroot_server.get_url())
+ t = transport.get_transport_from_url(chroot_server.get_url())
self.do_POST_inner(t)
finally:
chroot_server.stop_server()
@@ -153,7 +153,7 @@
return self._adjust_url(base, relpath)
def get_secondary_transport(self, relpath=None):
- t = transport.get_transport(self.get_secondary_url(relpath))
+ t = transport.get_transport_from_url(self.get_secondary_url(relpath))
self.assertTrue(t.is_readonly())
return t
@@ -257,7 +257,7 @@
return self._adjust_url(base, relpath)
def get_old_transport(self, relpath=None):
- t = transport.get_transport(self.get_old_url(relpath))
+ t = transport.get_transport_from_url(self.get_old_url(relpath))
self.assertTrue(t.is_readonly())
return t
@@ -266,7 +266,7 @@
return self._adjust_url(base, relpath)
def get_new_transport(self, relpath=None):
- t = transport.get_transport(self.get_new_url(relpath))
+ t = transport.get_transport_from_url(self.get_new_url(relpath))
self.assertTrue(t.is_readonly())
return t
=== modified file 'bzrlib/tests/per_branch/test_branch.py'
--- a/bzrlib/tests/per_branch/test_branch.py 2011-05-13 12:51:05 +0000
+++ b/bzrlib/tests/per_branch/test_branch.py 2011-07-23 16:33:38 +0000
@@ -673,7 +673,7 @@
return
# supported formats must be able to init and open
t = self.get_transport()
- readonly_t = transport.get_transport(self.get_readonly_url())
+ readonly_t = transport.get_transport_from_url(self.get_readonly_url())
made_branch = self.make_branch('.')
self.assertIsInstance(made_branch, _mod_branch.Branch)
=== modified file 'bzrlib/tests/per_branch/test_push.py'
--- a/bzrlib/tests/per_branch/test_push.py 2011-05-14 20:01:04 +0000
+++ b/bzrlib/tests/per_branch/test_push.py 2011-07-23 16:33:38 +0000
@@ -424,7 +424,7 @@
def test_empty_branch_api(self):
"""The branch_obj.push API should make a limited number of HPSS calls.
"""
- t = transport.get_transport(self.smart_server.get_url()).clone('target')
+ t = transport.get_transport_from_url(self.smart_server.get_url()).clone('target')
target = branch.Branch.open_from_transport(t)
self.empty_branch.push(target)
self.assertEqual(
=== modified file 'bzrlib/tests/test_transport.py'
--- a/bzrlib/tests/test_transport.py 2011-07-22 11:06:10 +0000
+++ b/bzrlib/tests/test_transport.py 2011-07-25 11:19:19 +0000
@@ -16,6 +16,7 @@
from cStringIO import StringIO
+import os
import subprocess
import sys
import threading
@@ -38,6 +39,7 @@
pathfilter,
readonly,
)
+import bzrlib.transport.trace
from bzrlib.tests import (
features,
test_server,
@@ -89,7 +91,7 @@
transport.register_lazy_transport(
'foo', 'bzrlib.tests.test_transport', 'BadTransportHandler')
try:
- transport.get_transport('foo://fooserver/foo')
+ transport.get_transport_from_url('foo://fooserver/foo')
except errors.UnsupportedProtocol, e:
e_str = str(e)
self.assertEquals('Unsupported protocol'
@@ -109,13 +111,13 @@
'foo', 'bzrlib.tests.test_transport', 'BackupTransportHandler')
transport.register_lazy_transport(
'foo', 'bzrlib.tests.test_transport', 'BadTransportHandler')
- t = transport.get_transport('foo://fooserver/foo')
+ t = transport.get_transport_from_url('foo://fooserver/foo')
self.assertTrue(isinstance(t, BackupTransportHandler))
def test_ssh_hints(self):
"""Transport ssh:// should raise an error pointing out bzr+ssh://"""
try:
- transport.get_transport('ssh://fooserver/foo')
+ transport.get_transport_from_url('ssh://fooserver/foo')
except errors.UnsupportedProtocol, e:
e_str = str(e)
self.assertEquals('Unsupported protocol'
@@ -245,7 +247,7 @@
server.start_server()
url = server.get_url()
self.assertTrue(url in transport.transport_list_registry)
- t = transport.get_transport(url)
+ t = transport.get_transport_from_url(url)
del t
server.stop_server()
self.assertFalse(url in transport.transport_list_registry)
@@ -366,9 +368,9 @@
def test_abspath(self):
# The abspath is always relative to the chroot_url.
server = chroot.ChrootServer(
- transport.get_transport('memory:///foo/bar/'))
+ transport.get_transport_from_url('memory:///foo/bar/'))
self.start_server(server)
- t = transport.get_transport(server.get_url())
+ t = transport.get_transport_from_url(server.get_url())
self.assertEqual(server.get_url(), t.abspath('/'))
subdir_t = t.clone('subdir')
@@ -376,9 +378,9 @@
def test_clone(self):
server = chroot.ChrootServer(
- transport.get_transport('memory:///foo/bar/'))
+ transport.get_transport_from_url('memory:///foo/bar/'))
self.start_server(server)
- t = transport.get_transport(server.get_url())
+ t = transport.get_transport_from_url(server.get_url())
# relpath from root and root path are the same
relpath_cloned = t.clone('foo')
abspath_cloned = t.clone('/foo')
@@ -393,13 +395,13 @@
This is so that it is not possible to escape a chroot by doing::
url = chroot_transport.base
parent_url = urlutils.join(url, '..')
- new_t = transport.get_transport(parent_url)
+ new_t = transport.get_transport_from_url(parent_url)
"""
server = chroot.ChrootServer(
- transport.get_transport('memory:///path/subpath'))
+ transport.get_transport_from_url('memory:///path/subpath'))
self.start_server(server)
- t = transport.get_transport(server.get_url())
- new_t = transport.get_transport(t.base)
+ t = transport.get_transport_from_url(server.get_url())
+ new_t = transport.get_transport_from_url(t.base)
self.assertEqual(t.server, new_t.server)
self.assertEqual(t.base, new_t.base)
@@ -410,12 +412,12 @@
This is so that it is not possible to escape a chroot by doing::
url = chroot_transport.base
parent_url = urlutils.join(url, '..')
- new_t = transport.get_transport(parent_url)
+ new_t = transport.get_transport_from_url(parent_url)
"""
server = chroot.ChrootServer(
- transport.get_transport('memory:///path/'))
+ transport.get_transport_from_url('memory:///path/'))
self.start_server(server)
- t = transport.get_transport(server.get_url())
+ t = transport.get_transport_from_url(server.get_url())
self.assertRaises(
errors.InvalidURLJoin, urlutils.join, t.base, '..')
@@ -457,10 +459,10 @@
def test_abspath(self):
# The abspath is always relative to the base of the backing transport.
server = pathfilter.PathFilteringServer(
- transport.get_transport('memory:///foo/bar/'),
+ transport.get_transport_from_url('memory:///foo/bar/'),
lambda x: x)
server.start_server()
- t = transport.get_transport(server.get_url())
+ t = transport.get_transport_from_url(server.get_url())
self.assertEqual(server.get_url(), t.abspath('/'))
subdir_t = t.clone('subdir')
@@ -475,10 +477,10 @@
if filter_func is None:
filter_func = lambda x: x
server = pathfilter.PathFilteringServer(
- transport.get_transport('memory:///foo/bar/'), filter_func)
+ transport.get_transport_from_url('memory:///foo/bar/'), filter_func)
server.start_server()
self.addCleanup(server.stop_server)
- return transport.get_transport(server.get_url())
+ return transport.get_transport_from_url(server.get_url())
def test__filter(self):
# _filter (with an identity func as filter_func) always returns
@@ -528,10 +530,10 @@
otherwise) the filtering by doing::
url = filtered_transport.base
parent_url = urlutils.join(url, '..')
- new_t = transport.get_transport(parent_url)
+ new_t = transport.get_transport_from_url(parent_url)
"""
t = self.make_pf_transport()
- new_t = transport.get_transport(t.base)
+ new_t = transport.get_transport_from_url(t.base)
self.assertEqual(t.server, new_t.server)
self.assertEqual(t.base, new_t.base)
@@ -550,7 +552,7 @@
# connect to '.' via http which is not listable
server = HttpServer()
self.start_server(server)
- t = transport.get_transport('readonly+' + server.get_url())
+ t = transport.get_transport_from_url('readonly+' + server.get_url())
self.assertIsInstance(t, readonly.ReadonlyTransportDecorator)
self.assertEqual(False, t.listable())
self.assertEqual(True, t.is_readonly())
@@ -589,7 +591,7 @@
# the url should be decorated appropriately
self.assertStartsWith(server.get_url(), 'fakenfs+')
# and we should be able to get a transport for it
- t = transport.get_transport(server.get_url())
+ t = transport.get_transport_from_url(server.get_url())
# which must be a FakeNFSTransportDecorator instance.
self.assertIsInstance(t, fakenfs.FakeNFSTransportDecorator)
@@ -672,7 +674,7 @@
base_url = self._server.get_url()
url = self._adjust_url(base_url, relpath)
# try getting the transport via the regular interface:
- t = transport.get_transport(url)
+ t = transport.get_transport_from_url(url)
# vila--20070607 if the following are commented out the test suite
# still pass. Is this really still needed or was it a forgotten
# temporary fix ?
@@ -683,6 +685,34 @@
return t
+class TestTransportFromPath(tests.TestCaseInTempDir):
+
+ def test_with_path(self):
+ t = transport.get_transport_from_path(self.test_dir)
+ self.assertIsInstance(t, local.LocalTransport)
+ self.assertEquals(t.base.rstrip("/"),
+ urlutils.local_path_to_url(self.test_dir))
+
+ def test_with_url(self):
+ t = transport.get_transport_from_path("file:")
+ self.assertIsInstance(t, local.LocalTransport)
+ self.assertEquals(t.base.rstrip("/"),
+ urlutils.local_path_to_url(os.path.join(self.test_dir, "file:")))
+
+
+class TestTransportFromUrl(tests.TestCaseInTempDir):
+
+ def test_with_path(self):
+ self.assertRaises(errors.InvalidURL, transport.get_transport_from_url,
+ self.test_dir)
+
+ def test_with_url(self):
+ url = urlutils.local_path_to_url(self.test_dir)
+ t = transport.get_transport_from_url(url)
+ self.assertIsInstance(t, local.LocalTransport)
+ self.assertEquals(t.base.rstrip("/"), url)
+
+
class TestLocalTransports(tests.TestCase):
def test_get_transport_from_abspath(self):
@@ -815,40 +845,40 @@
def test_reuse_same_transport(self):
possible_transports = []
- t1 = transport.get_transport('http://foo/',
+ t1 = transport.get_transport_from_url('http://foo/',
possible_transports=possible_transports)
self.assertEqual([t1], possible_transports)
- t2 = transport.get_transport('http://foo/',
+ t2 = transport.get_transport_from_url('http://foo/',
possible_transports=[t1])
self.assertIs(t1, t2)
# Also check that final '/' are handled correctly
- t3 = transport.get_transport('http://foo/path/')
- t4 = transport.get_transport('http://foo/path',
+ t3 = transport.get_transport_from_url('http://foo/path/')
+ t4 = transport.get_transport_from_url('http://foo/path',
possible_transports=[t3])
self.assertIs(t3, t4)
- t5 = transport.get_transport('http://foo/path')
- t6 = transport.get_transport('http://foo/path/',
+ t5 = transport.get_transport_from_url('http://foo/path')
+ t6 = transport.get_transport_from_url('http://foo/path/',
possible_transports=[t5])
self.assertIs(t5, t6)
def test_don_t_reuse_different_transport(self):
- t1 = transport.get_transport('http://foo/path')
- t2 = transport.get_transport('http://bar/path',
+ t1 = transport.get_transport_from_url('http://foo/path')
+ t2 = transport.get_transport_from_url('http://bar/path',
possible_transports=[t1])
self.assertIsNot(t1, t2)
class TestTransportTrace(tests.TestCase):
- def test_get(self):
- t = transport.get_transport('trace+memory://')
+ def test_decorator(self):
+ t = transport.get_transport_from_url('trace+memory://')
self.assertIsInstance(
t, bzrlib.transport.trace.TransportTraceDecorator)
def test_clone_preserves_activity(self):
- t = transport.get_transport('trace+memory://')
+ t = transport.get_transport_from_url('trace+memory://')
t2 = t.clone('.')
self.assertTrue(t is not t2)
self.assertTrue(t._activity is t2._activity)
@@ -858,7 +888,7 @@
# still won't cause a test failure when the top level Transport API
# changes; so there is little return doing that.
def test_get(self):
- t = transport.get_transport('trace+memory:///')
+ t = transport.get_transport_from_url('trace+memory:///')
t.put_bytes('foo', 'barish')
t.get('foo')
expected_result = []
@@ -870,7 +900,7 @@
self.assertEqual(expected_result, t._activity)
def test_readv(self):
- t = transport.get_transport('trace+memory:///')
+ t = transport.get_transport_from_url('trace+memory:///')
t.put_bytes('foo', 'barish')
list(t.readv('foo', [(0, 1), (3, 2)],
adjust_for_latency=True, upper_limit=6))
=== modified file 'bzrlib/transport/__init__.py'
--- a/bzrlib/transport/__init__.py 2011-07-22 11:05:08 +0000
+++ b/bzrlib/transport/__init__.py 2011-07-25 11:19:19 +0000
@@ -1586,25 +1586,30 @@
return location
-def get_transport(base, possible_transports=None):
- """Open a transport to access a URL or directory.
-
- :param base: either a URL or a directory name.
-
+def get_transport_from_path(path, possible_transports=None):
+ """Open a transport for a local path.
+
+ :param path: Local path as byte or unicode string
+ :return: Transport object for path
+ """
+ return get_transport_from_url(urlutils.local_path_to_url(path),
+ possible_transports)
+
+
+def get_transport_from_url(url, possible_transports=None):
+ """Open a transport to access a URL.
+
+ :param base: a URL
:param transports: optional reusable transports list. If not None, created
transports will be added to the list.
:return: A new transport optionally sharing its connection with one of
possible_transports.
"""
- if base is None:
- base = '.'
- base = location_to_url(base)
-
transport = None
if possible_transports is not None:
for t in possible_transports:
- t_same_connection = t._reuse_for(base)
+ t_same_connection = t._reuse_for(url)
if t_same_connection is not None:
# Add only new transports
if t_same_connection not in possible_transports:
@@ -1613,15 +1618,33 @@
last_err = None
for proto, factory_list in transport_list_registry.items():
- if proto is not None and base.startswith(proto):
- transport, last_err = _try_transport_factories(base, factory_list)
+ if proto is not None and url.startswith(proto):
+ transport, last_err = _try_transport_factories(url, factory_list)
if transport:
if possible_transports is not None:
if transport in possible_transports:
raise AssertionError()
possible_transports.append(transport)
return transport
- raise errors.UnsupportedProtocol(base, last_err)
+ if not urlutils.is_url(url):
+ raise errors.InvalidURL(path=url)
+ raise errors.UnsupportedProtocol(url, last_err)
+
+
+def get_transport(base, possible_transports=None):
+ """Open a transport to access a URL or directory.
+
+ :param base: either a URL or a directory name.
+
+ :param transports: optional reusable transports list. If not None, created
+ transports will be added to the list.
+
+ :return: A new transport optionally sharing its connection with one of
+ possible_transports.
+ """
+ if base is None:
+ base = '.'
+ return get_transport_from_url(location_to_url(base), possible_transports)
def _try_transport_factories(base, factory_list):
=== modified file 'bzrlib/transport/gio_transport.py'
--- a/bzrlib/transport/gio_transport.py 2011-05-27 10:02:53 +0000
+++ b/bzrlib/transport/gio_transport.py 2011-07-23 16:33:06 +0000
@@ -24,15 +24,10 @@
supported by gio.
"""
from cStringIO import StringIO
-import getpass
import os
import random
-import socket
import stat
-import urllib
import time
-import sys
-import getpass
import urlparse
from bzrlib import (
@@ -49,12 +44,11 @@
deprecated_passed,
warn,
)
-from bzrlib.trace import mutter, warning
+from bzrlib.trace import mutter
from bzrlib.transport import (
FileStream,
ConnectedTransport,
_file_streams,
- Server,
)
from bzrlib.tests.test_server import TestServer
=== modified file 'bzrlib/transport/sftp.py'
--- a/bzrlib/transport/sftp.py 2011-06-28 21:47:24 +0000
+++ b/bzrlib/transport/sftp.py 2011-07-23 16:33:38 +0000
@@ -337,10 +337,6 @@
# up the request itself, rather than us having to worry about it
_max_request_size = 32768
- def __init__(self, base, _from_transport=None):
- super(SFTPTransport, self).__init__(base,
- _from_transport=_from_transport)
-
def _remote_path(self, relpath):
"""Return the path to be passed along the sftp protocol for relpath.
=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt 2011-07-23 13:01:03 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt 2011-07-25 11:19:19 +0000
@@ -90,6 +90,10 @@
.. Changes that may require updates in plugins or other code that uses
bzrlib.
+* New methods ``get_transport_from_path`` and ``get_transport_from_url``
+ have been added that only support opening from a path or a URL,
+ unlike ``get_transport``. (Jelmer Vernooij)
+
* Remove ``AtomicFile.closed`` which has been deprecated in bzr 0.10.
(Vincent Ladeuil)
@@ -116,6 +120,7 @@
no longer support it.
(Martin Pool)
+
Internals
*********
More information about the bazaar-commits
mailing list