1062
1061
source = self.clone(from_relpath)
1063
1062
target = self.clone(to_relpath)
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)
1069
1064
source.copy_tree_to_transport(target)
1071
1066
def copy_tree_to_transport(self, to_transport):
1207
1202
count = self._iterate_over(relpaths, gather, pb, 'stat', expand=False)
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)
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)
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)
1222
1205
def listable(self):
1223
1206
"""Return True if this store supports listing."""
1224
1207
raise NotImplementedError(self.listable)
1286
1269
# should be asked to ConnectedTransport only.
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.
1295
1272
def _redirected_to(self, source, target):
1296
1273
"""Returns a transport suitable to re-issue a redirected request.
1556
1533
transport = self.__class__(other_base, _from_transport=self)
1557
1534
return transport
1559
def disconnect(self):
1560
"""Disconnect the transport.
1562
If and when required the transport willl reconnect automatically.
1564
raise NotImplementedError(self.disconnect)
1537
# We try to recognize an url lazily (ignoring user, password, etc)
1538
_urlRE = re.compile(r'^(?P<proto>[^:/\\]+)://(?P<rest>.*)$')
1567
1540
def get_transport(base, possible_transports=None):
1568
1541
"""Open a transport to access a URL or directory.
1689
1663
class Server(object):
1690
1664
"""A Transport Server.
1692
The Server interface provides a server for a given transport type.
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 start_server is called.
1671
Note that these are real servers - they must implement all the things
1672
that we want bzr transports to take advantage of.
1695
1675
def start_server(self):
1698
1678
def stop_server(self):
1699
1679
"""Remove the server and cleanup any resources it owns."""
1682
"""Return a url for this server.
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 start_server() was called.
1690
Subsequent calls will return the same resource.
1692
raise NotImplementedError
1694
def get_bogus_url(self):
1695
"""Return a url for this protocol, that will fail to connect.
1697
This may raise NotImplementedError to indicate that this server cannot
1700
raise NotImplementedError
1702
1703
# None is the default transport, for things with no url scheme
1703
1704
register_transport_proto('file://',
1749
1750
register_lazy_transport('ftp://', 'bzrlib.transport.ftp', 'FtpTransport')
1750
1751
register_transport_proto('aftp://', help="Access using active FTP.")
1751
1752
register_lazy_transport('aftp://', 'bzrlib.transport.ftp', 'FtpTransport')
1752
register_transport_proto('gio+', help="Access using any GIO supported protocols.")
1753
register_lazy_transport('gio+', 'bzrlib.transport.gio_transport', 'GioTransport')
1756
# Default to trying GSSAPI authentication (if the kerberos module is
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',
1772
register_lazy_transport('aftp+nogssapi://', 'bzrlib.transport.ftp',
1756
kerberos_available = True
1758
kerberos_available = False
1760
if kerberos_available:
1761
# Default to trying GSSAPI authentication (if the kerberos module is
1763
register_transport_proto('ftp+gssapi://', register_netloc=True)
1764
register_lazy_transport('ftp+gssapi://', 'bzrlib.transport.ftp._gssapi',
1765
'GSSAPIFtpTransport')
1766
register_transport_proto('aftp+gssapi://', register_netloc=True)
1767
register_lazy_transport('aftp+gssapi://', 'bzrlib.transport.ftp._gssapi',
1768
'GSSAPIFtpTransport')
1769
register_transport_proto('ftp+nogssapi://', register_netloc=True)
1770
register_transport_proto('aftp+nogssapi://', register_netloc=True)
1772
register_lazy_transport('ftp://', 'bzrlib.transport.ftp._gssapi',
1773
'GSSAPIFtpTransport')
1774
register_lazy_transport('aftp://', 'bzrlib.transport.ftp._gssapi',
1775
'GSSAPIFtpTransport')
1776
register_lazy_transport('ftp+nogssapi://', 'bzrlib.transport.ftp',
1778
register_lazy_transport('aftp+nogssapi://', 'bzrlib.transport.ftp',
1775
1781
register_transport_proto('memory://')
1776
1782
register_lazy_transport('memory://', 'bzrlib.transport.memory',
1854
1860
transport_server_registry = registry.Registry()
1855
transport_server_registry.register_lazy('bzr', 'bzrlib.smart.server',
1861
transport_server_registry.register_lazy('bzr', 'bzrlib.smart.server',
1856
1862
'serve_bzr', help="The Bazaar smart server protocol over TCP. (default port: 4155)")
1857
1863
transport_server_registry.default_key = 'bzr'