~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/knit.py

  • Committer: John Arbash Meinel
  • Date: 2008-02-19 23:18:16 UTC
  • mto: This revision was merged to the branch mainline in revision 3280.
  • Revision ID: john@arbash-meinel.com-20080219231816-1uuv72o4jjj3psc6
Introduce the heads_provider for reannotate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
lazy_import(globals(), """
75
75
from bzrlib import (
76
76
    annotate,
 
77
    graph as _mod_graph,
77
78
    lru_cache,
78
79
    pack,
79
80
    trace,
2789
2790
        self._pending_children = {}
2790
2791
 
2791
2792
        self._all_build_details = {}
 
2793
        # The children => parent revision_id graph
2792
2794
        self._revision_id_graph = {}
2793
2795
 
 
2796
        self._heads_provider = None
 
2797
 
2794
2798
    def _add_fulltext_content(self, revision_id, content_obj, noeol_flag):
2795
2799
        self._fulltext_contents[revision_id] = content_obj
2796
2800
        if noeol_flag:
2828
2832
        a = self._annotated_lines
2829
2833
        annotated_parent_lines = [a[p] for p in parent_ids]
2830
2834
        annotated_lines = list(annotate.reannotate(annotated_parent_lines,
2831
 
            fulltext, revision_id, left_matching_blocks))
 
2835
            fulltext, revision_id, left_matching_blocks,
 
2836
            heads_provider=self._get_heads_provider()))
2832
2837
        self._annotated_lines[revision_id] = annotated_lines
2833
2838
        # Now that we've added this one, see if there are any pending
2834
2839
        # deltas to be done, certainly this parent is finished
2849
2854
            passing to read_records_iter to start reading in the raw data from
2850
2855
            the pack file.
2851
2856
        """
 
2857
        if revision_id in self._annotated_lines:
 
2858
            # Nothing to do
 
2859
            return []
2852
2860
        pending = set([revision_id])
2853
2861
        records = []
2854
2862
        while pending:
2935
2943
                    self._add_annotation(rev_id, fulltext, parent_ids,
2936
2944
                                     left_matching_blocks=blocks))
2937
2945
 
 
2946
    def _get_heads_provider(self):
 
2947
        """Create a heads provider for resolving ancestry issues."""
 
2948
        if self._heads_provider is not None:
 
2949
            return self._heads_provider
 
2950
        parent_provider = _mod_graph.DictParentsProvider(
 
2951
            self._revision_id_graph)
 
2952
        graph_obj = _mod_graph.Graph(parent_provider)
 
2953
        head_cache = _mod_graph.HeadsCache(graph_obj)
 
2954
        self._heads_provider = head_cache
 
2955
        return head_cache
 
2956
 
2938
2957
    def get_annotated_lines(self, revision_id):
2939
2958
        """Return the annotated fulltext at the given revision.
2940
2959