~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/knitrepo.py

  • Committer: Robert Collins
  • Date: 2009-05-12 04:24:57 UTC
  • mto: This revision was merged to the branch mainline in revision 4593.
  • Revision ID: robertc@robertcollins.net-20090512042457-y91nn2suuc7syinj
Refactor Repository._find_inconsistent_revision_parents and Repository.get_revisions to a new Repository._iter_revisions which is kinder on memory without needing code duplication.

Show diffs side-by-side

added added

removed removed

Lines of Context:
229
229
    def _make_parents_provider(self):
230
230
        return _KnitsParentsProvider(self.revisions)
231
231
 
232
 
    def _find_inconsistent_revision_parents(self):
 
232
    def _find_inconsistent_revision_parents(self, revisions_iterator=None):
233
233
        """Find revisions with different parent lists in the revision object
234
234
        and in the index graph.
235
235
 
 
236
        :param revisions_iterator: None, or an iterator of (revid,
 
237
            Revision-or-None). This iterator controls the revisions checked.
236
238
        :returns: an iterator yielding tuples of (revison-id, parents-in-index,
237
239
            parents-in-revision).
238
240
        """
239
241
        if not self.is_locked():
240
242
            raise AssertionError()
241
243
        vf = self.revisions
242
 
        for index_version in vf.keys():
243
 
            parent_map = vf.get_parent_map([index_version])
 
244
        if revisions_iterator is None:
 
245
            revisions_iterator = self._iter_revisions(None)
 
246
        for revid, revision in revisions_iterator:
 
247
            if revision is None:
 
248
                pass
 
249
            parent_map = vf.get_parent_map([(revid,)])
244
250
            parents_according_to_index = tuple(parent[-1] for parent in
245
 
                parent_map[index_version])
246
 
            revision = self.get_revision(index_version[-1])
 
251
                parent_map[(revid,)])
247
252
            parents_according_to_revision = tuple(revision.parent_ids)
248
253
            if parents_according_to_index != parents_according_to_revision:
249
 
                yield (index_version[-1], parents_according_to_index,
 
254
                yield (revid, parents_according_to_index,
250
255
                    parents_according_to_revision)
251
256
 
252
257
    def _check_for_inconsistent_revision_parents(self):