Rev 4: Annotate. in http://people.ubuntu.com/~robertc/baz2.0/plugins/groupcompress/trunk
Robert Collins
robertc at robertcollins.net
Mon Jul 7 09:56:32 BST 2008
At http://people.ubuntu.com/~robertc/baz2.0/plugins/groupcompress/trunk
------------------------------------------------------------
revno: 4
revision-id: robertc at robertcollins.net-20080707085630-wjx40bv0izfau7gk
parent: robertc at robertcollins.net-20080707022703-rfk7o3i2xysdl9o6
committer: Robert Collins <robertc at robertcollins.net>
branch nick: trunk
timestamp: Mon 2008-07-07 18:56:30 +1000
message:
Annotate.
modified:
groupcompress.py groupcompress.py-20080705181503-ccbxd6xuy1bdnrpu-8
=== modified file 'groupcompress.py'
--- a/groupcompress.py 2008-07-07 02:27:03 +0000
+++ b/groupcompress.py 2008-07-07 08:56:30 +0000
@@ -17,7 +17,14 @@
"""Core compression logic for compressing streams of related files."""
-from bzrlib import diff, pack, patiencediff
+from bzrlib import (
+ annotate,
+ diff,
+ graph as _mod_graph,
+ pack,
+ patiencediff,
+ )
+from bzrlib.graph import Graph
from bzrlib.knit import _DirectPackAccess
from bzrlib.osutils import (
contains_whitespace,
@@ -291,6 +298,29 @@
sha1 = self._insert_record_stream([record]).next()
return sha1, len(bytes), None
+ def annotate(self, key):
+ """See VersionedFiles.annotate."""
+ graph = Graph(self)
+ head_cache = _mod_graph.FrozenHeadsCache(graph)
+ search = graph._make_breadth_first_searcher([key])
+ keys = set()
+ while True:
+ try:
+ present, ghosts = search.next_with_ghosts()
+ except StopIteration:
+ break
+ keys.update(present)
+ parent_map = self.get_parent_map(keys)
+ parent_cache = {}
+ reannotate = annotate.reannotate
+ for record in self.get_record_stream(keys, 'topological', True):
+ key = record.key
+ fulltext = split_lines(record.get_bytes_as('fulltext'))
+ parent_lines = [parent_cache[parent] for parent in parent_map[key]]
+ parent_cache[key] = list(
+ reannotate(parent_lines, fulltext, key, None, head_cache))
+ return parent_cache[key]
+
def _check_add(self, key, lines, random_id, check_content):
"""check that version_id and lines are safe to add."""
version_id = key[-1]
More information about the bazaar-commits
mailing list