~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

Teach Knit repositories how to handle ghosts without corrupting at all.

Show diffs side-by-side

added added

removed removed

Lines of Context:
522
522
        if not self.has_revision(revision_id):
523
523
            raise errors.NoSuchRevision(self, revision_id)
524
524
        w = self.get_inventory_weave()
525
 
        return [None] + w.get_ancestry(revision_id)
 
525
        candidates = w.get_ancestry(revision_id)
 
526
        return [None] + candidates # self._eliminate_revisions_not_present(candidates)
526
527
 
527
528
    @needs_read_lock
528
529
    def print_file(self, file, revision_id):
699
700
        if revision_id is None:
700
701
            return [None]
701
702
        vf = self._revision_store.get_revision_file(self.get_transaction())
702
 
        return [None] + vf.get_ancestry(revision_id)
 
703
        try:
 
704
            return [None] + vf.get_ancestry(revision_id)
 
705
        except errors.RevisionNotPresent:
 
706
            raise errors.NoSuchRevision(self, revision_id)
 
707
 
 
708
    @needs_read_lock
 
709
    def get_revision_graph_with_ghosts(self, revision_ids=None):
 
710
        """Return a graph of the revisions with ghosts marked as applicable.
 
711
 
 
712
        :param revision_ids: an iterable of revisions to graph or None for all.
 
713
        :return: a Graph object with the graph reachable from revision_ids.
 
714
        """
 
715
        result = Graph()
 
716
        vf = self._revision_store.get_revision_file(self.get_transaction())
 
717
        versions = vf.versions()
 
718
        if not revision_ids:
 
719
            pending = set(self.all_revision_ids())
 
720
            required = set([])
 
721
        else:
 
722
            pending = set(revision_ids)
 
723
            required = set(revision_ids)
 
724
        done = set([])
 
725
        while len(pending):
 
726
            revision_id = pending.pop()
 
727
            if not revision_id in versions:
 
728
                if revision_id in required:
 
729
                    raise errors.NoSuchRevision(self, revision_id)
 
730
                # a ghost
 
731
                result.add_ghost(revision_id)
 
732
                continue
 
733
            parent_ids = vf.get_parents_with_ghosts(revision_id)
 
734
            for parent_id in parent_ids:
 
735
                # is this queued or done ?
 
736
                if (parent_id not in pending and
 
737
                    parent_id not in done):
 
738
                    # no, queue it.
 
739
                    pending.add(parent_id)
 
740
            result.add_node(revision_id, parent_ids)
 
741
            done.add(result)
 
742
        return result
703
743
 
704
744
    @needs_write_lock
705
745
    def reconcile(self):