~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/remote.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-10-13 06:08:53 UTC
  • mfrom: (4737.1.1 merge-2.0-into-devel)
  • Revision ID: pqm@pqm.ubuntu.com-20091013060853-erk2aaj80fnkrv25
(andrew) Merge lp:bzr/2.0 into lp:bzr, including fixes for #322807,
        #389413, #402623 and documentation improvements.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006 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
20
20
imported from bzrlib.smart.
21
21
"""
22
22
 
23
 
from __future__ import absolute_import
24
 
 
25
23
__all__ = ['RemoteTransport', 'RemoteTCPTransport', 'RemoteSSHTransport']
26
24
 
27
25
from cStringIO import StringIO
36
34
    urlutils,
37
35
    )
38
36
from bzrlib.smart import client, medium
 
37
from bzrlib.symbol_versioning import (
 
38
    deprecated_method,
 
39
    )
39
40
 
40
41
 
41
42
class _SmartStat(object):
169
170
 
170
171
    def _remote_path(self, relpath):
171
172
        """Returns the Unicode version of the absolute path for relpath."""
172
 
        return urlutils.URL._combine_paths(self._parsed_url.path, relpath)
 
173
        return self._combine_paths(self._path, relpath)
173
174
 
174
175
    def _call(self, method, *args):
175
176
        resp = self._call2(method, *args)
434
435
        remote._translate_error(err, path=relpath)
435
436
 
436
437
    def disconnect(self):
437
 
        m = self.get_smart_medium()
438
 
        if m is not None:
439
 
            m.disconnect()
 
438
        self.get_smart_medium().disconnect()
440
439
 
441
440
    def stat(self, relpath):
442
441
        resp = self._call2('stat', self._remote_path(relpath))
482
481
 
483
482
    def _build_medium(self):
484
483
        client_medium = medium.SmartTCPClientMedium(
485
 
            self._parsed_url.host, self._parsed_url.port, self.base)
 
484
            self._host, self._port, self.base)
486
485
        return client_medium, None
487
486
 
488
487
 
495
494
 
496
495
    def _build_medium(self):
497
496
        client_medium = medium.SmartTCPClientMedium(
498
 
            self._parsed_url.host, self._parsed_url.port, self.base)
 
497
            self._host, self._port, self.base)
499
498
        client_medium._protocol_version = 2
500
499
        client_medium._remember_remote_is_before((1, 6))
501
500
        return client_medium, None
511
510
    def _build_medium(self):
512
511
        location_config = config.LocationConfig(self.base)
513
512
        bzr_remote_path = location_config.get_bzr_remote_path()
514
 
        user = self._parsed_url.user
 
513
        user = self._user
515
514
        if user is None:
516
515
            auth = config.AuthenticationConfig()
517
 
            user = auth.get_user('ssh', self._parsed_url.host,
518
 
                self._parsed_url.port)
519
 
        ssh_params = medium.SSHParams(self._parsed_url.host,
520
 
                self._parsed_url.port, user, self._parsed_url.password,
521
 
                bzr_remote_path)
522
 
        client_medium = medium.SmartSSHClientMedium(self.base, ssh_params)
523
 
        return client_medium, (user, self._parsed_url.password)
 
516
            user = auth.get_user('ssh', self._host, self._port)
 
517
        client_medium = medium.SmartSSHClientMedium(self._host, self._port,
 
518
            user, self._password, self.base,
 
519
            bzr_remote_path=bzr_remote_path)
 
520
        return client_medium, (user, self._password)
524
521
 
525
522
 
526
523
class RemoteHTTPTransport(RemoteTransport):
540
537
            # url only for an intial construction (when the url came from the
541
538
            # command-line).
542
539
            http_url = base[len('bzr+'):]
543
 
            self._http_transport = transport.get_transport_from_url(http_url)
 
540
            self._http_transport = transport.get_transport(http_url)
544
541
        else:
545
542
            self._http_transport = http_transport
546
543
        super(RemoteHTTPTransport, self).__init__(
604
601
    """Return (transport, server) permutations for testing."""
605
602
    ### We may need a little more test framework support to construct an
606
603
    ### appropriate RemoteTransport in the future.
607
 
    from bzrlib.tests import test_server
608
 
    return [(RemoteTCPTransport, test_server.SmartTCPServer_for_testing)]
 
604
    from bzrlib.smart import server
 
605
    return [(RemoteTCPTransport, server.SmartTCPServer_for_testing)]