/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: Martin Pool
  • Date: 2010-04-21 11:27:04 UTC
  • mto: This revision was merged to the branch mainline in revision 5189.
  • Revision ID: mbp@canonical.com-20100421112704-zijso22b6pdevrxy
Simplify various code to use user_url

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    lock,
28
28
    lockdir,
29
29
    repository,
30
 
    repository as _mod_repository,
31
30
    revision,
32
31
    revision as _mod_revision,
33
32
    static_tuple,
34
33
    symbol_versioning,
35
34
)
36
 
from bzrlib.branch import BranchReferenceFormat, BranchWriteLockResult
 
35
from bzrlib.branch import BranchReferenceFormat
37
36
from bzrlib.bzrdir import BzrDir, RemoteBzrDirFormat
38
37
from bzrlib.decorators import needs_read_lock, needs_write_lock, only_raises
39
38
from bzrlib.errors import (
43
42
from bzrlib.lockable_files import LockableFiles
44
43
from bzrlib.smart import client, vfs, repository as smart_repo
45
44
from bzrlib.revision import ensure_null, NULL_REVISION
46
 
from bzrlib.repository import RepositoryWriteLockResult
47
45
from bzrlib.trace import mutter, note, warning
48
46
 
49
47
 
998
996
        pass
999
997
 
1000
998
    def lock_read(self):
1001
 
        """Lock the repository for read operations.
1002
 
 
1003
 
        :return: A bzrlib.lock.LogicalLockResult.
1004
 
        """
1005
999
        # wrong eventually - want a local lock cache context
1006
1000
        if not self._lock_mode:
1007
1001
            self._note_lock('r')
1014
1008
                repo.lock_read()
1015
1009
        else:
1016
1010
            self._lock_count += 1
1017
 
        return lock.LogicalLockResult(self.unlock)
1018
1011
 
1019
1012
    def _remote_lock_write(self, token):
1020
1013
        path = self.bzrdir._path_for_remote_call(self._client)
1060
1053
            raise errors.ReadOnlyError(self)
1061
1054
        else:
1062
1055
            self._lock_count += 1
1063
 
        return RepositoryWriteLockResult(self.unlock, self._lock_token or None)
 
1056
        return self._lock_token or None
1064
1057
 
1065
1058
    def leave_lock_in_place(self):
1066
1059
        if not self._lock_token:
1246
1239
            # state, so always add a lock here. If a caller passes us a locked
1247
1240
            # repository, they are responsible for unlocking it later.
1248
1241
            repository.lock_read()
1249
 
        self._check_fallback_repository(repository)
1250
1242
        self._fallback_repositories.append(repository)
1251
1243
        # If self._real_repository was parameterised already (e.g. because a
1252
1244
        # _real_branch had its get_stacked_on_url method called), then the
1257
1249
            if repository.user_url not in fallback_locations:
1258
1250
                self._real_repository.add_fallback_repository(repository)
1259
1251
 
1260
 
    def _check_fallback_repository(self, repository):
1261
 
        """Check that this repository can fallback to repository safely.
1262
 
 
1263
 
        Raise an error if not.
1264
 
 
1265
 
        :param repository: A repository to fallback to.
1266
 
        """
1267
 
        return _mod_repository.InterRepository._assert_same_model(
1268
 
            self, repository)
1269
 
 
1270
1252
    def add_inventory(self, revid, inv, parents):
1271
1253
        self._ensure_real()
1272
1254
        return self._real_repository.add_inventory(revid, inv, parents)
1625
1607
        return self._real_repository.inventories
1626
1608
 
1627
1609
    @needs_write_lock
1628
 
    def pack(self, hint=None, clean_obsolete_packs=False):
 
1610
    def pack(self, hint=None):
1629
1611
        """Compress the data within the repository.
1630
1612
 
1631
1613
        This is not currently implemented within the smart server.
1632
1614
        """
1633
1615
        self._ensure_real()
1634
 
        return self._real_repository.pack(hint=hint, clean_obsolete_packs=clean_obsolete_packs)
 
1616
        return self._real_repository.pack(hint=hint)
1635
1617
 
1636
1618
    @property
1637
1619
    def revisions(self):
2393
2375
            self._vfs_set_tags_bytes(bytes)
2394
2376
 
2395
2377
    def lock_read(self):
2396
 
        """Lock the branch for read operations.
2397
 
 
2398
 
        :return: A bzrlib.lock.LogicalLockResult.
2399
 
        """
2400
2378
        self.repository.lock_read()
2401
2379
        if not self._lock_mode:
2402
2380
            self._note_lock('r')
2406
2384
                self._real_branch.lock_read()
2407
2385
        else:
2408
2386
            self._lock_count += 1
2409
 
        return lock.LogicalLockResult(self.unlock)
2410
2387
 
2411
2388
    def _remote_lock_write(self, token):
2412
2389
        if token is None:
2413
2390
            branch_token = repo_token = ''
2414
2391
        else:
2415
2392
            branch_token = token
2416
 
            repo_token = self.repository.lock_write().repository_token
 
2393
            repo_token = self.repository.lock_write()
2417
2394
            self.repository.unlock()
2418
2395
        err_context = {'token': token}
2419
2396
        response = self._call(
2456
2433
            self._lock_count += 1
2457
2434
            # Re-lock the repository too.
2458
2435
            self.repository.lock_write(self._repo_lock_token)
2459
 
        return BranchWriteLockResult(self.unlock, self._lock_token or None)
 
2436
        return self._lock_token or None
2460
2437
 
2461
2438
    def _unlock(self, branch_token, repo_token):
2462
2439
        err_context = {'token': str((branch_token, repo_token))}