128
128
self.get(key).insert(0,
129
129
registry._LazyObjectGetter(module_name, member_name))
131
def register_transport(self, key, help=None, info=None):
132
self.register(key, [], help, info)
131
def register_transport(self, key, help=None, default_port=None):
132
self.register(key, [], help, default_port)
134
134
def set_default_transport(self, key=None):
135
135
"""Return either 'key' or the default key if key is None"""
136
136
self._default_key = key
138
def get_default_port(self, scheme):
139
"""Return the registered default port for this protocol scheme."""
141
return self.get_info(scheme + '://')
139
146
transport_list_registry = TransportListRegistry( )
142
def register_transport_proto(prefix, help=None, info=None):
143
transport_list_registry.register_transport(prefix, help, info)
149
def register_transport_proto(prefix, help=None, info=None, default_port=None):
150
transport_list_registry.register_transport(prefix, help, default_port)
146
153
def register_lazy_transport(prefix, module, classname):
1256
1263
host = urllib.unquote(host)
1257
1264
path = urllib.unquote(path)
1267
# The port isn't explicitly specified, so return the default (if
1269
port = transport_list_registry.get_default_port(scheme)
1259
1270
return (scheme, user, password, host, port, path)
1286
1297
# have one so that it doesn't get accidentally
1288
1299
netloc = '%s@%s' % (urllib.quote(user), netloc)
1289
if port is not None:
1300
if (port is not None and
1301
port != transport_list_registry.get_default_port(scheme)):
1302
# Include the port in the netloc (unless it's the same as the
1303
# default, in which case we omit it as it is redundant).
1290
1304
netloc = '%s:%d' % (netloc, port)
1291
1305
path = urllib.quote(path)
1292
1306
return urlparse.urlunparse((scheme, netloc, path, None, None, None))
1626
1640
transport_list_registry.set_default_transport("file://")
1628
1642
register_transport_proto('sftp://',
1629
help="Access using SFTP (most SSH servers provide SFTP).")
1643
help="Access using SFTP (most SSH servers provide SFTP).",
1630
1645
register_lazy_transport('sftp://', 'bzrlib.transport.sftp', 'SFTPTransport')
1631
1646
# Decorated http transport
1632
1647
register_transport_proto('http+urllib://',
1633
1648
# help="Read-only access of branches exported on the web."
1635
1650
register_lazy_transport('http+urllib://', 'bzrlib.transport.http._urllib',
1636
1651
'HttpTransport_urllib')
1637
1652
register_transport_proto('https+urllib://',
1638
1653
# help="Read-only access of branches exported on the web using SSL."
1640
1655
register_lazy_transport('https+urllib://', 'bzrlib.transport.http._urllib',
1641
1656
'HttpTransport_urllib')
1642
1657
register_transport_proto('http+pycurl://',
1643
1658
# help="Read-only access of branches exported on the web."
1645
1660
register_lazy_transport('http+pycurl://', 'bzrlib.transport.http._pycurl',
1646
1661
'PyCurlTransport')
1647
1662
register_transport_proto('https+pycurl://',
1648
1663
# help="Read-only access of branches exported on the web using SSL."
1650
1665
register_lazy_transport('https+pycurl://', 'bzrlib.transport.http._pycurl',
1651
1666
'PyCurlTransport')
1652
1667
# Default http transports (last declared wins (if it can be imported))
1653
1668
register_transport_proto('http://',
1654
help="Read-only access of branches exported on the web.")
1669
help="Read-only access of branches exported on the web.",
1655
1671
register_transport_proto('https://',
1656
help="Read-only access of branches exported on the web using SSL.")
1672
help="Read-only access of branches exported on the web using SSL.",
1657
1674
register_lazy_transport('http://', 'bzrlib.transport.http._urllib',
1658
1675
'HttpTransport_urllib')
1659
1676
register_lazy_transport('https://', 'bzrlib.transport.http._urllib',
1662
1679
register_lazy_transport('https://', 'bzrlib.transport.http._pycurl', 'PyCurlTransport')
1664
1681
register_transport_proto('ftp://',
1665
help="Access using passive FTP.")
1682
help="Access using passive FTP.",
1666
1684
register_lazy_transport('ftp://', 'bzrlib.transport.ftp', 'FtpTransport')
1667
1685
register_transport_proto('aftp://',
1668
help="Access using active FTP.")
1686
help="Access using active FTP.",
1669
1688
register_lazy_transport('aftp://', 'bzrlib.transport.ftp', 'FtpTransport')
1671
1690
register_transport_proto('memory://')
1692
1711
'bzrlib.transport.fakevfat',
1693
1712
'FakeVFATTransportDecorator')
1694
1713
register_transport_proto('bzr://',
1695
help="Fast access using the Bazaar smart server.")
1714
help="Fast access using the Bazaar smart server.",
1697
1717
register_lazy_transport('bzr://',
1698
1718
'bzrlib.transport.remote',
1699
1719
'RemoteTCPTransport')
1700
1720
register_transport_proto('bzr+http://',
1701
1721
# help="Fast access using the Bazaar smart server over HTTP."
1703
1723
register_lazy_transport('bzr+http://',
1704
1724
'bzrlib.transport.remote',
1705
1725
'RemoteHTTPTransport')
1710
1730
'bzrlib.transport.remote',
1711
1731
'RemoteHTTPTransport')
1712
1732
register_transport_proto('bzr+ssh://',
1713
help="Fast access using the Bazaar smart server over SSH.")
1733
help="Fast access using the Bazaar smart server over SSH.",
1714
1735
register_lazy_transport('bzr+ssh://',
1715
1736
'bzrlib.transport.remote',
1716
1737
'RemoteSSHTransport')