Rev 2484: Mark transports that need to be instrumented or refactored to check in file:///v/home/vila/src/bugs/111702/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Thu May 3 22:27:18 BST 2007
At file:///v/home/vila/src/bugs/111702/
------------------------------------------------------------
revno: 2484
revision-id: v.ladeuil+lp at free.fr-20070503212714-3sbdmehsv8kemomw
parent: v.ladeuil+lp at free.fr-20070503124529-3na89ialmyl9bogy
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 111702
timestamp: Thu 2007-05-03 23:27:14 +0200
message:
Mark transports that need to be instrumented or refactored to check
multiple connections. Various cosmetic changes.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/tests/test_bzrdir.py test_bzrdir.py-20060131065654-deba40eef51cf220
bzrlib/tests/test_transport.py testtransport.py-20050718175618-e5cdb99f4555ddce
bzrlib/transport/__init__.py transport.py-20050711165921-4978aa7ce1285ad5
bzrlib/transport/http/_urllib2_wrappers.py _urllib2_wrappers.py-20060913231729-ha9ugi48ktx481ao-1
bzrlib/transport/sftp.py sftp.py-20051019050329-ab48ce71b7e32dfe
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS 2007-05-02 20:18:37 +0000
+++ b/NEWS 2007-05-03 21:27:14 +0000
@@ -21,7 +21,7 @@
* ``bzr init`` should only connect to the remote location one time.
We have been connecting several times because we forget to pass
around the Transport object. This modifies
- ``BzrDir.create_branch_convenienve``, so that we can pass in the
+ ``BzrDir.create_branch_convenience``, so that we can pass in the
Transport that we already have.
(John Arbash Meinel, Vincent Ladeuil, #111702)
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2007-05-03 11:38:27 +0000
+++ b/bzrlib/builtins.py 2007-05-03 21:27:14 +0000
@@ -1286,7 +1286,7 @@
# really a NotBzrDir error...
create_branch= bzrdir.BzrDir.create_branch_convenience
branch = create_branch(to_transport.base, format=format,
- transports=[to_transport])
+ possible_transports=[to_transport])
else:
from bzrlib.transport.local import LocalTransport
if existing_bzrdir.has_branch():
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py 2007-05-03 11:38:27 +0000
+++ b/bzrlib/bzrdir.py 2007-05-03 21:27:14 +0000
@@ -214,7 +214,7 @@
t.ensure_base()
@classmethod
- def create(cls, base, format=None, transports=None):
+ def create(cls, base, format=None, possible_transports=None):
"""Create a new BzrDir at the url 'base'.
This will call the current default formats initialize with base
@@ -222,15 +222,17 @@
:param format: If supplied, the format of branch to create. If not
supplied, the default is used.
+ :param possible_transports: If supplied, a list of transports that
+ can be reused to share a remote connection.
"""
if cls is not BzrDir:
raise AssertionError("BzrDir.create always creates the default"
" format, not one of %r" % cls)
- t = get_transport(base, transports)
+ t = get_transport(base, possible_transports)
t.ensure_base()
if format is None:
format = BzrDirFormat.get_default_format()
- return format.initialize(safe_unicode(base), transports)
+ return format.initialize(safe_unicode(base), possible_transports)
def create_branch(self):
"""Create a branch in this BzrDir.
@@ -270,7 +272,7 @@
@staticmethod
def create_branch_convenience(base, force_new_repo=False,
force_new_tree=None, format=None,
- transports=None,):
+ possible_transports=None,):
"""Create a new BzrDir, Branch and Repository at the url 'base'.
This is a convenience function - it will use an existing repository
@@ -293,14 +295,14 @@
:param force_new_tree: If True or False force creation of a tree or
prevent such creation respectively.
:param format: Override for the for the bzrdir format to create.
- :param transports: An optional reusable transports list.
+ :param possible_transports: An optional reusable transports list.
"""
if force_new_tree:
# check for non local urls
- t = get_transport(safe_unicode(base), transports)
+ t = get_transport(safe_unicode(base), possible_transports)
if not isinstance(t, LocalTransport):
raise errors.NotLocalUrl(base)
- bzrdir = BzrDir.create(base, format, transports)
+ bzrdir = BzrDir.create(base, format, possible_transports)
repo = bzrdir._find_or_create_repository(force_new_repo)
result = bzrdir.create_branch()
if force_new_tree or (repo.make_working_trees() and
@@ -1292,13 +1294,14 @@
"""
raise NotImplementedError(self.get_converter)
- def initialize(self, url, transports=None):
+ def initialize(self, url, possible_transports=None):
"""Create a bzr control dir at this url and return an opened copy.
Subclasses should typically override initialize_on_transport
instead of this method.
"""
- return self.initialize_on_transport(get_transport(url, transports))
+ return self.initialize_on_transport(get_transport(url,
+ possible_transports))
def initialize_on_transport(self, transport):
"""Initialize a new bzrdir in the base directory of a Transport."""
=== modified file 'bzrlib/tests/test_bzrdir.py'
--- a/bzrlib/tests/test_bzrdir.py 2007-05-03 12:45:29 +0000
+++ b/bzrlib/tests/test_bzrdir.py 2007-05-03 21:27:14 +0000
@@ -198,9 +198,9 @@
"""See BzrDirFormat.get_format_string()."""
return "Sample .bzr dir format."
- def initialize(self, url, transports=None):
+ def initialize(self, url, possible_transports=None):
"""Create a bzr dir."""
- t = get_transport(url, transports)
+ t = get_transport(url, possible_transports)
t.mkdir('.bzr')
t.put_bytes('.bzr/branch-format', self.get_format_string())
return SampleBzrDir(t, self)
=== modified file 'bzrlib/tests/test_transport.py'
--- a/bzrlib/tests/test_transport.py 2007-05-03 09:59:47 +0000
+++ b/bzrlib/tests/test_transport.py 2007-05-03 21:27:14 +0000
@@ -598,10 +598,10 @@
def test_reuse_same_transport(self):
t = get_transport('http://foo/')
- t2 = get_transport('http://foo/', transports=[t])
+ t2 = get_transport('http://foo/', possible_transports=[t])
self.assertIs(t, t2)
def test_don_t_reuse_different_transport(self):
t = get_transport('http://foo/')
- t2 = get_transport('http://bar/', transports=[t])
+ t2 = get_transport('http://bar/', possible_transports=[t])
self.assertIsNot(t, t2)
=== modified file 'bzrlib/transport/__init__.py'
--- a/bzrlib/transport/__init__.py 2007-05-03 11:38:27 +0000
+++ b/bzrlib/transport/__init__.py 2007-05-03 21:27:14 +0000
@@ -1038,7 +1038,7 @@
urlunescape = urlutils.unescape
_urlRE = re.compile(r'^(?P<proto>[^:/\\]+)://(?P<path>.*)$')
-def get_transport(base, transports=None):
+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.
@@ -1068,8 +1068,8 @@
'URLs must be properly escaped (protocol: %s)')
transport = None
- if transports:
- for t in transports:
+ if possible_transports:
+ for t in possible_transports:
if t.base == base:
transport = t
break
=== modified file 'bzrlib/transport/http/_urllib2_wrappers.py'
--- a/bzrlib/transport/http/_urllib2_wrappers.py 2007-04-22 16:32:04 +0000
+++ b/bzrlib/transport/http/_urllib2_wrappers.py 2007-05-03 21:27:14 +0000
@@ -235,6 +235,7 @@
handler_order = 1000 # after all pre-processings
+ # test mutiple connections
def create_connection(self, request, http_connection_class):
host = request.get_host()
if not host:
=== modified file 'bzrlib/transport/sftp.py'
--- a/bzrlib/transport/sftp.py 2007-04-16 04:24:11 +0000
+++ b/bzrlib/transport/sftp.py 2007-05-03 21:27:14 +0000
@@ -824,6 +824,7 @@
# that we have taken the lock.
return SFTPLock(relpath, self)
+ # test mutiple connections
def _sftp_connect(self):
"""Connect to the remote sftp server.
After this, self._sftp should have a valid connection (or
More information about the bazaar-commits
mailing list