Rev 2938: (John Arbash Meinel) Register netloc protocols earlier. Helps reduce some race conditions. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Oct 24 19:19:55 BST 2007


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 2938
revision-id: pqm at pqm.ubuntu.com-20071024181951-qqo4r5mqrhr032pf
parent: pqm at pqm.ubuntu.com-20071024171920-7ow21d7v5crrxdc4
parent: john at arbash-meinel.com-20071024172606-qxfil64hcjy7n7s5
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2007-10-24 19:19:51 +0100
message:
  (John Arbash Meinel) Register netloc protocols earlier. Helps reduce some race conditions.
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
    ------------------------------------------------------------
    revno: 2919.2.2
    merged: john at arbash-meinel.com-20071024172606-qxfil64hcjy7n7s5
    parent: john at arbash-meinel.com-20071019195606-ksvbz5hfy7p5xwvh
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: netloc_protocols
    timestamp: Wed 2007-10-24 12:26:06 -0500
    message:
      fix a simple typo
    ------------------------------------------------------------
    revno: 2919.2.1
    merged: 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 file 'bzrlib/transport/__init__.py'
--- a/bzrlib/transport/__init__.py	2007-10-11 04:54:04 +0000
+++ b/bzrlib/transport/__init__.py	2007-10-24 18:19:51 +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']:
+    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-11 04:54:04 +0000
+++ b/bzrlib/transport/remote.py	2007-10-24 18:19:51 +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 22:00:07 +0000
+++ b/bzrlib/transport/sftp.py	2007-10-24 18:19:51 +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