440
440
self._protocol_version = None
441
441
self._done_hello = False
442
442
# Be optimistic: we assume the remote end can accept new remote
443
# requests until we get an error saying otherwise. (1.2 adds some
444
# requests that send bodies, which confuses older servers.)
445
self._remote_is_at_least_1_2 = True
443
# requests until we get an error saying otherwise.
444
# _remote_version_is_before tracks the bzr version the remote side
445
# can be based on what we've seen so far.
446
self._remote_version_is_before = None
448
def _is_remote_before(self, version_tuple):
449
"""Is it possible the remote side is supports RPCs for a given version?
453
needed_version = (1, 2)
454
if medium._is_remote_before(needed_version):
455
fallback_to_pre_1_2_rpc()
459
except UnknownSmartMethod:
460
medium._remember_remote_is_before(needed_version)
461
fallback_to_pre_1_2_rpc()
463
:seealso: _remember_remote_is_before
465
if self._remote_version_is_before is None:
466
# So far, the remote side seems to support everything
468
return version_tuple >= self._remote_version_is_before
470
def _remember_remote_is_before(self, version_tuple):
471
"""Tell this medium that the remote side is older the given version.
473
:seealso: _is_remote_before
475
if (self._remote_version_is_before is not None and
476
version_tuple > self._remote_version_is_before):
477
raise AssertionError, (
478
"_remember_remote_is_before(%r) called, but "
479
"_remember_remote_is_before(%r) was called previously."
480
% (version_tuple, self._remote_version_is_before))
481
self._remote_version_is_before = version_tuple
447
483
def protocol_version(self):
448
484
"""Find out if 'hello' smart request works."""