~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Jelmer Vernooij
  • Date: 2011-04-08 15:26:51 UTC
  • mto: (5757.7.6 knitpackrepo-6)
  • mto: This revision was merged to the branch mainline in revision 5790.
  • Revision ID: jelmer@samba.org-20110408152651-6jfhyznacm4lp5n8
Move implementation of _find_inconsistent_parents to Repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2765
2765
                except UnicodeDecodeError:
2766
2766
                    raise errors.NonAsciiRevisionId(method, self)
2767
2767
 
 
2768
    def _find_inconsistent_revision_parents(self, revisions_iterator=None):
 
2769
        """Find revisions with different parent lists in the revision object
 
2770
        and in the index graph.
 
2771
 
 
2772
        :param revisions_iterator: None, or an iterator of (revid,
 
2773
            Revision-or-None). This iterator controls the revisions checked.
 
2774
        :returns: an iterator yielding tuples of (revison-id, parents-in-index,
 
2775
            parents-in-revision).
 
2776
        """
 
2777
        if not self.is_locked():
 
2778
            raise AssertionError()
 
2779
        vf = self.revisions
 
2780
        if revisions_iterator is None:
 
2781
            revisions_iterator = self._iter_revisions(None)
 
2782
        for revid, revision in revisions_iterator:
 
2783
            if revision is None:
 
2784
                pass
 
2785
            parent_map = vf.get_parent_map([(revid,)])
 
2786
            parents_according_to_index = tuple(parent[-1] for parent in
 
2787
                parent_map[(revid,)])
 
2788
            parents_according_to_revision = tuple(revision.parent_ids)
 
2789
            if parents_according_to_index != parents_according_to_revision:
 
2790
                yield (revid, parents_according_to_index,
 
2791
                    parents_according_to_revision)
 
2792
 
 
2793
    def _check_for_inconsistent_revision_parents(self):
 
2794
        inconsistencies = list(self._find_inconsistent_revision_parents())
 
2795
        if inconsistencies:
 
2796
            raise errors.BzrCheckError(
 
2797
                "Revision knit has inconsistent parents.")
 
2798
 
2768
2799
 
2769
2800
def install_revision(repository, rev, revision_tree):
2770
2801
    """Install all revision data into a repository."""