~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: Patch Queue Manager
  • Date: 2012-09-05 20:52:26 UTC
  • mfrom: (6549.3.1 dev_2.5_integration)
  • Revision ID: pqm@pqm.ubuntu.com-20120905205226-8s3bzolvduug3ifj
(gz) Merge 2.5 (Martin Packman)

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
384
384
            self._real_store = _mod_config.ControlStore(self.bzrdir)
385
385
 
386
386
    def external_url(self):
387
 
        return self.bzrdir.user_url
 
387
        return urlutils.join(self.branch.user_url, 'control.conf')
388
388
 
389
389
    def _load_content(self):
390
390
        medium = self.bzrdir._client._medium
1051
1051
            network_name = self._network_name
1052
1052
        else:
1053
1053
            # Select the current bzrlib default and ask for that.
1054
 
            reference_bzrdir_format = _mod_bzrdir.format_registry.get('default')()
 
1054
            reference_bzrdir_format = controldir.format_registry.get('default')()
1055
1055
            reference_format = reference_bzrdir_format.repository_format
1056
1056
            network_name = reference_format.network_name()
1057
1057
        # 2) try direct creation via RPC
2160
2160
        self._ensure_real()
2161
2161
        self._real_repository.create_bundle(target, base, fileobj, format)
2162
2162
 
2163
 
    @needs_read_lock
2164
 
    @symbol_versioning.deprecated_method(
2165
 
        symbol_versioning.deprecated_in((2, 4, 0)))
2166
 
    def get_ancestry(self, revision_id, topo_sorted=True):
2167
 
        self._ensure_real()
2168
 
        return self._real_repository.get_ancestry(revision_id, topo_sorted)
2169
 
 
2170
2163
    def fileids_altered_by_revision_ids(self, revision_ids):
2171
2164
        self._ensure_real()
2172
2165
        return self._real_repository.fileids_altered_by_revision_ids(revision_ids)
2709
2702
    def supports_rich_root(self):
2710
2703
        return self._format.rich_root_data
2711
2704
 
2712
 
    @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 4, 0)))
2713
 
    def iter_reverse_revision_history(self, revision_id):
2714
 
        self._ensure_real()
2715
 
        return self._real_repository.iter_reverse_revision_history(revision_id)
2716
 
 
2717
2705
    @property
2718
2706
    def _serializer(self):
2719
2707
        return self._format._serializer
3157
3145
            network_name = self._custom_format.network_name()
3158
3146
        else:
3159
3147
            # Select the current bzrlib default and ask for that.
3160
 
            reference_bzrdir_format = _mod_bzrdir.format_registry.get('default')()
 
3148
            reference_bzrdir_format = controldir.format_registry.get('default')()
3161
3149
            reference_format = reference_bzrdir_format.get_branch_format()
3162
3150
            self._custom_format = reference_format
3163
3151
            network_name = reference_format.network_name()
3262
3250
        self.id = "branch"
3263
3251
        self._real_store = None
3264
3252
 
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
3253
    def external_url(self):
3280
 
        return self.branch.user_url
 
3254
        return urlutils.join(self.branch.user_url, 'branch.conf')
3281
3255
 
3282
3256
    def _load_content(self):
3283
3257
        path = self.branch._remote_path()
3366
3340
        self._repo_lock_token = None
3367
3341
        self._lock_count = 0
3368
3342
        self._leave_lock = False
 
3343
        self.conf_store = None
3369
3344
        # Setup a format: note that we cannot call _ensure_real until all the
3370
3345
        # attributes above are set: This code cannot be moved higher up in this
3371
3346
        # function.
3414
3389
        return RemoteBranchConfig(self)
3415
3390
 
3416
3391
    def _get_config_store(self):
3417
 
        return RemoteBranchStore(self)
 
3392
        if self.conf_store is None:
 
3393
            self.conf_store =  RemoteBranchStore(self)
 
3394
        return self.conf_store
 
3395
 
 
3396
    def store_uncommitted(self, creator):
 
3397
        self._ensure_real()
 
3398
        return self._real_branch.store_uncommitted(creator)
 
3399
 
 
3400
    def get_unshelver(self, tree):
 
3401
        self._ensure_real()
 
3402
        return self._real_branch.get_unshelver(tree)
3418
3403
 
3419
3404
    def _get_real_transport(self):
3420
3405
        # if we try vfs access, return the real branch's vfs transport
