Rev 4491: Add tests tha left-matching-blocks gets populated. in http://bazaar.launchpad.net/~jameinel/bzr/1.17-rework-annotate
John Arbash Meinel
john at arbash-meinel.com
Tue Jun 23 20:25:06 BST 2009
At http://bazaar.launchpad.net/~jameinel/bzr/1.17-rework-annotate
------------------------------------------------------------
revno: 4491
revision-id: john at arbash-meinel.com-20090623192501-qzf1a07g8gxzkrxl
parent: john at arbash-meinel.com-20090623191430-jpb00rg2to2spfb3
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 1.17-rework-annotate
timestamp: Tue 2009-06-23 14:25:01 -0500
message:
Add tests tha left-matching-blocks gets populated.
-------------- next part --------------
=== modified file 'bzrlib/knit.py'
--- a/bzrlib/knit.py 2009-06-23 19:14:30 +0000
+++ b/bzrlib/knit.py 2009-06-23 19:25:01 +0000
@@ -3399,8 +3399,14 @@
# The cached build_details are no longer valid
self._all_build_details.clear()
+ def _cache_delta_blocks(self, key, compression_parent, delta, lines):
+ parent_lines = self._text_cache[compression_parent]
+ blocks = list(KnitContent.get_line_delta_blocks(delta, parent_lines, lines))
+ self._left_matching_blocks[key] = blocks
+
def _expand_record(self, key, parent_keys, compression_parent, record,
record_details):
+ delta = None
if compression_parent:
if compression_parent not in self._content_objects:
# Waiting for the parent
@@ -3422,19 +3428,19 @@
# gives very bad results.
# The alternative is to copy the lines into text cache, but then we
# are copying anyway, so just do it here.
- content, _ = self._vf._factory.parse_record(
+ content, delta = self._vf._factory.parse_record(
key, record, record_details, base_content,
copy_base_content=True)
else:
# Fulltext record
content, _ = self._vf._factory.parse_record(
key, record, record_details, None)
- # TODO: Only track the content when there are compression children.
- # Otherwise we only need the lines
if self._num_compression_children.get(key, 0) > 0:
self._content_objects[key] = content
lines = content.text()
self._text_cache[key] = lines
+ if delta is not None:
+ self._cache_delta_blocks(key, compression_parent, delta, lines)
return lines
def _process_pending(self, key):
=== modified file 'bzrlib/tests/test_knit.py'
--- a/bzrlib/tests/test_knit.py 2009-06-23 19:14:30 +0000
+++ b/bzrlib/tests/test_knit.py 2009-06-23 19:25:01 +0000
@@ -1372,6 +1372,26 @@
# they do not have compression children of their own.
self.assertEqual({}, ann._content_objects)
+ def test__expand_delta_records_blocks(self):
+ ann = self.make_annotator()
+ rev_key = ('rev-id',)
+ parent_key = ('parent-id',)
+ record = ['0,1,1\n', 'new-line\n']
+ details = ('line-delta', True)
+ ann._num_compression_children[parent_key] = 2
+ ann._expand_record(parent_key, (), None,
+ ['line1\n', 'line2\n', 'line3\n'],
+ ('fulltext', False))
+ ann._expand_record(rev_key, (parent_key,), parent_key, record, details)
+ self.assertEqual({rev_key: [(1, 1, 1), (3, 3, 0)]},
+ ann._left_matching_blocks)
+ rev2_key = ('rev2-id',)
+ record = ['0,1,1\n', 'new-line\n']
+ details = ('line-delta', False)
+ ann._expand_record(rev2_key, (parent_key,), parent_key, record, details)
+ self.assertEqual([(1, 1, 2), (3, 3, 0)],
+ ann._left_matching_blocks[rev2_key])
+
def test__process_pending(self):
ann = self.make_annotator()
rev_key = ('rev-id',)
More information about the bazaar-commits
mailing list