~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-11-12 00:28:01 UTC
  • mfrom: (5535.2.4 read-lock-caches-tags)
  • Revision ID: pqm@pqm.ubuntu.com-20101112002801-qb8mk6pt3pqhp444
(spiv) Cache a branch's tags during a read-lock. (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
        self._revision_id_to_revno_cache = None
93
93
        self._partial_revision_id_to_revno_cache = {}
94
94
        self._partial_revision_history_cache = []
 
95
        self._tags_bytes = None
95
96
        self._last_revision_info_cache = None
96
97
        self._merge_sorted_revisions_cache = None
97
98
        self._open_hook()
227
228
            possible_transports=[self.bzrdir.root_transport])
228
229
        return a_branch.repository
229
230
 
 
231
    @needs_read_lock
230
232
    def _get_tags_bytes(self):
231
233
        """Get the bytes of a serialised tags dict.
232
234
 
239
241
        :return: The bytes of the tags file.
240
242
        :seealso: Branch._set_tags_bytes.
241
243
        """
242
 
        return self._transport.get_bytes('tags')
 
244
        if self._tags_bytes is None:
 
245
            self._tags_bytes = self._transport.get_bytes('tags')
 
246
        return self._tags_bytes
243
247
 
244
248
    def _get_nick(self, local=False, possible_transports=None):
245
249
        config = self.get_config()
876
880
 
877
881
        :seealso: Branch._get_tags_bytes.
878
882
        """
879
 
        return _run_with_write_locked_target(self, self._transport.put_bytes,
880
 
            'tags', bytes)
 
883
        return _run_with_write_locked_target(self, self._set_tags_bytes_locked,
 
884
                bytes)
 
885
 
 
886
    def _set_tags_bytes_locked(self, bytes):
 
887
        self._tags_bytes = bytes
 
888
        return self._transport.put_bytes('tags', bytes)
881
889
 
882
890
    def _cache_revision_history(self, rev_history):
883
891
        """Set the cached revision history to rev_history.
913
921
        self._merge_sorted_revisions_cache = None
914
922
        self._partial_revision_history_cache = []
915
923
        self._partial_revision_id_to_revno_cache = {}
 
924
        self._tags_bytes = None
916
925
 
917
926
    def _gen_revision_history(self):
918
927
        """Return sequence of revision hashes on to this branch.