~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: John Arbash Meinel
  • Date: 2009-10-12 20:12:32 UTC
  • mfrom: (4736 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4749.
  • Revision ID: john@arbash-meinel.com-20091012201232-ccnceqvk29u7v22u
Merge bzr.dev 4736

This includes the updates to StaticTuple, etc, to build using Pyrex 0.9.6.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
)
34
34
from bzrlib.branch import BranchReferenceFormat
35
35
from bzrlib.bzrdir import BzrDir, RemoteBzrDirFormat
36
 
from bzrlib.decorators import needs_read_lock, needs_write_lock
 
36
from bzrlib.decorators import needs_read_lock, needs_write_lock, only_raises
37
37
from bzrlib.errors import (
38
38
    NoSuchRevision,
39
39
    SmartProtocolError,
619
619
        return self._custom_format._serializer
620
620
 
621
621
 
622
 
class RemoteRepository(_RpcHelper):
 
622
class RemoteRepository(_RpcHelper, lock._RelockDebugMixin):
623
623
    """Repository accessed over rpc.
624
624
 
625
625
    For the moment most operations are performed using local transport-backed
949
949
    def lock_read(self):
950
950
        # wrong eventually - want a local lock cache context
951
951
        if not self._lock_mode:
 
952
            self._note_lock('r')
952
953
            self._lock_mode = 'r'
953
954
            self._lock_count = 1
954
955
            self._unstacked_provider.enable_cache(cache_misses=True)
974
975
 
975
976
    def lock_write(self, token=None, _skip_rpc=False):
976
977
        if not self._lock_mode:
 
978
            self._note_lock('w')
977
979
            if _skip_rpc:
978
980
                if self._lock_token is not None:
979
981
                    if token != self._lock_token:
1082
1084
        else:
1083
1085
            raise errors.UnexpectedSmartServerResponse(response)
1084
1086
 
 
1087
    @only_raises(errors.LockNotHeld, errors.LockBroken)
1085
1088
    def unlock(self):
1086
1089
        if not self._lock_count:
1087
1090
            return lock.cant_unlock_not_held(self)
2081
2084
        return self._custom_format.supports_set_append_revisions_only()
2082
2085
 
2083
2086
 
2084
 
class RemoteBranch(branch.Branch, _RpcHelper):
 
2087
class RemoteBranch(branch.Branch, _RpcHelper, lock._RelockDebugMixin):
2085
2088
    """Branch stored on a server accessed by HPSS RPC.
2086
2089
 
2087
2090
    At the moment most operations are mapped down to simple file operations.
2318
2321
    def lock_read(self):
2319
2322
        self.repository.lock_read()
2320
2323
        if not self._lock_mode:
 
2324
            self._note_lock('r')
2321
2325
            self._lock_mode = 'r'
2322
2326
            self._lock_count = 1
2323
2327
            if self._real_branch is not None:
2343
2347
 
2344
2348
    def lock_write(self, token=None):
2345
2349
        if not self._lock_mode:
 
2350
            self._note_lock('w')
2346
2351
            # Lock the branch and repo in one remote call.
2347
2352
            remote_tokens = self._remote_lock_write(token)
2348
2353
            self._lock_token, self._repo_lock_token = remote_tokens
2383
2388
            return
2384
2389
        raise errors.UnexpectedSmartServerResponse(response)
2385
2390
 
 
2391
    @only_raises(errors.LockNotHeld, errors.LockBroken)
2386
2392
    def unlock(self):
2387
2393
        try:
2388
2394
            self._lock_count -= 1