Rev 2920: Register netloc protocols as soon as the protocol is registered. in http://bzr.arbash-meinel.com/branches/bzr/0.92-dev/netloc_protocols
John Arbash Meinel
john at arbash-meinel.com
Fri Oct 19 20:56:44 BST 2007
At http://bzr.arbash-meinel.com/branches/bzr/0.92-dev/netloc_protocols
------------------------------------------------------------
revno: 2920
revision-id: john at arbash-meinel.com-20071019195606-ksvbz5hfy7p5xwvh
parent: pqm at pqm.ubuntu.com-20071019183933-ponmwcztrwpn9o7w
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: netloc_protocols
timestamp: Fri 2007-10-19 14:56:06 -0500
message:
Register netloc protocols as soon as the protocol is registered.
Rather than waiting for importing the submodule to register it.
This fixes a timing bug when opening a master branch that points to a new
url prefix. The code to re-use the existing transport would try to
parse the URL before the netloc prefix had been registered.
modified:
bzrlib/transport/__init__.py transport.py-20050711165921-4978aa7ce1285ad5
bzrlib/transport/http/_pycurl.py pycurlhttp.py-20060110060940-4e2a705911af77a6
bzrlib/transport/http/_urllib.py _urlgrabber.py-20060113083826-0bbf7d992fbf090c
bzrlib/transport/remote.py ssh.py-20060608202016-c25gvf1ob7ypbus6-1
bzrlib/transport/sftp.py sftp.py-20051019050329-ab48ce71b7e32dfe
-------------- next part --------------
=== modified file 'bzrlib/transport/__init__.py'
--- a/bzrlib/transport/__init__.py 2007-10-09 08:43:47 +0000
+++ b/bzrlib/transport/__init__.py 2007-10-19 19:56:06 +0000
@@ -146,8 +146,12 @@
transport_list_registry = TransportListRegistry()
-def register_transport_proto(prefix, help=None, info=None, default_port=None):
+def register_transport_proto(prefix, help=None, info=None, default_port=None,
+ register_netloc=False):
transport_list_registry.register_transport(prefix, help, default_port)
+ if register_netloc:
+ assert prefix.endswith('://')
+ register_urlparse_netloc_protocol(prefix[:-3])
def register_lazy_transport(prefix, module, classname):
@@ -1710,27 +1714,28 @@
# Note that sftp:// has no default_port, because the user's ~/.ssh/config
# can set it to arbitrary values based on hostname.
register_transport_proto('sftp://',
- help="Access using SFTP (most SSH servers provide SFTP).")
+ help="Access using SFTP (most SSH servers provide SFTP).",
+ register_netloc=True)
register_lazy_transport('sftp://', 'bzrlib.transport.sftp', 'SFTPTransport')
# Decorated http transport
register_transport_proto('http+urllib://',
# help="Read-only access of branches exported on the web."
- default_port=80)
+ default_port=80, register_netloc=True)
register_lazy_transport('http+urllib://', 'bzrlib.transport.http._urllib',
'HttpTransport_urllib')
register_transport_proto('https+urllib://',
# help="Read-only access of branches exported on the web using SSL."
- default_port=443)
+ default_port=443, register_netloc=True)
register_lazy_transport('https+urllib://', 'bzrlib.transport.http._urllib',
'HttpTransport_urllib')
register_transport_proto('http+pycurl://',
# help="Read-only access of branches exported on the web."
- default_port=80)
+ default_port=80, register_netloc=True)
register_lazy_transport('http+pycurl://', 'bzrlib.transport.http._pycurl',
'PyCurlTransport')
register_transport_proto('https+pycurl://',
# help="Read-only access of branches exported on the web using SSL."
- default_port=443)
+ default_port=443, register_netloc=True)
register_lazy_transport('https+pycurl://', 'bzrlib.transport.http._pycurl',
'PyCurlTransport')
# Default http transports (last declared wins (if it can be imported))
@@ -1784,29 +1789,37 @@
register_lazy_transport('vfat+',
'bzrlib.transport.fakevfat',
'FakeVFATTransportDecorator')
+
+# These two schemes were registered, but don't seem to have an actual transport
+# protocol registered
+for scheme in ['ssh', 'bzr+loopback']:
+ transport.register_urlparse_netloc_protocol(scheme)
+del scheme
+
register_transport_proto('bzr://',
help="Fast access using the Bazaar smart server.",
- default_port=4155)
+ default_port=4155, register_netloc=True)
register_lazy_transport('bzr://',
'bzrlib.transport.remote',
'RemoteTCPTransport')
register_transport_proto('bzr+http://',
# help="Fast access using the Bazaar smart server over HTTP."
- default_port=80)
+ default_port=80, register_netloc=True)
register_lazy_transport('bzr+http://',
'bzrlib.transport.remote',
'RemoteHTTPTransport')
register_transport_proto('bzr+https://',
# help="Fast access using the Bazaar smart server over HTTPS."
- )
+ register_netloc=True)
register_lazy_transport('bzr+https://',
'bzrlib.transport.remote',
'RemoteHTTPTransport')
# Note that bzr+ssh:// has no default_port, because the user's ~/.ssh/config
# can set it to arbitrary values based on hostname.
register_transport_proto('bzr+ssh://',
- help="Fast access using the Bazaar smart server over SSH.")
+ help="Fast access using the Bazaar smart server over SSH.",
+ register_netloc=True)
register_lazy_transport('bzr+ssh://',
'bzrlib.transport.remote',
'RemoteSSHTransport')
=== modified file 'bzrlib/transport/http/_pycurl.py'
--- a/bzrlib/transport/http/_pycurl.py 2007-10-01 08:42:16 +0000
+++ b/bzrlib/transport/http/_pycurl.py 2007-10-19 19:56:06 +0000
@@ -44,7 +44,6 @@
ConnectionError,
DependencyNotPresent)
from bzrlib.trace import mutter
-from bzrlib.transport import register_urlparse_netloc_protocol
from bzrlib.transport.http import (
ca_bundle,
_extract_headers,
@@ -96,9 +95,6 @@
CURLE_PARTIAL_FILE = _get_pycurl_errcode('E_PARTIAL_FILE', 18)
-register_urlparse_netloc_protocol('http+pycurl')
-
-
class PyCurlTransport(HttpTransportBase):
"""http client transport using pycurl
=== modified file 'bzrlib/transport/http/_urllib.py'
--- a/bzrlib/transport/http/_urllib.py 2007-08-15 04:56:08 +0000
+++ b/bzrlib/transport/http/_urllib.py 2007-10-19 19:56:06 +0000
@@ -23,7 +23,6 @@
urlutils,
)
from bzrlib.trace import mutter
-from bzrlib.transport import register_urlparse_netloc_protocol
from bzrlib.transport.http import HttpTransportBase
# TODO: handle_response should be integrated into the _urllib2_wrappers
from bzrlib.transport.http.response import handle_response
@@ -35,9 +34,6 @@
)
-register_urlparse_netloc_protocol('http+urllib')
-
-
class HttpTransport_urllib(HttpTransportBase):
"""Python urllib transport for http and https."""
=== modified file 'bzrlib/transport/remote.py'
--- a/bzrlib/transport/remote.py 2007-10-05 14:52:02 +0000
+++ b/bzrlib/transport/remote.py 2007-10-19 19:56:06 +0000
@@ -36,11 +36,6 @@
)
from bzrlib.smart import client, medium, protocol
-# must do this otherwise urllib can't parse the urls properly :(
-for scheme in ['ssh', 'bzr', 'bzr+loopback', 'bzr+ssh', 'bzr+http', 'bzr+https']:
- transport.register_urlparse_netloc_protocol(scheme)
-del scheme
-
# Port 4155 is the default port for bzr://, registered with IANA.
BZR_DEFAULT_INTERFACE = '0.0.0.0'
=== modified file 'bzrlib/transport/sftp.py'
--- a/bzrlib/transport/sftp.py 2007-10-04 05:09:58 +0000
+++ b/bzrlib/transport/sftp.py 2007-10-19 19:56:06 +0000
@@ -57,7 +57,6 @@
FileFileStream,
_file_streams,
local,
- register_urlparse_netloc_protocol,
Server,
ssh,
ConnectedTransport,
@@ -88,9 +87,6 @@
from paramiko.sftp_file import SFTPFile
-register_urlparse_netloc_protocol('sftp')
-
-
_paramiko_version = getattr(paramiko, '__version_info__', (0, 0, 0))
# don't use prefetch unless paramiko version >= 1.5.5 (there were bugs earlier)
_default_do_prefetch = (_paramiko_version >= (1, 5, 5))
More information about the bazaar-commits
mailing list