~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

Branch.dotted_revno_to_revision_idĀ API

Show diffs side-by-side

added added

removed removed

Lines of Context:
189
189
        raise NotImplementedError(self.get_physical_lock_status)
190
190
 
191
191
    @needs_read_lock
 
192
    def dotted_revno_to_revision_id(self, revno):
 
193
        """Return the revision_id for a dotted revno.
 
194
 
 
195
        :param revno: a tuple like (1,) or (1,1,2)
 
196
        :return: the revision_id
 
197
        :raises errors.NoSuchRevision: if the revno doesn't exist
 
198
        """
 
199
        return self._dotted_revno_to_revision_id(revno)
 
200
 
 
201
    def _dotted_revno_to_revision_id(self, revno):
 
202
        """Worker function for dotted_revno_to_revision_id.
 
203
 
 
204
        Subclasses should override this if they wish to
 
205
        provide a more efficient implementation.
 
206
        """
 
207
        if len(revno) == 1:
 
208
            return self.get_rev_id(revno[0])
 
209
        revision_id_to_revno = self.get_revision_id_to_revno_map()
 
210
        for revision_id, this_revno in revision_id_to_revno.iteritems():
 
211
            if revno == this_revno:
 
212
                return revision_id
 
213
        else:
 
214
            revno_str = '.'.join(map(str, revno))
 
215
            raise errors.NoSuchRevision(self, revno_str)
 
216
 
 
217
    @needs_read_lock
192
218
    def get_revision_id_to_revno_map(self):
193
219
        """Return the revision_id => dotted revno map.
194
220