189
190
raise NotImplementedError(self.get_physical_lock_status)
193
def dotted_revno_to_revision_id(self, revno, _cache_reverse=False):
194
"""Return the revision_id for a dotted revno.
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
204
rev_id = self._do_dotted_revno_to_revision_id(revno)
206
self._partial_revision_id_to_revno_cache[rev_id] = revno
209
def _do_dotted_revno_to_revision_id(self, revno):
210
"""Worker function for dotted_revno_to_revision_id.
212
Subclasses should override this if they wish to
213
provide a more efficient implementation.
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]
224
revno_str = '.'.join(map(str, revno))
225
raise errors.NoSuchRevision(self, revno_str)
228
def revision_id_to_dotted_revno(self, revision_id):
229
"""Given a revision id, return its dotted revno.
231
:return: a tuple like (1,) or (400,1,3).
233
return self._do_revision_id_to_dotted_revno(revision_id)
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:
241
if self._revision_id_to_revno_cache:
242
result = self._revision_id_to_revno_cache.get(revision_id)
244
raise errors.NoSuchRevision(self, revision_id)
245
# Try the mainline as it's optimised
247
revno = self.revision_id_to_revno(revision_id)
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)
253
raise errors.NoSuchRevision(self, revision_id)
192
257
def get_revision_id_to_revno_map(self):
193
258
"""Return the revision_id => dotted revno map.