/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-27 07:52:08 UTC
  • mto: This revision was merged to the branch mainline in revision 5192.
  • Revision ID: mbp@sourcefrog.net-20100427075208-nc9uf6jgwlyy5r3k
Add osutils.rename that includes the relevant filenames

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
 
273
272
    def create_workingtree(self, revision_id=None, from_branch=None):
274
273
        raise errors.NotLocalUrl(self.transport.base)
275
274
 
276
 
    def find_branch_format(self, name=None):
 
275
    def find_branch_format(self):
277
276
        """Find the branch 'format' for this bzrdir.
278
277
 
279
278
        This might be a synthetic object for e.g. RemoteBranch and SVN.
280
279
        """
281
 
        b = self.open_branch(name=name)
 
280
        b = self.open_branch()
282
281
        return b._format
283
282
 
284
 
    def get_branch_reference(self, name=None):
 
283
    def get_branch_reference(self):
285
284
        """See BzrDir.get_branch_reference()."""
286
 
        if name is not None:
287
 
            # XXX JRV20100304: Support opening colocated branches
288
 
            raise errors.NoColocatedBranchSupport(self)
289
285
        response = self._get_branch_reference()
290
286
        if response[0] == 'ref':
291
287
            return response[1]
322
318
            raise errors.UnexpectedSmartServerResponse(response)
323
319
        return response
324
320
 
325
 
    def _get_tree_branch(self, name=None):
 
321
    def _get_tree_branch(self):
326
322
        """See BzrDir._get_tree_branch()."""
327
 
        return None, self.open_branch(name=name)
 
323
        return None, self.open_branch()
328
324
 
329
325
    def open_branch(self, name=None, unsupported=False,
330
326
                    ignore_fallbacks=False):
647
643
        return self._custom_format._serializer
648
644
 
649
645
 
650
 
class RemoteRepository(_RpcHelper, lock._RelockDebugMixin,
651
 
    bzrdir.ControlComponent):
 
646
class RemoteRepository(_RpcHelper, lock._RelockDebugMixin):
652
647
    """Repository accessed over rpc.
653
648
 
654
649
    For the moment most operations are performed using local transport-backed
697
692
        # Additional places to query for data.
698
693
        self._fallback_repositories = []
699
694
 
700
 
    @property
701
 
    def user_transport(self):
702
 
        return self.bzrdir.user_transport
703
 
 
704
 
    @property
705
 
    def control_transport(self):
706
 
        # XXX: Normally you shouldn't directly get at the remote repository
707
 
        # transport, but I'm not sure it's worth making this method
708
 
        # optional -- mbp 2010-04-21
709
 
        return self.bzrdir.get_repository_transport(None)
710
 
        
711
695
    def __str__(self):
712
696
        return "%s(%s)" % (self.__class__.__name__, self.base)
713
697
 
1001
985
        pass
1002
986
 
1003
987
    def lock_read(self):
1004
 
        """Lock the repository for read operations.
1005
 
 
1006
 
        :return: A bzrlib.lock.LogicalLockResult.
1007
 
        """
1008
988
        # wrong eventually - want a local lock cache context
1009
989
        if not self._lock_mode:
1010
990
            self._note_lock('r')
1017
997
                repo.lock_read()
1018
998
        else:
1019
999
            self._lock_count += 1
1020
 
        return lock.LogicalLockResult(self.unlock)
1021
1000
 
1022
1001
    def _remote_lock_write(self, token):
1023
1002
        path = self.bzrdir._path_for_remote_call(self._client)
1063
1042
            raise errors.ReadOnlyError(self)
1064
1043
        else:
1065
1044
            self._lock_count += 1
1066
 
        return RepositoryWriteLockResult(self.unlock, self._lock_token or None)
 
1045
        return self._lock_token or None
1067
1046
 
1068
1047
    def leave_lock_in_place(self):
1069
1048
        if not self._lock_token:
1255
1234
        # _real_branch had its get_stacked_on_url method called), then the
1256
1235
        # repository to be added may already be in the _real_repositories list.
1257
1236
        if self._real_repository is not None:
1258
 
            fallback_locations = [repo.user_url for repo in
 
1237
            fallback_locations = [repo.bzrdir.root_transport.base for repo in
1259
1238
                self._real_repository._fallback_repositories]
1260
 
            if repository.user_url not in fallback_locations:
 
1239
            if repository.bzrdir.root_transport.base not in fallback_locations:
1261
1240
                self._real_repository.add_fallback_repository(repository)
1262
1241
 
1263
1242
    def _check_fallback_repository(self, repository):
1315
1294
        return self._real_repository.make_working_trees()
1316
1295
 
1317
1296
    def refresh_data(self):
1318
 
        """Re-read any data needed to synchronise with disk.
 
1297
        """Re-read any data needed to to synchronise with disk.
1319
1298
 
1320
1299
        This method is intended to be called after another repository instance
1321
1300
        (such as one used by a smart server) has inserted data into the
1322
 
        repository. On all repositories this will work outside of write groups.
1323
 
        Some repository formats (pack and newer for bzrlib native formats)
1324
 
        support refresh_data inside write groups. If called inside a write
1325
 
        group on a repository that does not support refreshing in a write group
1326
 
        IsInWriteGroupError will be raised.
 
1301
        repository. It may not be called during a write group, but may be
 
1302
        called at any other time.
1327
1303
        """
 
1304
        if self.is_in_write_group():
 
1305
            raise errors.InternalBzrError(
 
1306
                "May not refresh_data while in a write group.")
1328
1307
        if self._real_repository is not None:
1329
1308
            self._real_repository.refresh_data()
1330
1309
 
2202
2181
            self._real_branch = None
2203
2182
        # Fill out expected attributes of branch for bzrlib API users.
2204
2183
        self._clear_cached_state()
2205
 
        # TODO: deprecate self.base in favor of user_url
2206
 
        self.base = self.bzrdir.user_url
 
2184
        self.base = self.bzrdir.root_transport.base
2207
2185
        self._name = name
2208
2186
        self._control_files = None
2209
2187
        self._lock_mode = None
2396
2374
            self._vfs_set_tags_bytes(bytes)
2397
2375
 
2398
2376
    def lock_read(self):
2399
 
        """Lock the branch for read operations.
2400
 
 
2401
 
        :return: A bzrlib.lock.LogicalLockResult.
2402
 
        """
2403
2377
        self.repository.lock_read()
2404
2378
        if not self._lock_mode:
2405
2379
            self._note_lock('r')
2409
2383
                self._real_branch.lock_read()
2410
2384
        else:
2411
2385
            self._lock_count += 1
2412
 
        return lock.LogicalLockResult(self.unlock)
2413
2386
 
2414
2387
    def _remote_lock_write(self, token):
2415
2388
        if token is None:
2416
2389
            branch_token = repo_token = ''
2417
2390
        else:
2418
2391
            branch_token = token
2419
 
            repo_token = self.repository.lock_write().repository_token
 
2392
            repo_token = self.repository.lock_write()
2420
2393
            self.repository.unlock()
2421
2394
        err_context = {'token': token}
2422
2395
        response = self._call(
2459
2432
            self._lock_count += 1
2460
2433
            # Re-lock the repository too.
2461
2434
            self.repository.lock_write(self._repo_lock_token)
2462
 
        return BranchWriteLockResult(self.unlock, self._lock_token or None)
 
2435
        return self._lock_token or None
2463
2436
 
2464
2437
    def _unlock(self, branch_token, repo_token):
2465
2438
        err_context = {'token': str((branch_token, repo_token))}