/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/branch.py

merge bzr.dev r3954

Show diffs side-by-side

added added

removed removed

Lines of Context:
89
89
        self.tags = self._make_tags()
90
90
        self._revision_history_cache = None
91
91
        self._revision_id_to_revno_cache = None
 
92
        self._partial_revision_id_to_revno_cache = {}
92
93
        self._last_revision_info_cache = None
93
94
        self._open_hook()
94
95
        hooks = Branch.hooks['open']
189
190
        raise NotImplementedError(self.get_physical_lock_status)
190
191
 
191
192
    @needs_read_lock
 
193
    def dotted_revno_to_revision_id(self, revno, _cache_reverse=False):
 
194
        """Return the revision_id for a dotted revno.
 
195
 
 
196
        :param revno: a tuple like (1,) or (1,1,2)
 
197
        :param _cache_reverse: a private parameter enabling storage
 
198
           of the reverse mapping in a top level cache. (This should
 
199
           only be done in selective circumstances as we want to
 
200
           avoid having the mapping cached multiple times.)
 
201
        :return: the revision_id
 
202
        :raises errors.NoSuchRevision: if the revno doesn't exist
 
203
        """
 
204
        rev_id = self._do_dotted_revno_to_revision_id(revno)
 
205
        if _cache_reverse:
 
206
            self._partial_revision_id_to_revno_cache[rev_id] = revno
 
207
        return rev_id
 
208
 
 
209
    def _do_dotted_revno_to_revision_id(self, revno):
 
210
        """Worker function for dotted_revno_to_revision_id.
 
211
 
 
212
        Subclasses should override this if they wish to
 
213
        provide a more efficient implementation.
 
214
        """
 
215
        if len(revno) == 1:
 
216
            return self.get_rev_id(revno[0])
 
217
        revision_id_to_revno = self.get_revision_id_to_revno_map()
 
218
        revision_ids = [revision_id for revision_id, this_revno
 
219
                        in revision_id_to_revno.iteritems()
 
220
                        if revno == this_revno]
 
221
        if len(revision_ids) == 1:
 
222
            return revision_ids[0]
 
223
        else:
 
224
            revno_str = '.'.join(map(str, revno))
 
225
            raise errors.NoSuchRevision(self, revno_str)
 
226
 
 
227
    @needs_read_lock
 
228
    def revision_id_to_dotted_revno(self, revision_id):
 
229
        """Given a revision id, return its dotted revno.
 
230
        
 
231
        :return: a tuple like (1,) or (400,1,3).
 
232
        """
 
233
        return self._do_revision_id_to_dotted_revno(revision_id)
 
234
 
 
235
    def _do_revision_id_to_dotted_revno(self, revision_id):
 
236
        """Worker function for revision_id_to_revno."""
 
237
        # Try the caches if they are loaded
 
238
        result = self._partial_revision_id_to_revno_cache.get(revision_id)
 
239
        if result is not None:
 
240
            return result
 
241
        if self._revision_id_to_revno_cache:
 
242
            result = self._revision_id_to_revno_cache.get(revision_id)
 
243
            if result is None:
 
244
                raise errors.NoSuchRevision(self, revision_id)
 
245
        # Try the mainline as it's optimised
 
246
        try:
 
247
            revno = self.revision_id_to_revno(revision_id)
 
248
            return (revno,)
 
249
        except errors.NoSuchRevision:
 
250
            # We need to load and use the full revno map after all
 
251
            result = self.get_revision_id_to_revno_map().get(revision_id)
 
252
            if result is None:
 
253
                raise errors.NoSuchRevision(self, revision_id)
 
254
        return result
 
255
 
 
256
    @needs_read_lock
192
257
    def get_revision_id_to_revno_map(self):
193
258
        """Return the revision_id => dotted revno map.
194
259