~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Andrew Bennetts
  • Date: 2011-03-18 01:12:17 UTC
  • mto: (5609.24.3 2.3)
  • mto: This revision was merged to the branch mainline in revision 5732.
  • Revision ID: andrew.bennetts@canonical.com-20110318011217-h1206xizh4kj1ldw
Alternative fix: cache the result of get_master_branch for the lifetime of the branch lock.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
        revision as _mod_revision,
36
36
        rio,
37
37
        symbol_versioning,
38
 
        tag,
39
38
        transport,
40
39
        tsort,
41
40
        ui,
95
94
        self._partial_revision_history_cache = []
96
95
        self._tags_bytes = None
97
96
        self._last_revision_info_cache = None
 
97
        self._master_branch_cache = None
98
98
        self._merge_sorted_revisions_cache = None
99
99
        self._open_hook()
100
 
        self._suppress_merge_tags_to_master = False
101
100
        hooks = Branch.hooks['open']
102
101
        for hook in hooks:
103
102
            hook(self)
928
927
        self._revision_history_cache = None
929
928
        self._revision_id_to_revno_cache = None
930
929
        self._last_revision_info_cache = None
 
930
        self._master_branch_cache = None
931
931
        self._merge_sorted_revisions_cache = None
932
932
        self._partial_revision_history_cache = []
933
933
        self._partial_revision_id_to_revno_cache = {}
2673
2673
            target.update_revisions(self, stop_revision,
2674
2674
                overwrite=overwrite, graph=graph)
2675
2675
        if self._push_should_merge_tags():
2676
 
            result.tag_conflicts = tag._merge_tags_if_possible(
2677
 
                self, target, overwrite=overwrite,
2678
 
                ignore_master=self._suppress_merge_tags_to_master)
 
2676
            result.tag_conflicts = self.tags.merge_to(target.tags, overwrite)
2679
2677
        result.new_revno, result.new_revid = target.last_revision_info()
2680
2678
        return result
2681
2679
 
2726
2724
        """Return the branch we are bound to.
2727
2725
 
2728
2726
        :return: Either a Branch, or None
2729
 
 
2730
 
        This could memoise the branch, but if thats done
2731
 
        it must be revalidated on each new lock.
2732
 
        So for now we just don't memoise it.
2733
 
        # RBC 20060304 review this decision.
2734
2727
        """
 
2728
        if self._master_branch_cache is None:
 
2729
            self._master_branch_cache = self._get_master_branch(
 
2730
                possible_transports)
 
2731
        return self._master_branch_cache
 
2732
 
 
2733
    def _get_master_branch(self, possible_transports):
2735
2734
        bound_loc = self.get_bound_location()
2736
2735
        if not bound_loc:
2737
2736
            return None
2748
2747
 
2749
2748
        :param location: URL to the target branch
2750
2749
        """
 
2750
        self._master_branch_cache = None
2751
2751
        if location:
2752
2752
            self._transport.put_bytes('bound', location+'\n',
2753
2753
                mode=self.bzrdir._get_file_mode())
3529
3529
                # and push into the target branch from the source. Note that we
3530
3530
                # push from the source branch again, because it's considered the
3531
3531
                # highest bandwidth repository.
3532
 
                self.source._suppress_merge_tags_to_master = True
3533
 
                try:
3534
 
                    result = self.source._basic_push(self.target, overwrite,
3535
 
                        stop_revision)
3536
 
                finally:
3537
 
                    self.source._suppress_merge_tags_to_master = False
 
3532
                result = self.source._basic_push(self.target, overwrite,
 
3533
                    stop_revision)
3538
3534
                result.master_branch = master_branch
3539
3535
                result.local_branch = self.target
3540
3536
                _run_hooks()