/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-23 00:44:15 UTC
  • mto: This revision was merged to the branch mainline in revision 5189.
  • Revision ID: mbp@canonical.com-20100423004415-py8ozrtkjo6tphj2
Update more code to use user_transport when it should

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: An object with an unlock method which will release the lock
1004
 
            obtained.
1005
 
        """
1006
999
        # wrong eventually - want a local lock cache context
1007
1000
        if not self._lock_mode:
1008
1001
            self._note_lock('r')
1015
1008
                repo.lock_read()
1016
1009
        else:
1017
1010
            self._lock_count += 1
1018
 
        return self
1019
1011
 
1020
1012
    def _remote_lock_write(self, token):
1021
1013
        path = self.bzrdir._path_for_remote_call(self._client)
1061
1053
            raise errors.ReadOnlyError(self)
1062
1054
        else:
1063
1055
            self._lock_count += 1
1064
 
        return RepositoryWriteLockResult(self.unlock, self._lock_token or None)
 
1056
        return self._lock_token or None
1065
1057
 
1066
1058
    def leave_lock_in_place(self):
1067
1059
        if not self._lock_token:
1247
1239
            # state, so always add a lock here. If a caller passes us a locked
1248
1240
            # repository, they are responsible for unlocking it later.
1249
1241
            repository.lock_read()
1250
 
        self._check_fallback_repository(repository)
1251
1242
        self._fallback_repositories.append(repository)
1252
1243
        # If self._real_repository was parameterised already (e.g. because a
1253
1244
        # _real_branch had its get_stacked_on_url method called), then the
1258
1249
            if repository.user_url not in fallback_locations:
1259
1250
                self._real_repository.add_fallback_repository(repository)
1260
1251
 
1261
 
    def _check_fallback_repository(self, repository):
1262
 
        """Check that this repository can fallback to repository safely.
1263
 
 
1264
 
        Raise an error if not.
1265
 
 
1266
 
        :param repository: A repository to fallback to.
1267
 
        """
1268
 
        return _mod_repository.InterRepository._assert_same_model(
1269
 
            self, repository)
1270
 
 
1271
1252
    def add_inventory(self, revid, inv, parents):
1272
1253
        self._ensure_real()
1273
1254
        return self._real_repository.add_inventory(revid, inv, parents)
1626
1607
        return self._real_repository.inventories
1627
1608
 
1628
1609
    @needs_write_lock
1629
 
    def pack(self, hint=None, clean_obsolete_packs=False):
 
1610
    def pack(self, hint=None):
1630
1611
        """Compress the data within the repository.
1631
1612
 
1632
1613
        This is not currently implemented within the smart server.
1633
1614
        """
1634
1615
        self._ensure_real()
1635
 
        return self._real_repository.pack(hint=hint, clean_obsolete_packs=clean_obsolete_packs)
 
1616
        return self._real_repository.pack(hint=hint)
1636
1617
 
1637
1618
    @property
1638
1619
    def revisions(self):
2394
2375
            self._vfs_set_tags_bytes(bytes)
2395
2376
 
2396
2377
    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
2378
        self.repository.lock_read()
2403
2379
        if not self._lock_mode:
2404
2380
            self._note_lock('r')
2408
2384
                self._real_branch.lock_read()
2409
2385
        else:
2410
2386
            self._lock_count += 1
2411
 
        return self
2412
2387
 
2413
2388
    def _remote_lock_write(self, token):
2414
2389
        if token is None:
2415
2390
            branch_token = repo_token = ''
2416
2391
        else:
2417
2392
            branch_token = token
2418
 
            repo_token = self.repository.lock_write().repository_token
 
2393
            repo_token = self.repository.lock_write()
2419
2394
            self.repository.unlock()
2420
2395
        err_context = {'token': token}
2421
2396
        response = self._call(
2458
2433
            self._lock_count += 1
2459
2434
            # Re-lock the repository too.
2460
2435
            self.repository.lock_write(self._repo_lock_token)
2461
 
        return BranchWriteLockResult(self.unlock, self._lock_token or None)
 
2436
        return self._lock_token or None
2462
2437
 
2463
2438
    def _unlock(self, branch_token, repo_token):
2464
2439
        err_context = {'token': str((branch_token, repo_token))}