[MERGE][0.16] Allow new smart client to work with old (<= 0.15) smart servers.

Robert Collins robertc at robertcollins.net
Tue Apr 24 12:57:14 BST 2007


Andrew Bennetts wrote:

> === modified file bzrlib/bzrdir.py
> --- bzrlib/bzrdir.py
> +++ bzrlib/bzrdir.py
> @@ -57,6 +57,7 @@
>      sha_string,
>      )
>  from bzrlib.smart.client import _SmartClient
> +from bzrlib.smart import protocol
>  from bzrlib.store.revision.text import TextRevisionStore
>  from bzrlib.store.text import TextStore
>  from bzrlib.store.versioned import WeaveStore
> @@ -2232,12 +2233,20 @@
>      def probe_transport(klass, transport):
>          """Return a RemoteBzrDirFormat object if it looks possible."""
>          try:
> -            transport.get_smart_client()
> +            client = transport.get_smart_client()
>          except (NotImplementedError, AttributeError,
>                  errors.TransportNotPossible):
>              # no smart server, so not a branch for this format type.
>              raise errors.NotBranchError(path=transport.base)
>          else:
> +            # Send a 'hello' request in protocol version one, and fail if the
> +            # server doesn't support our required version (2).
> +            request = client.get_request()
> +            smart_protocol = protocol.SmartClientRequestProtocolOne(request)
> +            smart_protocol.call('hello')
> +            server_version = smart_protocol.read_response_tuple(expect_body=False)
> +            if server_version != '2':
> +                raise errors.NotBranchError(path=transport.base)
>              return klass()


Isn't

smart_protocol = protocol.SmartClientRequestProtocolOne(request)
server_version = smart_protocol.query_version()
if server_version != '2':
     raise errors.NotBranchError(path=transport.base)

better?

Other than that,

+1

-Rob



More information about the bazaar mailing list