/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

  • Committer: Lukáš Lalinský
  • Date: 2007-12-03 20:48:08 UTC
  • mto: (3298.2.1 get_rev_id)
  • mto: This revision was merged to the branch mainline in revision 3328.
  • Revision ID: lalinsky@gmail.com-20071203204808-gv1m751xdb8m9ltc
Make RevisionSpec_last not load the whole history.

Implement BzrBranch6.get_rev_id, that uses last_revision_info and repository.iter_reverse_revision_history to find out the revision_id incrementally without loading the whole history.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2081
2081
    def _make_tags(self):
2082
2082
        return BasicTags(self)
2083
2083
 
 
2084
    def get_rev_id(self, revno, history=None):
 
2085
        """Find the revision id of the specified revno."""
 
2086
        if revno == 0:
 
2087
            return _mod_revision.NULL_REVISION
 
2088
 
 
2089
        last_revno, last_revision_id = self.last_revision_info()
 
2090
        if revno == last_revno:
 
2091
            return last_revision_id
 
2092
 
 
2093
        if revno <= 0 or revno > last_revno:
 
2094
            raise errors.NoSuchRevision(self, revno)
 
2095
 
 
2096
        if history is None:
 
2097
            history = self._revision_history_cache
 
2098
        if history is not None:
 
2099
            return history[revno - 1]
 
2100
 
 
2101
        # TODO cache the partially loaded history (Lukas Lalinsky, 20081203)
 
2102
        revision_id = last_revision_id
 
2103
        history_iter = self.repository.iter_reverse_revision_history(
 
2104
            last_revision_id)
 
2105
        for i in xrange(last_revno - revno + 1):
 
2106
            try:
 
2107
                revision_id = history_iter.next()
 
2108
            except StopIteration:
 
2109
                raise errors.NoSuchRevision(self, revno)
 
2110
        return revision_id
 
2111
 
2084
2112
 
2085
2113
######################################################################
2086
2114
# results of operations