3440
3425
            self.bzrdir._ensure_real()
3441
3426
            self._real_branch = self.bzrdir._real_bzrdir.open_branch(
3442
3427
                ignore_fallbacks=self._real_ignore_fallbacks, name=self._name)
 
3428
            # The remote branch and the real branch shares the same store. If
 
3429
            # we don't, there will always be cases where one of the stores
 
3430
            # doesn't see an update made on the other.
 
3431
            self._real_branch.conf_store = self.conf_store
3443
3432
            if self.repository._real_repository is None:
3444
3433
                # Give the remote repository the matching real repo.
3445
3434
                real_repo = self._real_branch.repository
3523
3512
 
3524
3513
    def set_stacked_on_url(self, url):
3525
3514
        branch.Branch.set_stacked_on_url(self, url)
 
3515
        # We need the stacked_on_url to be visible both locally (to not query
 
3516
        # it repeatedly) and remotely (so smart verbs can get it server side)
 
3517
        # Without the following line,
 
3518
        # bzrlib.tests.per_branch.test_create_clone.TestCreateClone
 
3519
        # .test_create_clone_on_transport_stacked_hooks_get_stacked_branch
 
3520
        # fails for remote branches -- vila 2012-01-04
 
3521
        self.conf_store.save_changes()
3526
3522
        if not url:
3527
3523
            self._is_stacked = False
3528
3524
        else:
3656
3652
        try:
3657
3653
            self._lock_count -= 1
3658
3654
            if not self._lock_count:
 
3655
                if self.conf_store is not None:
 
3656
                    self.conf_store.save_changes()
3659
3657
                self._clear_cached_state()
3660
3658
                mode = self._lock_mode
3661
3659
                self._lock_mode = None
3790
3788
            raise errors.UnexpectedSmartServerResponse(response)
3791
3789
        self._run_post_change_branch_tip_hooks(old_revno, old_revid)
3792
3790
 
3793
 
    @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 4, 0)))
3794
 
    @needs_write_lock
3795
 
    def set_revision_history(self, rev_history):
3796
 
        """See Branch.set_revision_history."""
3797
 
        self._set_revision_history(rev_history)
3798
 
 
3799
 
    @needs_write_lock
3800
 
    def _set_revision_history(self, rev_history):
3801
 
        # Send just the tip revision of the history; the server will generate
3802
 
        # the full history from that.  If the revision doesn't exist in this
3803
 
        # branch, NoSuchRevision will be raised.
3804
 
        if rev_history == []:
3805
 
            rev_id = 'null:'
3806
 
        else:
3807
 
            rev_id = rev_history[-1]
3808
 
        self._set_last_revision(rev_id)
3809
 
        for hook in branch.Branch.hooks['set_rh']:
3810
 
            hook(self, rev_history)
3811
 
        self._cache_revision_history(rev_history)
3812
 
 
3813
3791
    def _get_parent_location(self):
3814
3792
        medium = self._client._medium
3815
3793
        if medium._is_remote_before((1, 13)):
3947
3925
            except errors.UnknownSmartMethod:
3948
3926
                medium._remember_remote_is_before((1, 6))
3949
3927
        self._clear_cached_state_of_remote_branch_only()
3950
 
        self._set_revision_history(self._lefthand_history(revision_id,
3951
 
            last_rev=last_rev,other_branch=other_branch))
 
3928
        graph = self.repository.get_graph()
 
3929
        (last_revno, last_revid) = self.last_revision_info()
 
3930
        known_revision_ids = [
 
3931
            (last_revid, last_revno),
 
3932
            (_mod_revision.NULL_REVISION, 0),
 
3933
            ]
 
3934
        if last_rev is not None:
 
3935
            if not graph.is_ancestor(last_rev, revision_id):
 
3936
                # our previous tip is not merged into stop_revision
 
3937
                raise errors.DivergedBranches(self, other_branch)
 
3938
        revno = graph.find_distance_to_null(revision_id, known_revision_ids)
 
3939
        self.set_last_revision_info(revno, revision_id)
3952
3940
 
3953
3941
    def set_push_location(self, location):
3954
 
        self._ensure_real()
3955
 
        return self._real_branch.set_push_location(location)
 
3942
        self._set_config_location('push_location', location)
3956
3943
 
3957
3944
    def heads_to_fetch(self):
3958
3945
        if self._format._use_default_local_heads_to_fetch():