128
128
self.get(key).insert(0,
129
129
registry._LazyObjectGetter(module_name, member_name))
131
def register_transport(self, key, help=None, default_port=None):
132
self.register(key, [], help, default_port)
131
def register_transport(self, key, help=None):
132
self.register(key, [], help)
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 + '://')
146
139
transport_list_registry = TransportListRegistry()
149
def register_transport_proto(prefix, help=None, info=None, default_port=None,
142
def register_transport_proto(prefix, help=None, info=None,
150
143
register_netloc=False):
151
transport_list_registry.register_transport(prefix, help, default_port)
144
transport_list_registry.register_transport(prefix, help)
152
145
if register_netloc:
153
146
assert prefix.endswith('://')
154
147
register_urlparse_netloc_protocol(prefix[:-3])
668
661
if adjust_for_latency:
669
662
# Design note: We may wish to have different algorithms for the
670
663
# expansion of the offsets per-transport. E.g. for local disk to
671
# use page-aligned expansion. If that is the case consider the following structure:
672
# - a test that transport.readv uses self._offset_expander or some similar attribute, to do the expansion
673
# - a test for each transport that it has some known-good offset expander
664
# use page-aligned expansion. If that is the case consider the
665
# following structure:
666
# - a test that transport.readv uses self._offset_expander or some
667
# similar attribute, to do the expansion
668
# - a test for each transport that it has some known-good offset
674
670
# - unit tests for each offset expander
675
671
# - a set of tests for the offset expander interface, giving
676
672
# baseline behaviour (which the current transport
1396
1388
# have one so that it doesn't get accidentally
1398
1390
netloc = '%s@%s' % (urllib.quote(user), netloc)
1399
if (port is not None and
1400
port != transport_list_registry.get_default_port(scheme)):
1401
# Include the port in the netloc (unless it's the same as the
1402
# default, in which case we omit it as it is redundant).
1391
if port is not None:
1403
1392
netloc = '%s:%d' % (netloc, port)
1404
1393
path = urllib.quote(path)
1405
1394
return urlparse.urlunparse((scheme, netloc, path, None, None, None))
1730
1717
# Decorated http transport
1731
1718
register_transport_proto('http+urllib://',
1732
1719
# help="Read-only access of branches exported on the web."
1733
default_port=80, register_netloc=True)
1720
register_netloc=True)
1734
1721
register_lazy_transport('http+urllib://', 'bzrlib.transport.http._urllib',
1735
1722
'HttpTransport_urllib')
1736
1723
register_transport_proto('https+urllib://',
1737
1724
# help="Read-only access of branches exported on the web using SSL."
1738
default_port=443, register_netloc=True)
1725
register_netloc=True)
1739
1726
register_lazy_transport('https+urllib://', 'bzrlib.transport.http._urllib',
1740
1727
'HttpTransport_urllib')
1741
1728
register_transport_proto('http+pycurl://',
1742
1729
# help="Read-only access of branches exported on the web."
1743
default_port=80, register_netloc=True)
1730
register_netloc=True)
1744
1731
register_lazy_transport('http+pycurl://', 'bzrlib.transport.http._pycurl',
1745
1732
'PyCurlTransport')
1746
1733
register_transport_proto('https+pycurl://',
1747
1734
# help="Read-only access of branches exported on the web using SSL."
1748
default_port=443, register_netloc=True)
1735
register_netloc=True)
1749
1736
register_lazy_transport('https+pycurl://', 'bzrlib.transport.http._pycurl',
1750
1737
'PyCurlTransport')
1751
1738
# Default http transports (last declared wins (if it can be imported))
1752
1739
register_transport_proto('http://',
1753
help="Read-only access of branches exported on the web.",
1740
help="Read-only access of branches exported on the web.")
1755
1741
register_transport_proto('https://',
1756
help="Read-only access of branches exported on the web using SSL.",
1742
help="Read-only access of branches exported on the web using SSL.")
1758
1743
register_lazy_transport('http://', 'bzrlib.transport.http._urllib',
1759
1744
'HttpTransport_urllib')
1760
1745
register_lazy_transport('https://', 'bzrlib.transport.http._urllib',
1761
1746
'HttpTransport_urllib')
1762
register_lazy_transport('http://', 'bzrlib.transport.http._pycurl', 'PyCurlTransport')
1763
register_lazy_transport('https://', 'bzrlib.transport.http._pycurl', 'PyCurlTransport')
1747
register_lazy_transport('http://', 'bzrlib.transport.http._pycurl',
1749
register_lazy_transport('https://', 'bzrlib.transport.http._pycurl',
1765
register_transport_proto('ftp://',
1766
help="Access using passive FTP.",
1752
register_transport_proto('ftp://', help="Access using passive FTP.")
1768
1753
register_lazy_transport('ftp://', 'bzrlib.transport.ftp', 'FtpTransport')
1769
register_transport_proto('aftp://',
1770
help="Access using active FTP.",
1754
register_transport_proto('aftp://', help="Access using active FTP.")
1772
1755
register_lazy_transport('aftp://', 'bzrlib.transport.ftp', 'FtpTransport')
1774
1757
register_transport_proto('memory://')
1775
register_lazy_transport('memory://', 'bzrlib.transport.memory', 'MemoryTransport')
1758
register_lazy_transport('memory://', 'bzrlib.transport.memory',
1777
1761
# chroots cannot be implicitly accessed, they must be explicitly created:
1778
1762
register_transport_proto('chroot+')
1780
1764
register_transport_proto('readonly+',
1781
1765
# help="This modifier converts any transport to be readonly."
1783
register_lazy_transport('readonly+', 'bzrlib.transport.readonly', 'ReadonlyTransportDecorator')
1767
register_lazy_transport('readonly+', 'bzrlib.transport.readonly',
1768
'ReadonlyTransportDecorator')
1785
1770
register_transport_proto('fakenfs+')
1786
register_lazy_transport('fakenfs+', 'bzrlib.transport.fakenfs', 'FakeNFSTransportDecorator')
1771
register_lazy_transport('fakenfs+', 'bzrlib.transport.fakenfs',
1772
'FakeNFSTransportDecorator')
1788
1774
register_transport_proto('trace+')
1789
register_lazy_transport('trace+', 'bzrlib.transport.trace', 'TransportTraceDecorator')
1775
register_lazy_transport('trace+', 'bzrlib.transport.trace',
1776
'TransportTraceDecorator')
1791
1778
register_transport_proto('unlistable+')
1792
register_lazy_transport('unlistable+', 'bzrlib.transport.unlistable', 'UnlistableTransportDecorator')
1779
register_lazy_transport('unlistable+', 'bzrlib.transport.unlistable',
1780
'UnlistableTransportDecorator')
1794
1782
register_transport_proto('brokenrename+')
1795
1783
register_lazy_transport('brokenrename+', 'bzrlib.transport.brokenrename',
1796
'BrokenRenameTransportDecorator')
1784
'BrokenRenameTransportDecorator')
1798
1786
register_transport_proto('vfat+')
1799
1787
register_lazy_transport('vfat+',
1809
1797
register_transport_proto('bzr://',
1810
1798
help="Fast access using the Bazaar smart server.",
1811
default_port=4155, register_netloc=True)
1799
register_netloc=True)
1813
register_lazy_transport('bzr://',
1814
'bzrlib.transport.remote',
1801
register_lazy_transport('bzr://', 'bzrlib.transport.remote',
1815
1802
'RemoteTCPTransport')
1816
1803
register_transport_proto('bzr+http://',
1817
1804
# help="Fast access using the Bazaar smart server over HTTP."
1818
default_port=80, register_netloc=True)
1819
register_lazy_transport('bzr+http://',
1820
'bzrlib.transport.remote',
1805
register_netloc=True)
1806
register_lazy_transport('bzr+http://', 'bzrlib.transport.remote',
1821
1807
'RemoteHTTPTransport')
1822
1808
register_transport_proto('bzr+https://',
1823
1809
# help="Fast access using the Bazaar smart server over HTTPS."
1824
register_netloc=True)
1810
register_netloc=True)
1825
1811
register_lazy_transport('bzr+https://',
1826
1812
'bzrlib.transport.remote',
1827
1813
'RemoteHTTPTransport')
1828
# Note that bzr+ssh:// has no default_port, because the user's ~/.ssh/config
1829
# can set it to arbitrary values based on hostname.
1830
1814
register_transport_proto('bzr+ssh://',
1831
1815
help="Fast access using the Bazaar smart server over SSH.",
1832
1816
register_netloc=True)
1833
register_lazy_transport('bzr+ssh://',
1834
'bzrlib.transport.remote',
1817
register_lazy_transport('bzr+ssh://', 'bzrlib.transport.remote',
1835
1818
'RemoteSSHTransport')