~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/knit.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-07-07 08:34:51 UTC
  • mfrom: (3517.4.2 annotate)
  • Revision ID: pqm@pqm.ubuntu.com-20080707083451-33s2p0jaawgzkyfk
(mbp, for robertc) simple annotation on stacked knits

Show diffs side-by-side

added added

removed removed

Lines of Context:
2680
2680
 
2681
2681
        :param key: The key to annotate.
2682
2682
        """
 
2683
        if True or len(self._knit._fallback_vfs) > 0:
 
2684
            # stacked knits can't use the fast path at present.
 
2685
            return self._simple_annotate(key)
2683
2686
        records = self._get_build_graph(key)
2684
2687
        if key in self._ghosts:
2685
2688
            raise errors.RevisionNotPresent(key, self._knit)
2686
2689
        self._annotate_records(records)
2687
2690
        return self._annotated_lines[key]
2688
2691
 
 
2692
    def _simple_annotate(self, key):
 
2693
        """Return annotated fulltext, rediffing from the full texts.
 
2694
 
 
2695
        This is slow but makes no assumptions about the repository
 
2696
        being able to produce line deltas.
 
2697
        """
 
2698
        # TODO: this code generates a parent maps of present ancestors; it
 
2699
        # could be split out into a separate method, and probably should use
 
2700
        # iter_ancestry instead. -- mbp and robertc 20080704
 
2701
        graph = Graph(self._knit)
 
2702
        head_cache = _mod_graph.FrozenHeadsCache(graph)
 
2703
        search = graph._make_breadth_first_searcher([key])
 
2704
        keys = set()
 
2705
        while True:
 
2706
            try:
 
2707
                present, ghosts = search.next_with_ghosts()
 
2708
            except StopIteration:
 
2709
                break
 
2710
            keys.update(present)
 
2711
        parent_map = self._knit.get_parent_map(keys)
 
2712
        parent_cache = {}
 
2713
        reannotate = annotate.reannotate
 
2714
        for record in self._knit.get_record_stream(keys, 'topological', True):
 
2715
            key = record.key
 
2716
            fulltext = split_lines(record.get_bytes_as('fulltext'))
 
2717
            parents = parent_map[key]
 
2718
            if parents is not None:
 
2719
                parent_lines = [parent_cache[parent] for parent in parent_map[key]]
 
2720
            else:
 
2721
                parent_lines = []
 
2722
            parent_cache[key] = list(
 
2723
                reannotate(parent_lines, fulltext, key, None, head_cache))
 
2724
        try:
 
2725
            return parent_cache[key]
 
2726
        except KeyError, e:
 
2727
            raise errors.RevisionNotPresent(key, self._knit)
 
2728
 
2689
2729
 
2690
2730
try:
2691
2731
    from bzrlib._knit_load_data_c import _load_data_c as _load_data