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