~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: Parth Malwankar
  • Date: 2010-05-05 14:11:13 UTC
  • mfrom: (5211 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5213.
  • Revision ID: parth.malwankar@gmail.com-20100505141113-c21oicoxzb3u6if6
merged in changes from trunk.

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, BranchWriteLockResult
 
36
from bzrlib.branch import BranchReferenceFormat
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
47
46
from bzrlib.trace import mutter, note, warning
48
47
 
49
48
 
998
997
        pass
999
998
 
1000
999
    def lock_read(self):
1001
 
        """Lock the repository for read operations.
1002
 
 
1003
 
        :return: An object with an unlock method which will release the lock
1004
 
            obtained.
1005
 
        """
1006
1000
        # wrong eventually - want a local lock cache context
1007
1001
        if not self._lock_mode:
1008
1002
            self._note_lock('r')
1015
1009
                repo.lock_read()
1016
1010
        else:
1017
1011
            self._lock_count += 1
1018
 
        return self
1019
1012
 
1020
1013
    def _remote_lock_write(self, token):
1021
1014
        path = self.bzrdir._path_for_remote_call(self._client)
1061
1054
            raise errors.ReadOnlyError(self)
1062
1055
        else:
1063
1056
            self._lock_count += 1
1064
 
        return RepositoryWriteLockResult(self.unlock, self._lock_token or None)
 
1057
        return self._lock_token or None
1065
1058
 
1066
1059
    def leave_lock_in_place(self):
1067
1060
        if not self._lock_token:
1313
1306
        return self._real_repository.make_working_trees()
1314
1307
 
1315
1308
    def refresh_data(self):
1316
 
        """Re-read any data needed to to synchronise with disk.
 
1309
        """Re-read any data needed to synchronise with disk.
1317
1310
 
1318
1311
        This method is intended to be called after another repository instance
1319
1312
        (such as one used by a smart server) has inserted data into the
1320
 
        repository. It may not be called during a write group, but may be
1321
 
        called at any other time.
 
1313
        repository. On all repositories this will work outside of write groups.
 
1314
        Some repository formats (pack and newer for bzrlib native formats)
 
1315
        support refresh_data inside write groups. If called inside a write
 
1316
        group on a repository that does not support refreshing in a write group
 
1317
        IsInWriteGroupError will be raised.
1322
1318
        """
1323
 
        if self.is_in_write_group():
1324
 
            raise errors.InternalBzrError(
1325
 
                "May not refresh_data while in a write group.")
1326
1319
        if self._real_repository is not None:
1327
1320
            self._real_repository.refresh_data()
1328
1321
 
2394
2387
            self._vfs_set_tags_bytes(bytes)
2395
2388
 
2396
2389
    def lock_read(self):
2397
 
        """Lock the branch for read operations.
2398
 
 
2399
 
        :return: An object with an unlock method which will release the lock
2400
 
            obtained.
2401
 
        """
2402
2390
        self.repository.lock_read()
2403
2391
        if not self._lock_mode:
2404
2392
            self._note_lock('r')
2408
2396
                self._real_branch.lock_read()
2409
2397
        else:
2410
2398
            self._lock_count += 1
2411
 
        return self
2412
2399
 
2413
2400
    def _remote_lock_write(self, token):
2414
2401
        if token is None:
2415
2402
            branch_token = repo_token = ''
2416
2403
        else:
2417
2404
            branch_token = token
2418
 
            repo_token = self.repository.lock_write().repository_token
 
2405
            repo_token = self.repository.lock_write()
2419
2406
            self.repository.unlock()
2420
2407
        err_context = {'token': token}
2421
2408
        response = self._call(
2458
2445
            self._lock_count += 1
2459
2446
            # Re-lock the repository too.
2460
2447
            self.repository.lock_write(self._repo_lock_token)
2461
 
        return BranchWriteLockResult(self.unlock, self._lock_token or None)
 
2448
        return self._lock_token or None
2462
2449
 
2463
2450
    def _unlock(self, branch_token, repo_token):
2464
2451
        err_context = {'token': str((branch_token, repo_token))}