~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-07-09 00:44:25 UTC
  • mfrom: (4454.3.79 1.17-rework-annotate)
  • Revision ID: pqm@pqm.ubuntu.com-20090709004425-6tukiuklys5y02m5
(jam) Rework the internals of annotate to use a class object (fixes
        bug #387952)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1069
1069
 
1070
1070
    def annotate(self, key):
1071
1071
        """See VersionedFiles.annotate."""
1072
 
        graph = Graph(self)
1073
 
        parent_map = self.get_parent_map([key])
1074
 
        if not parent_map:
1075
 
            raise errors.RevisionNotPresent(key, self)
1076
 
        if parent_map[key] is not None:
1077
 
            parent_map = dict((k, v) for k, v in graph.iter_ancestry([key])
1078
 
                              if v is not None)
1079
 
            keys = parent_map.keys()
1080
 
        else:
1081
 
            keys = [key]
1082
 
            parent_map = {key:()}
1083
 
        # We used Graph(self) to load the parent_map, but now that we have it,
1084
 
        # we can just query the parent map directly, so create a KnownGraph
1085
 
        heads_provider = _mod_graph.KnownGraph(parent_map)
1086
 
        parent_cache = {}
1087
 
        reannotate = annotate.reannotate
1088
 
        for record in self.get_record_stream(keys, 'topological', True):
1089
 
            key = record.key
1090
 
            lines = osutils.chunks_to_lines(record.get_bytes_as('chunked'))
1091
 
            parent_lines = [parent_cache[parent] for parent in parent_map[key]]
1092
 
            parent_cache[key] = list(
1093
 
                reannotate(parent_lines, lines, key, None, heads_provider))
1094
 
        return parent_cache[key]
 
1072
        ann = annotate.Annotator(self)
 
1073
        return ann.annotate_flat(key)
 
1074
 
 
1075
    def get_annotator(self):
 
1076
        return annotate.Annotator(self)
1095
1077
 
1096
1078
    def check(self, progress_bar=None):
1097
1079
        """See VersionedFiles.check()."""