~bzr/ubuntu/lucid/bzr/beta-ppa

« back to all changes in this revision

Viewing changes to bzrlib/transport/__init__.py

  • Committer: Martin Pool
  • Date: 2010-08-18 04:26:39 UTC
  • mfrom: (129.1.8 packaging-karmic)
  • Revision ID: mbp@sourcefrog.net-20100818042639-mjoxtngyjwiu05fo
* PPA rebuild for lucid.
* PPA rebuild for karmic.
* PPA rebuild onto jaunty.
* New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
""")
48
48
 
49
49
from bzrlib.symbol_versioning import (
50
 
        deprecated_method,
51
 
        deprecated_function,
52
50
        DEPRECATED_PARAMETER,
53
51
        )
54
52
from bzrlib.trace import (
539
537
 
540
538
        This function will only be defined for Transports which have a
541
539
        physical local filesystem representation.
 
540
 
 
541
        :raises errors.NotLocalUrl: When no local path representation is
 
542
            available.
542
543
        """
543
544
        raise errors.NotLocalUrl(self.abspath(relpath))
544
545
 
1206
1207
        count = self._iterate_over(relpaths, gather, pb, 'stat', expand=False)
1207
1208
        return stats
1208
1209
 
 
1210
    def readlink(self, relpath):
 
1211
        """Return a string representing the path to which the symbolic link points."""
 
1212
        raise errors.TransportNotPossible("Dereferencing symlinks is not supported on %s" % self)
 
1213
 
 
1214
    def hardlink(self, source, link_name):
 
1215
        """Create a hardlink pointing to source named link_name."""
 
1216
        raise errors.TransportNotPossible("Hard links are not supported on %s" % self)
 
1217
 
 
1218
    def symlink(self, source, link_name):
 
1219
        """Create a symlink pointing to source named link_name."""
 
1220
        raise errors.TransportNotPossible("Symlinks are not supported on %s" % self)
 
1221
 
1209
1222
    def listable(self):
1210
1223
        """Return True if this store supports listing."""
1211
1224
        raise NotImplementedError(self.listable)
1538
1551
        return transport
1539
1552
 
1540
1553
 
1541
 
# We try to recognize an url lazily (ignoring user, password, etc)
1542
 
_urlRE = re.compile(r'^(?P<proto>[^:/\\]+)://(?P<rest>.*)$')
1543
 
 
1544
1554
def get_transport(base, possible_transports=None):
1545
1555
    """Open a transport to access a URL or directory.
1546
1556
 
1559
1569
    base = directories.dereference(base)
1560
1570
 
1561
1571
    def convert_path_to_url(base, error_str):
1562
 
        m = _urlRE.match(base)
1563
 
        if m:
 
1572
        if urlutils.is_url(base):
1564
1573
            # This looks like a URL, but we weren't able to
1565
1574
            # instantiate it as such raise an appropriate error
1566
1575
            # FIXME: we have a 'error_str' unused and we use last_err below
1667
1676
class Server(object):
1668
1677
    """A Transport Server.
1669
1678
 
1670
 
    The Server interface provides a server for a given transport. We use
1671
 
    these servers as loopback testing tools. For any given transport the
1672
 
    Servers it provides must either allow writing, or serve the contents
1673
 
    of os.getcwdu() at the time start_server is called.
1674
 
 
1675
 
    Note that these are real servers - they must implement all the things
1676
 
    that we want bzr transports to take advantage of.
 
1679
    The Server interface provides a server for a given transport type.
1677
1680
    """
1678
1681
 
1679
1682
    def start_server(self):
1682
1685
    def stop_server(self):
1683
1686
        """Remove the server and cleanup any resources it owns."""
1684
1687
 
1685
 
    def get_url(self):
1686
 
        """Return a url for this server.
