~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: John Arbash Meinel
  • Date: 2010-05-11 14:14:55 UTC
  • mfrom: (5223.1.1 global_chk_attrs)
  • mto: This revision was merged to the branch mainline in revision 5225.
  • Revision ID: john@arbash-meinel.com-20100511141455-5xq2dqfei11m5lms
Bring in the global chk change, which includes some more bzr.dev code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
    static_tuple,
34
34
    symbol_versioning,
35
35
)
36
 
from bzrlib.branch import BranchReferenceFormat
 
36
from bzrlib.branch import BranchReferenceFormat, BranchWriteLockResult
37
37
from bzrlib.bzrdir import BzrDir, RemoteBzrDirFormat
38
38
from bzrlib.decorators import needs_read_lock, needs_write_lock, only_raises
39
39
from bzrlib.errors import (
43
43
from bzrlib.lockable_files import LockableFiles
44
44
from bzrlib.smart import client, vfs, repository as smart_repo
45
45
from bzrlib.revision import ensure_null, NULL_REVISION
 
46
from bzrlib.repository import RepositoryWriteLockResult
46
47
from bzrlib.trace import mutter, note, warning
47
48
 
48
49
 
1000
1001
        pass
1001
1002
 
1002
1003
    def lock_read(self):
 
1004
        """Lock the repository for read operations.
 
1005
 
 
1006
        :return: A bzrlib.lock.LogicalLockResult.
 
1007
        """
1003
1008
        # wrong eventually - want a local lock cache context
1004
1009
        if not self._lock_mode:
1005
1010
            self._note_lock('r')
1012
1017
                repo.lock_read()
1013
1018
        else:
1014
1019
            self._lock_count += 1
 
1020
        return lock.LogicalLockResult(self.unlock)
1015
1021
 
1016
1022
    def _remote_lock_write(self, token):
1017
1023
        path = self.bzrdir._path_for_remote_call(self._client)
1057
1063
            raise errors.ReadOnlyError(self)
1058
1064
        else:
1059
1065
            self._lock_count += 1
1060
 
        return self._lock_token or None
 
1066
        return RepositoryWriteLockResult(self.unlock, self._lock_token or None)
1061
1067
 
1062
1068
    def leave_lock_in_place(self):
1063
1069
        if not self._lock_token:
2390
2396
            self._vfs_set_tags_bytes(bytes)
2391
2397
 
2392
2398
    def lock_read(self):
 
2399
        """Lock the branch for read operations.
 
2400
 
 
2401
        :return: A bzrlib.lock.LogicalLockResult.
 
2402
        """
2393
2403
        self.repository.lock_read()
2394
2404
        if not self._lock_mode:
2395
2405
            self._note_lock('r')
2399
2409
                self._real_branch.lock_read()
2400
2410
        else:
2401
2411
            self._lock_count += 1
 
2412
        return lock.LogicalLockResult(self.unlock)
2402
2413
 
2403
2414
    def _remote_lock_write(self, token):
2404
2415
        if token is None:
2405
2416
            branch_token = repo_token = ''
2406
2417
        else:
2407
2418
            branch_token = token
2408
 
            repo_token = self.repository.lock_write()
 
2419
            repo_token = self.repository.lock_write().repository_token
2409
2420
            self.repository.unlock()
2410
2421
        err_context = {'token': token}
2411
2422
        response = self._call(
2448
2459
            self._lock_count += 1
2449
2460
            # Re-lock the repository too.
2450
2461
            self.repository.lock_write(self._repo_lock_token)
2451
 
        return self._lock_token or None
 
2462
        return BranchWriteLockResult(self.unlock, self._lock_token or None)
2452
2463
 
2453
2464
    def _unlock(self, branch_token, repo_token):
2454
2465
        err_context = {'token': str((branch_token, repo_token))}