~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/knit.py

  • Committer: John Arbash Meinel
  • Date: 2009-06-04 16:50:33 UTC
  • mto: This revision was merged to the branch mainline in revision 4410.
  • Revision ID: john@arbash-meinel.com-20090604165033-bfdo0lyf4yt4vjcz
We don't need a base Coder class, because Decoder._update_tail is different than Encoder._update_tail.
(one adds, one subtracts from self.size).
So we now have 2 versions of the macro, and the test suite stops crashing... :)

Show diffs side-by-side

added added

removed removed

Lines of Context:
3552
3552
        """Create a heads provider for resolving ancestry issues."""
3553
3553
        if self._heads_provider is not None:
3554
3554
            return self._heads_provider
3555
 
        self._heads_provider = _mod_graph.KnownGraph(self._revision_id_graph)
3556
 
        return self._heads_provider
 
3555
        parent_provider = _mod_graph.DictParentsProvider(
 
3556
            self._revision_id_graph)
 
3557
        graph_obj = _mod_graph.Graph(parent_provider)
 
3558
        head_cache = _mod_graph.FrozenHeadsCache(graph_obj)
 
3559
        self._heads_provider = head_cache
 
3560
        return head_cache
3557
3561
 
3558
3562
    def annotate(self, key):
3559
3563
        """Return the annotated fulltext at the given key.
3582
3586
        being able to produce line deltas.
3583
3587
        """
3584
3588
        # TODO: this code generates a parent maps of present ancestors; it
3585
 
        #       could be split out into a separate method
3586
 
        #       -- mbp and robertc 20080704
 
3589
        # could be split out into a separate method, and probably should use
 
3590
        # iter_ancestry instead. -- mbp and robertc 20080704
3587
3591
        graph = _mod_graph.Graph(self._knit)
3588
 
        parent_map = dict((k, v) for k, v in graph.iter_ancestry([key])
3589
 
                          if v is not None)
3590
 
        if not parent_map:
3591
 
            raise errors.RevisionNotPresent(key, self)
3592
 
        keys = parent_map.keys()
3593
 
        heads_provider = _mod_graph.KnownGraph(parent_map)
 
3592
        head_cache = _mod_graph.FrozenHeadsCache(graph)
 
3593
        search = graph._make_breadth_first_searcher([key])
 
3594
        keys = set()
 
3595
        while True:
 
3596
            try:
 
3597
                present, ghosts = search.next_with_ghosts()
 
3598
            except StopIteration:
 
3599
                break
 
3600
            keys.update(present)
 
3601
        parent_map = self._knit.get_parent_map(keys)
3594
3602
        parent_cache = {}
3595
3603
        reannotate = annotate.reannotate
3596
3604
        for record in self._knit.get_record_stream(keys, 'topological', True):
3602
3610
            else:
3603
3611
                parent_lines = []
3604
3612
            parent_cache[key] = list(
3605
 
                reannotate(parent_lines, fulltext, key, None, heads_provider))
 
3613
                reannotate(parent_lines, fulltext, key, None, head_cache))
3606
3614
        try:
3607
3615
            return parent_cache[key]
3608
3616
        except KeyError, e: