~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to groupcompress.py

Annotate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""Core compression logic for compressing streams of related files."""
19
19
 
20
 
from bzrlib import diff, pack, patiencediff
 
20
from bzrlib import (
 
21
    annotate,
 
22
    diff,
 
23
    graph as _mod_graph,
 
24
    pack,
 
25
    patiencediff,
 
26
    )
 
27
from bzrlib.graph import Graph
21
28
from bzrlib.knit import _DirectPackAccess
22
29
from bzrlib.osutils import (
23
30
    contains_whitespace,
291
298
        sha1 = self._insert_record_stream([record]).next()
292
299
        return sha1, len(bytes), None
293
300
 
 
301
    def annotate(self, key):
 
302
        """See VersionedFiles.annotate."""
 
303
        graph = Graph(self)
 
304
        head_cache = _mod_graph.FrozenHeadsCache(graph)
 
305
        search = graph._make_breadth_first_searcher([key])
 
306
        keys = set()
 
307
        while True:
 
308
            try:
 
309
                present, ghosts = search.next_with_ghosts()
 
310
            except StopIteration:
 
311
                break
 
312
            keys.update(present)
 
313
        parent_map = self.get_parent_map(keys)
 
314
        parent_cache = {}
 
315
        reannotate = annotate.reannotate
 
316
        for record in self.get_record_stream(keys, 'topological', True):
 
317
            key = record.key
 
318
            fulltext = split_lines(record.get_bytes_as('fulltext'))
 
319
            parent_lines = [parent_cache[parent] for parent in parent_map[key]]
 
320
            parent_cache[key] = list(
 
321
                reannotate(parent_lines, fulltext, key, None, head_cache))
 
322
        return parent_cache[key]
 
323
 
294
324
    def _check_add(self, key, lines, random_id, check_content):
295
325
        """check that version_id and lines are safe to add."""
296
326
        version_id = key[-1]