~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/groupcompress.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-06-16 19:32:32 UTC
  • mfrom: (4371.3.48 1.16-better_heads)
  • Revision ID: pqm@pqm.ubuntu.com-20090616193232-rorncr6v3z633n9u
(jam) graph.KnownGraph implementation,
        used for optimized heads() lookups during annotate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1022
1022
        if not parent_map:
1023
1023
            raise errors.RevisionNotPresent(key, self)
1024
1024
        if parent_map[key] is not None:
1025
 
            search = graph._make_breadth_first_searcher([key])
1026
 
            keys = set()
1027
 
            while True:
1028
 
                try:
1029
 
                    present, ghosts = search.next_with_ghosts()
1030
 
                except StopIteration:
1031
 
                    break
1032
 
                keys.update(present)
1033
 
            parent_map = self.get_parent_map(keys)
 
1025
            parent_map = dict((k, v) for k, v in graph.iter_ancestry([key])
 
1026
                              if v is not None)
 
1027
            keys = parent_map.keys()
1034
1028
        else:
1035
1029
            keys = [key]
1036
1030
            parent_map = {key:()}
1037
 
        # So we used Graph(self) to load the parent_map, but now that we have
1038
 
        # it, we can just query the parent map directly, so create a new Graph
1039
 
        # object
1040
 
        graph = _mod_graph.Graph(_mod_graph.DictParentsProvider(parent_map))
1041
 
        head_cache = _mod_graph.FrozenHeadsCache(graph)
 
1031
        # We used Graph(self) to load the parent_map, but now that we have it,
 
1032
        # we can just query the parent map directly, so create a KnownGraph
 
1033
        heads_provider = _mod_graph.KnownGraph(parent_map)
1042
1034
        parent_cache = {}
1043
1035
        reannotate = annotate.reannotate
1044
1036
        for record in self.get_record_stream(keys, 'topological', True):
1046
1038
            lines = osutils.chunks_to_lines(record.get_bytes_as('chunked'))
1047
1039
            parent_lines = [parent_cache[parent] for parent in parent_map[key]]
1048
1040
            parent_cache[key] = list(
1049
 
                reannotate(parent_lines, lines, key, None, head_cache))
 
1041
                reannotate(parent_lines, lines, key, None, heads_provider))
1050
1042
        return parent_cache[key]
1051
1043
 
1052
1044
    def check(self, progress_bar=None):