~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: Robert J. Tanner
  • Date: 2009-06-10 03:56:49 UTC
  • mfrom: (4423 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4425.
  • Revision ID: tanner@real-time.com-20090610035649-7rfx4cls4550zc3c
Merge 1.15.1 back to trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import bz2
21
21
 
22
22
from bzrlib import (
 
23
    bencode,
23
24
    branch,
24
25
    bzrdir,
25
26
    config,
45
46
from bzrlib.smart import client, vfs, repository as smart_repo
46
47
from bzrlib.revision import ensure_null, NULL_REVISION
47
48
from bzrlib.trace import mutter, note, warning
48
 
from bzrlib.util import bencode
49
49
 
50
50
 
51
51
class _RpcHelper(object):
670
670
        self._ensure_real()
671
671
        return self._real_repository.suspend_write_group()
672
672
 
673
 
    def get_missing_parent_inventories(self):
 
673
    def get_missing_parent_inventories(self, check_for_missing_texts=True):
674
674
        self._ensure_real()
675
 
        return self._real_repository.get_missing_parent_inventories()
 
675
        return self._real_repository.get_missing_parent_inventories(
 
676
            check_for_missing_texts=check_for_missing_texts)
676
677
 
677
678
    def _ensure_real(self):
678
679
        """Ensure that there is a _real_repository set.
860
861
            self._unstacked_provider.enable_cache(cache_misses=True)
861
862
            if self._real_repository is not None:
862
863
                self._real_repository.lock_read()
 
864
            for repo in self._fallback_repositories:
 
865
                repo.lock_read()
863
866
        else:
864
867
            self._lock_count += 1
865
 
        for repo in self._fallback_repositories:
866
 
            repo.lock_read()
867
868
 
868
869
    def _remote_lock_write(self, token):
869
870
        path = self.bzrdir._path_for_remote_call(self._client)
901
902
            self._lock_count = 1
902
903
            cache_misses = self._real_repository is None
903
904
            self._unstacked_provider.enable_cache(cache_misses=cache_misses)
 
905
            for repo in self._fallback_repositories:
 
906
                # Writes don't affect fallback repos
 
907
                repo.lock_read()
904
908
        elif self._lock_mode == 'r':
905
909
            raise errors.ReadOnlyError(self)
906
910
        else:
907
911
            self._lock_count += 1
908
 
        for repo in self._fallback_repositories:
909
 
            # Writes don't affect fallback repos
910
 
            repo.lock_read()
911
912
        return self._lock_token or None
912
913
 
913
914
    def leave_lock_in_place(self):
1015
1016
                self._lock_token = None
1016
1017
                if not self._leave_lock:
1017
1018
                    self._unlock(old_token)
 
1019
        # Fallbacks are always 'lock_read()' so we don't pay attention to
 
1020
        # self._leave_lock
 
1021
        for repo in self._fallback_repositories:
 
1022
            repo.unlock()
1018
1023
 
1019
1024
    def break_lock(self):
1020
1025
        # should hand off to the network
1084
1089
        # We need to accumulate additional repositories here, to pass them in
1085
1090
        # on various RPC's.
1086
1091
        #
 
1092
        if self.is_locked():
 
1093
            # We will call fallback.unlock() when we transition to the unlocked
 
1094
            # state, so always add a lock here. If a caller passes us a locked
 
1095
            # repository, they are responsible for unlocking it later.
 
1096
            repository.lock_read()
1087
1097
        self._fallback_repositories.append(repository)
1088
1098
        # If self._real_repository was parameterised already (e.g. because a
1089
1099
        # _real_branch had its get_stacked_on_url method called), then the
1566
1576
            providers.insert(0, other)
1567
1577
        providers.extend(r._make_parents_provider() for r in
1568
1578
                         self._fallback_repositories)
1569
 
        return graph._StackedParentsProvider(providers)
 
1579
        return graph.StackedParentsProvider(providers)
1570
1580
 
1571
1581
    def _serialise_search_recipe(self, recipe):
1572
1582
        """Serialise a graph search recipe.
1971
1981
        except (errors.NotStacked, errors.UnstackableBranchFormat,
1972
1982
            errors.UnstackableRepositoryFormat), e:
1973
1983
            return
1974
 
        self._activate_fallback_location(fallback_url, None)
 
1984
        self._activate_fallback_location(fallback_url)
1975
1985
 
1976
1986
    def _get_config(self):
1977
1987
        return RemoteBranchConfig(self)