~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/medium.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-07-13 17:01:23 UTC
  • mfrom: (3530.1.2 lazy_medium)
  • Revision ID: pqm@pqm.ubuntu.com-20080713170123-90yv7a7n8hqp4yjr
(jam) Use lazy importing for bzrlib.smart.medium,
        helps remove dependencies that aren't used

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
import sys
30
30
import urllib
31
31
 
 
32
from bzrlib.lazy_import import lazy_import
 
33
lazy_import(globals(), """
32
34
from bzrlib import (
33
35
    errors,
34
36
    osutils,
35
37
    symbol_versioning,
36
38
    urlutils,
37
39
    )
38
 
from bzrlib.smart.protocol import (
39
 
    MESSAGE_VERSION_THREE,
40
 
    REQUEST_VERSION_TWO,
41
 
    SmartClientRequestProtocolOne,
42
 
    SmartServerRequestProtocolOne,
43
 
    SmartServerRequestProtocolTwo,
44
 
    build_server_protocol_three
45
 
    )
 
40
from bzrlib.smart import protocol
46
41
from bzrlib.transport import ssh
 
42
""")
47
43
 
48
44
 
49
45
def _get_protocol_factory_for_bytes(bytes):
67
63
        root_client_path.  unused_bytes are any bytes that were not part of a
68
64
        protocol version marker.
69
65
    """
70
 
    if bytes.startswith(MESSAGE_VERSION_THREE):
71
 
        protocol_factory = build_server_protocol_three
72
 
        bytes = bytes[len(MESSAGE_VERSION_THREE):]
73
 
    elif bytes.startswith(REQUEST_VERSION_TWO):
74
 
        protocol_factory = SmartServerRequestProtocolTwo
75
 
        bytes = bytes[len(REQUEST_VERSION_TWO):]
 
66
    if bytes.startswith(protocol.MESSAGE_VERSION_THREE):
 
67
        protocol_factory = protocol.build_server_protocol_three
 
68
        bytes = bytes[len(protocol.MESSAGE_VERSION_THREE):]
 
69
    elif bytes.startswith(protocol.REQUEST_VERSION_TWO):
 
70
        protocol_factory = protocol.SmartServerRequestProtocolTwo
 
71
        bytes = bytes[len(protocol.REQUEST_VERSION_TWO):]
76
72
    else:
77
 
        protocol_factory = SmartServerRequestProtocolOne
 
73
        protocol_factory = protocol.SmartServerRequestProtocolOne
78
74
    return protocol_factory, bytes
79
75
 
80
76
 
489
485
                medium_request = self.get_request()
490
486
                # Send a 'hello' request in protocol version one, for maximum
491
487
                # backwards compatibility.
492
 
                client_protocol = SmartClientRequestProtocolOne(medium_request)
 
488
                client_protocol = protocol.SmartClientRequestProtocolOne(medium_request)
493
489
                client_protocol.query_version()
494
490
                self._done_hello = True
495
491
            except errors.SmartProtocolError, e: