~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/medium.py

MergeĀ fromĀ old-hpss-branch-implementation-test.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
447
447
 
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?
450
450
 
451
451
        Typical use::
452
452
 
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()
456
456
            else:
457
457
                try:
458
458
                    do_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()
462
462
 
463
 
        :seealso: _remote_is_not
 
463
        :seealso: _remember_remote_is_before
464
464
        """
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
467
 
            return True
468
 
        return version_tuple < self._remote_version_is_less_than
 
467
            return False
 
468
        return version_tuple >= self._remote_version_is_before
469
469
 
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.
472
472
 
473
 
        :seealso: _is_remote_at_least
 
473
        :seealso: _is_remote_before
474
474
        """
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 "
479
 
                "previously."
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
482
482
 
483
483
    def protocol_version(self):
484
484
        """Find out if 'hello' smart request works."""