/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/transport/__init__.py

  • Committer: Neil Martinsen-Burrell
  • Date: 2010-09-26 02:27:37 UTC
  • mfrom: (5424 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5461.
  • Revision ID: nmb@wartburg.edu-20100926022737-cj2qvebm2mhpjzak
mergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2008, 2010 Canonical Ltd
 
1
# Copyright (C) 2005-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
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
 
1060
1061
        """
1061
1062
        source = self.clone(from_relpath)
1062
1063
        target = self.clone(to_relpath)
1063
 
        target.mkdir('.')
 
1064
 
 
1065
        # create target directory with the same rwx bits as source.
 
1066
        # use mask to ensure that bits other than rwx are ignored.
 
1067
        stat = self.stat(from_relpath)
 
1068
        target.mkdir('.', stat.st_mode & 0777)
1064
1069
        source.copy_tree_to_transport(target)
1065
1070
 
1066
1071
    def copy_tree_to_transport(self, to_transport):
1202
1207
        count = self._iterate_over(relpaths, gather, pb, 'stat', expand=False)
1203
1208
        return stats
1204
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
 
1205
1222
    def listable(self):
1206
1223
        """Return True if this store supports listing."""
1207
1224
        raise NotImplementedError(self.listable)
1269
1286
        # should be asked to ConnectedTransport only.
1270
1287
        return None
1271
1288
 
 
1289
    def disconnect(self):
 
1290
        # This is really needed for ConnectedTransport only, but it's easier to
 
1291
        # have Transport do nothing than testing that the disconnect should be
 
1292
        # asked to ConnectedTransport only.
 
1293
        pass
 
1294
 
1272
1295
    def _redirected_to(self, source, target):
1273
1296
        """Returns a transport suitable to re-issue a redirected request.
1274
1297
 
1533
1556
            transport = self.__class__(other_base, _from_transport=self)
1534
1557
        return transport
1535
1558
 
1536
 
 
1537
 
# We try to recognize an url lazily (ignoring user, password, etc)
1538
 
_urlRE = re.compile(r'^(?P<proto>[^:/\\]+)://(?P<rest>.*)$')
 
1559
    def disconnect(self):
 
1560
        """Disconnect the transport.
 
1561
 
 
1562
        If and when required the transport willl reconnect automatically.
 
1563
        """
 
1564
        raise NotImplementedError(self.disconnect)
 
1565
 
1539
1566
 
1540
1567
def get_transport(base, possible_transports=None):
1541
1568
    """Open a transport to access a URL or directory.
1555
1582
    base = directories.dereference(base)
1556
1583
 
1557
1584
    def convert_path_to_url(base, error_str):
1558
 
        m = _urlRE.match(base)
1559
 
        if m:
 
1585
        if urlutils.is_url(base):
1560
1586
            # This looks like a URL, but we weren't able to
1561
1587
            # instantiate it as such raise an appropriate error
1562
1588
            # FIXME: we have a 'error_str' unused and we use last_err below
1723
1749
register_lazy_transport('ftp://', 'bzrlib.transport.ftp', 'FtpTransport')
1724
1750
register_transport_proto('aftp://', help="Access using active FTP.")
1725
1751
register_lazy_transport('aftp://', 'bzrlib.transport.ftp', 'FtpTransport')
1726
 
 
1727
 
try:
1728
 
    import kerberos
1729
 
    kerberos_available = True
1730
 
except ImportError:
1731
 
    kerberos_available = False
1732
 
 
1733
 
if kerberos_available:
1734
 
    # Default to trying GSSAPI authentication (if the kerberos module is
1735
 
    # available)
1736
 
    register_transport_proto('ftp+gssapi://', register_netloc=True)
1737
 
    register_lazy_transport('ftp+gssapi://', 'bzrlib.transport.ftp._gssapi',
1738
 
                            'GSSAPIFtpTransport')
1739
 
    register_transport_proto('aftp+gssapi://', register_netloc=True)
1740
 
    register_lazy_transport('aftp+gssapi://', 'bzrlib.transport.ftp._gssapi',
1741
 
                            'GSSAPIFtpTransport')
1742
 
    register_transport_proto('ftp+nogssapi://', register_netloc=True)
1743
 
    register_transport_proto('aftp+nogssapi://', register_netloc=True)
1744
 
 
1745
 
    register_lazy_transport('ftp://', 'bzrlib.transport.ftp._gssapi',
1746
 
                            'GSSAPIFtpTransport')
1747
 
    register_lazy_transport('aftp://', 'bzrlib.transport.ftp._gssapi',
1748
 
                            'GSSAPIFtpTransport')
1749
 
    register_lazy_transport('ftp+nogssapi://', 'bzrlib.transport.ftp',
1750
 
                            'FtpTransport')
1751
 
    register_lazy_transport('aftp+nogssapi://', 'bzrlib.transport.ftp',
1752
 
                            'FtpTransport')
 
1752
register_transport_proto('gio+', help="Access using any GIO supported protocols.")
 
1753
register_lazy_transport('gio+', 'bzrlib.transport.gio_transport', 'GioTransport')
 
1754
 
 
1755
 
 
1756
# Default to trying GSSAPI authentication (if the kerberos module is
 
1757
# available)
 
1758
register_transport_proto('ftp+gssapi://', register_netloc=True)
 
1759
register_transport_proto('aftp+gssapi://', register_netloc=True)
 
1760
register_transport_proto('ftp+nogssapi://', register_netloc=True)
 
1761
register_transport_proto('aftp+nogssapi://', register_netloc=True)
 
1762
register_lazy_transport('ftp+gssapi://', 'bzrlib.transport.ftp._gssapi',
 
1763
                        'GSSAPIFtpTransport')
 
1764
register_lazy_transport('aftp+gssapi://', 'bzrlib.transport.ftp._gssapi',
 
1765
                        'GSSAPIFtpTransport')
 
1766
register_lazy_transport('ftp://', 'bzrlib.transport.ftp._gssapi',
 
1767
                        'GSSAPIFtpTransport')
 
1768
register_lazy_transport('aftp://', 'bzrlib.transport.ftp._gssapi',
 
1769
                        'GSSAPIFtpTransport')
 
1770
register_lazy_transport('ftp+nogssapi://', 'bzrlib.transport.ftp',
 
1771
                        'FtpTransport')
 
1772
register_lazy_transport('aftp+nogssapi://', 'bzrlib.transport.ftp',
 
1773
                        'FtpTransport')
1753
1774
 
1754
1775
register_transport_proto('memory://')
1755
1776
register_lazy_transport('memory://', 'bzrlib.transport.memory',
1831
1852
 
1832
1853
 
1833
1854
transport_server_registry = registry.Registry()
1834
 
transport_server_registry.register_lazy('bzr', 'bzrlib.smart.server', 
 
1855
transport_server_registry.register_lazy('bzr', 'bzrlib.smart.server',
1835
1856
    'serve_bzr', help="The Bazaar smart server protocol over TCP. (default port: 4155)")
1836
1857
transport_server_registry.default_key = 'bzr'