~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/groupcompress.py

  • Committer: John Arbash Meinel
  • Date: 2009-06-10 18:58:02 UTC
  • mto: (4371.4.5 vila-better-heads)
  • mto: This revision was merged to the branch mainline in revision 4449.
  • Revision ID: john@arbash-meinel.com-20090610185802-wsybzjfil447yhy2
Change VF.annotate to use the new KnownGraph code.

This shows a significant savings in the time for 'annotate NEWS', of about 5s/20s
for knit formats, and 45s => 20s for GC formats.


Also, factor the code into a helper, so that we can prepare for writing
a pyrex version.

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
1031
        # So we used Graph(self) to load the parent_map, but now that we have
1038
1032
        # it, we can just query the parent map directly, so create a new Graph
1039
1033
        # object
1040
 
        graph = _mod_graph.Graph(_mod_graph.DictParentsProvider(parent_map))
1041
 
        head_cache = _mod_graph.FrozenHeadsCache(graph)
 
1034
        graph = _mod_graph.KnownGraph(parent_map)
1042
1035
        parent_cache = {}
1043
1036
        reannotate = annotate.reannotate
1044
1037
        for record in self.get_record_stream(keys, 'topological', True):
1046
1039
            lines = osutils.chunks_to_lines(record.get_bytes_as('chunked'))
1047
1040
            parent_lines = [parent_cache[parent] for parent in parent_map[key]]
1048
1041
            parent_cache[key] = list(
1049
 
                reannotate(parent_lines, lines, key, None, head_cache))
 
1042
                reannotate(parent_lines, lines, key, None, graph))
1050
1043
        return parent_cache[key]
1051
1044
 
1052
1045
    def check(self, progress_bar=None):