~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2011 Canonical Ltd
 
1
# Copyright (C) 2006-2012 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
3262
3262
        self.id = "branch"
3263
3263
        self._real_store = None
3264
3264
 
3265
 
    def lock_write(self, token=None):
3266
 
        return self.branch.lock_write(token)
3267
 
 
3268
 
    def unlock(self):
3269
 
        return self.branch.unlock()
3270
 
 
3271
 
    @needs_write_lock
3272
 
    def save(self):
3273
 
        # We need to be able to override the undecorated implementation
3274
 
        self.save_without_locking()
3275
 
 
3276
 
    def save_without_locking(self):
3277
 
        super(RemoteBranchStore, self).save()
3278
 
 
3279
3265
    def external_url(self):
3280
3266
        return self.branch.user_url
3281
3267
 
3366
3352
        self._repo_lock_token = None
3367
3353
        self._lock_count = 0
3368
3354
        self._leave_lock = False
 
3355
        self.conf_store = None
3369
3356
        # Setup a format: note that we cannot call _ensure_real until all the
3370
3357
        # attributes above are set: This code cannot be moved higher up in this
3371
3358
        # function.
3414
3401
        return RemoteBranchConfig(self)
3415
3402
 
3416
3403
    def _get_config_store(self):
3417
 
        return RemoteBranchStore(self)
 
3404
        if self.conf_store is None:
 
3405
            self.conf_store =  RemoteBranchStore(self)
 
3406
        return self.conf_store
3418
3407
 
3419
3408
    def _get_real_transport(self):
3420
3409
        # if we try vfs access, return the real branch's vfs transport
3440
3429
            self.bzrdir._ensure_real()
3441
3430
            self._real_branch = self.bzrdir._real_bzrdir.open_branch(
3442
3431
                ignore_fallbacks=self._real_ignore_fallbacks, name=self._name)
 
3432
            # The remote branch and the real branch shares the same store. If
 
3433
            # we don't, there will always be cases where one of the stores
 
3434
            # doesn't see an update made on the other.
 
3435
            self._real_branch.conf_store = self.conf_store
3443
3436
            if self.repository._real_repository is None:
3444
3437
                # Give the remote repository the matching real repo.
3445
3438
                real_repo = self._real_branch.repository
3523
3516
 
3524
3517
    def set_stacked_on_url(self, url):
3525
3518
        branch.Branch.set_stacked_on_url(self, url)
 
3519
        # We need the stacked_on_url to be visible both locally (to not query
 
3520
        # it repeatedly) and remotely (so smart verbs can get it server side)
 
3521
        # Without the following line,
 
3522
        # bzrlib.tests.per_branch.test_create_clone.TestCreateClone
 
3523
        # .test_create_clone_on_transport_stacked_hooks_get_stacked_branch
 
3524
        # fails for remote branches -- vila 2012-01-04
 
3525
        self.conf_store.save_changes()
3526
3526
        if not url:
3527
3527
            self._is_stacked = False
3528
3528
        else:
3656
3656
        try:
3657
3657
            self._lock_count -= 1
3658
3658
            if not self._lock_count:
 
3659
                if self.conf_store is not None:
 
3660
                    self.conf_store.save_changes()
3659
3661
                self._clear_cached_state()
3660
3662
                mode = self._lock_mode
3661
3663
                self._lock_mode = None
3951
3953
            last_rev=last_rev,other_branch=other_branch))
3952
3954
 
3953
3955
    def set_push_location(self, location):
3954
 
        self._ensure_real()
3955
 
        return self._real_branch.set_push_location(location)
 
3956
        self._set_config_location('push_location', location)
3956
3957
 
3957
3958
    def heads_to_fetch(self):
3958
3959
        if self._format._use_default_local_heads_to_fetch():