/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: Martin
  • Date: 2010-05-25 17:27:52 UTC
  • mfrom: (5254 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5257.
  • Revision ID: gzlist@googlemail.com-20100525172752-amm089xcikv968sw
Merge bzr.dev to unite with similar changes already made

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2008 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
108
108
    register_transport_provider( ) ( and the "lazy" variant )
109
109
 
110
110
    This is needed because:
111
 
    a) a single provider can support multple protcol ( like the ftp
 
111
    a) a single provider can support multiple protocols ( like the ftp
112
112
    provider which supports both the ftp:// and the aftp:// protocols )
113
113
    b) a single protocol can have multiple providers ( like the http://
114
114
    protocol which is supported by both the urllib and pycurl provider )
539
539
 
540
540
        This function will only be defined for Transports which have a
541
541
        physical local filesystem representation.
 
542
 
 
543
        :raises errors.NotLocalUrl: When no local path representation is
 
544
            available.
542
545
        """
543
546
        raise errors.NotLocalUrl(self.abspath(relpath))
544
547
 
1060
1063
        """
1061
1064
        source = self.clone(from_relpath)
1062
1065
        target = self.clone(to_relpath)
1063
 
        target.mkdir('.')
 
1066
 
 
1067
        # create target directory with the same rwx bits as source.
 
1068
        # use mask to ensure that bits other than rwx are ignored.
 
1069
        stat = self.stat(from_relpath)
 
1070
        target.mkdir('.', stat.st_mode & 0777)
1064
1071
        source.copy_tree_to_transport(target)
1065
1072
 
1066
1073
    def copy_tree_to_transport(self, to_transport):
1202
1209
        count = self._iterate_over(relpaths, gather, pb, 'stat', expand=False)
1203
1210
        return stats
1204
1211
 
 
1212
    def readlink(self, relpath):
 
1213
        """Return a string representing the path to which the symbolic link points."""
 
1214
        raise errors.TransportNotPossible("Dereferencing symlinks is not supported on %s" % self)
 
1215
 
 
1216
    def hardlink(self, source, link_name):
 
1217
        """Create a hardlink pointing to source named link_name."""
 
1218
        raise errors.TransportNotPossible("Hard links are not supported on %s" % self)
 
1219
 
 
1220
    def symlink(self, source, link_name):
 
1221
        """Create a symlink pointing to source named link_name."""
 
1222
        raise errors.TransportNotPossible("Symlinks are not supported on %s" % self)
 
1223
 
1205
1224
    def listable(self):
1206
1225
        """Return True if this store supports listing."""
1207
1226
        raise NotImplementedError(self.listable)
1663
1682
class Server(object):
1664
1683
    """A Transport Server.
1665
1684
 
1666
 
    The Server interface provides a server for a given transport. We use
1667
 
    these servers as loopback testing tools. For any given transport the
1668
 
    Servers it provides must either allow writing, or serve the contents
1669
 
    of os.getcwdu() at the time setUp is called.
1670
 
 
1671
 
    Note that these are real servers - they must implement all the things
1672
 
    that we want bzr transports to take advantage of.
 
1685
    The Server interface provides a server for a given transport type.
1673
1686
    """
1674
1687
 
1675
 
    def setUp(self):
 
1688
    def start_server(self):
1676
1689
        """Setup the server to service requests."""
1677
1690
 
1678
 
    def tearDown(self):
 
1691
    def stop_server(self):
1679
1692
        """Remove the server and cleanup any resources it owns."""
1680
1693
 
1681
 
    def get_url(self):
1682
 
        """Return a url for this server.
1683
 
 
1684
 
        If the transport does not represent a disk directory (i.e. it is
1685
 
        a database like svn, or a memory only transport, it should return
1686
 
        a connection to a newly established resource for this Server.
1687
 
        Otherwise it should return a url that will provide access to the path
1688
 
        that was os.getcwdu() when setUp() was called.
1689
 
 
1690
 
        Subsequent calls will return the same resource.
1691
 
        """
1692
 
        raise NotImplementedError
1693
 
 
1694
 
    def get_bogus_url(self):
1695
 
        """Return a url for this protocol, that will fail to connect.
1696
 
 
1697
 
        This may raise NotImplementedError to indicate that this server cannot
1698
 
        provide bogus urls.
1699
 
        """
1700
 
        raise NotImplementedError
1701
 
 
1702
1694
 
1703
1695
# None is the default transport, for things with no url scheme
1704
1696
register_transport_proto('file://',
1858
1850
 
1859
1851
 
1860
1852
transport_server_registry = registry.Registry()
1861
 
transport_server_registry.register_lazy('bzr', 'bzrlib.smart.server', 
 
1853
transport_server_registry.register_lazy('bzr', 'bzrlib.smart.server',
1862
1854
    'serve_bzr', help="The Bazaar smart server protocol over TCP. (default port: 4155)")
1863
1855
transport_server_registry.default_key = 'bzr'