1687
 
 
1688
 
        If the transport does not represent a disk directory (i.e. it is
1689
 
        a database like svn, or a memory only transport, it should return
1690
 
        a connection to a newly established resource for this Server.
1691
 
        Otherwise it should return a url that will provide access to the path
1692
 
        that was os.getcwdu() when start_server() was called.
1693
 
 
1694
 
        Subsequent calls will return the same resource.
1695
 
        """
1696
 
        raise NotImplementedError
1697
 
 
1698
 
    def get_bogus_url(self):
1699
 
        """Return a url for this protocol, that will fail to connect.
1700
 
 
1701
 
        This may raise NotImplementedError to indicate that this server cannot
1702
 
        provide bogus urls.
1703
 
        """
1704
 
        raise NotImplementedError
1705
 
 
1706
1688
 
1707
1689
# None is the default transport, for things with no url scheme
1708
1690
register_transport_proto('file://',
1754
1736
register_lazy_transport('ftp://', 'bzrlib.transport.ftp', 'FtpTransport')
1755
1737
register_transport_proto('aftp://', help="Access using active FTP.")
1756
1738
register_lazy_transport('aftp://', 'bzrlib.transport.ftp', 'FtpTransport')
1757
 
 
1758
 
try:
1759
 
    import kerberos
1760
 
    kerberos_available = True
1761
 
except ImportError:
1762
 
    kerberos_available = False
1763
 
 
1764
 
if kerberos_available:
1765
 
    # Default to trying GSSAPI authentication (if the kerberos module is
1766
 
    # available)
1767
 
    register_transport_proto('ftp+gssapi://', register_netloc=True)
1768
 
    register_lazy_transport('ftp+gssapi://', 'bzrlib.transport.ftp._gssapi',
1769
 
                            'GSSAPIFtpTransport')
1770
 
    register_transport_proto('aftp+gssapi://', register_netloc=True)
1771
 
    register_lazy_transport('aftp+gssapi://', 'bzrlib.transport.ftp._gssapi',
1772
 
                            'GSSAPIFtpTransport')
1773
 
    register_transport_proto('ftp+nogssapi://', register_netloc=True)
1774
 
    register_transport_proto('aftp+nogssapi://', register_netloc=True)
1775
 
 
1776
 
    register_lazy_transport('ftp://', 'bzrlib.transport.ftp._gssapi',
1777
 
                            'GSSAPIFtpTransport')
1778
 
    register_lazy_transport('aftp://', 'bzrlib.transport.ftp._gssapi',
1779
 
                            'GSSAPIFtpTransport')
1780
 
    register_lazy_transport('ftp+nogssapi://', 'bzrlib.transport.ftp',
1781
 
                            'FtpTransport')
1782
 
    register_lazy_transport('aftp+nogssapi://', 'bzrlib.transport.ftp',
1783
 
                            'FtpTransport')
 
1739
register_transport_proto('gio+', help="Access using any GIO supported protocols.")
 
1740
register_lazy_transport('gio+', 'bzrlib.transport.gio_transport', 'GioTransport')
 
1741
 
 
1742
 
 
1743
# Default to trying GSSAPI authentication (if the kerberos module is
 
1744
# available)
 
1745
register_transport_proto('ftp+gssapi://', register_netloc=True)
 
1746
register_transport_proto('aftp+gssapi://', register_netloc=True)
 
1747
register_transport_proto('ftp+nogssapi://', register_netloc=True)
 
1748
register_transport_proto('aftp+nogssapi://', register_netloc=True)
 
1749
register_lazy_transport('ftp+gssapi://', 'bzrlib.transport.ftp._gssapi',
 
1750
                        'GSSAPIFtpTransport')
 
1751
register_lazy_transport('aftp+gssapi://', 'bzrlib.transport.ftp._gssapi',
 
1752
                        'GSSAPIFtpTransport')
 
1753
register_lazy_transport('ftp://', 'bzrlib.transport.ftp._gssapi',
 
1754
                        'GSSAPIFtpTransport')
 
1755
register_lazy_transport('aftp://', 'bzrlib.transport.ftp._gssapi',
 
1756
                        'GSSAPIFtpTransport')
 
1757
register_lazy_transport('ftp+nogssapi://', 'bzrlib.transport.ftp',
 
1758
                        'FtpTransport')
 
1759
register_lazy_transport('aftp+nogssapi://', 'bzrlib.transport.ftp',
 
1760
                        'FtpTransport')
1784
1761
 
1785
1762
register_transport_proto('memory://')
1786
1763
register_lazy_transport('memory://', 'bzrlib.transport.memory',
1862
1839
 
1863
1840
 
1864
1841
transport_server_registry = registry.Registry()
1865
 
transport_server_registry.register_lazy('bzr', 'bzrlib.smart.server', 
 
1842
transport_server_registry.register_lazy('bzr', 'bzrlib.smart.server',
1866
1843
    'serve_bzr', help="The Bazaar smart server protocol over TCP. (default port: 4155)")
1867
1844
transport_server_registry.default_key = 'bzr'