Merge lp:~jelmer/brz/file-content-factory into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/file-content-factory
Merge into: lp:brz
Diff against target: 878 lines (+197/-139)
14 files modified
breezy/_annotator_py.py (+1/-1)
breezy/bzr/groupcompress.py (+20/-17)
breezy/bzr/groupcompress_repo.py (+3/-3)
breezy/bzr/knit.py (+55/-36)
breezy/bzr/knitpack_repo.py (+2/-2)
breezy/bzr/reconcile.py (+5/-5)
breezy/bzr/smart/repository.py (+3/-1)
breezy/bzr/versionedfile.py (+55/-18)
breezy/bzr/vf_repository.py (+6/-12)
breezy/bzr/weave.py (+5/-6)
breezy/git/annotate.py (+7/-4)
breezy/merge.py (+1/-2)
breezy/plugins/weave_fmt/repository.py (+5/-5)
breezy/tests/per_versionedfile.py (+29/-27)
To merge this branch: bzr merge lp:~jelmer/brz/file-content-factory
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+378072@code.launchpad.net

Commit message

Add a 'lines' storage kind.

Description of the change

Add a 'lines' storage kind.

Avoid converting back and forth between fulltext and lines in various places.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/_annotator_py.py'
--- breezy/_annotator_py.py 2019-03-02 21:46:18 +0000
+++ breezy/_annotator_py.py 2020-01-25 16:26:49 +0000
@@ -127,7 +127,7 @@
127 if record.storage_kind == 'absent':127 if record.storage_kind == 'absent':
128 raise errors.RevisionNotPresent(record.key, self._vf)128 raise errors.RevisionNotPresent(record.key, self._vf)
129 this_key = record.key129 this_key = record.key
130 lines = osutils.chunks_to_lines(record.get_bytes_as('chunked'))130 lines = record.get_bytes_as('lines')
131 num_lines = len(lines)131 num_lines = len(lines)
132 self._text_cache[this_key] = lines132 self._text_cache[this_key] = lines
133 yield this_key, lines, num_lines133 yield this_key, lines, num_lines
134134
=== modified file 'breezy/bzr/groupcompress.py'
--- breezy/bzr/groupcompress.py 2020-01-25 14:46:10 +0000
+++ breezy/bzr/groupcompress.py 2020-01-25 16:26:49 +0000
@@ -466,7 +466,7 @@
466 return self._manager._wire_bytes()466 return self._manager._wire_bytes()
467 else:467 else:
468 return b''468 return b''
469 if storage_kind in ('fulltext', 'chunked'):469 if storage_kind in ('fulltext', 'chunked', 'lines'):
470 if self._bytes is None:470 if self._bytes is None:
471 # Grab and cache the raw bytes for this entry471 # Grab and cache the raw bytes for this entry
472 # and break the ref-cycle with _manager since we don't need it472 # and break the ref-cycle with _manager since we don't need it
@@ -482,8 +482,10 @@
482 # refcycle here, but instead in manager.get_record_stream()482 # refcycle here, but instead in manager.get_record_stream()
483 if storage_kind == 'fulltext':483 if storage_kind == 'fulltext':
484 return self._bytes484 return self._bytes
485 else:485 elif storage_kind == 'chunked':
486 return [self._bytes]486 return [self._bytes]
487 else:
488 return osutils.split_lines(self._bytes)
487 raise errors.UnavailableRepresentation(self.key, storage_kind,489 raise errors.UnavailableRepresentation(self.key, storage_kind,
488 self.storage_kind)490 self.storage_kind)
489491
@@ -566,9 +568,9 @@
566 old_length = self._block._content_length568 old_length = self._block._content_length
567 end_point = 0569 end_point = 0
568 for factory in self._factories:570 for factory in self._factories:
569 bytes = factory.get_bytes_as('fulltext')571 chunks = factory.get_bytes_as('chunked')
570 (found_sha1, start_point, end_point,572 (found_sha1, start_point, end_point,
571 type) = compressor.compress(factory.key, [bytes], factory.sha1)573 type) = compressor.compress(factory.key, chunks, factory.sha1)
572 # Now update this factory with the new offsets, etc574 # Now update this factory with the new offsets, etc
573 factory.sha1 = found_sha1575 factory.sha1 = found_sha1
574 factory._start = start_point576 factory._start = start_point
@@ -1369,7 +1371,7 @@
1369 if keys is None:1371 if keys is None:
1370 keys = self.keys()1372 keys = self.keys()
1371 for record in self.get_record_stream(keys, 'unordered', True):1373 for record in self.get_record_stream(keys, 'unordered', True):
1372 record.get_bytes_as('fulltext')1374 record.get_bytes_as('chunked')
1373 else:1375 else:
1374 return self.get_record_stream(keys, 'unordered', True)1376 return self.get_record_stream(keys, 'unordered', True)
13751377
@@ -1670,8 +1672,8 @@
1670 result[record.key] = record.sha11672 result[record.key] = record.sha1
1671 else:1673 else:
1672 if record.storage_kind != 'absent':1674 if record.storage_kind != 'absent':
1673 result[record.key] = osutils.sha_string(1675 result[record.key] = osutils.sha_strings(
1674 record.get_bytes_as('fulltext'))1676 record.get_bytes_as('chunked'))
1675 return result1677 return result
16761678
1677 def insert_record_stream(self, stream):1679 def insert_record_stream(self, stream):
@@ -1823,25 +1825,26 @@
1823 self._index.add_records(nodes, random_id=random_id)1825 self._index.add_records(nodes, random_id=random_id)
1824 continue1826 continue
1825 try:1827 try:
1826 bytes = record.get_bytes_as('fulltext')1828 chunks = record.get_bytes_as('chunked')
1827 except errors.UnavailableRepresentation:1829 except errors.UnavailableRepresentation:
1828 adapter_key = record.storage_kind, 'fulltext'1830 adapter_key = record.storage_kind, 'chunked'
1829 adapter = get_adapter(adapter_key)1831 adapter = get_adapter(adapter_key)
1830 bytes = adapter.get_bytes(record)1832 chunks = adapter.get_bytes(record, 'chunked')
1833 chunks_len = sum(map(len, chunks))
1831 if len(record.key) > 1:1834 if len(record.key) > 1:
1832 prefix = record.key[0]1835 prefix = record.key[0]
1833 soft = (prefix == last_prefix)1836 soft = (prefix == last_prefix)
1834 else:1837 else:
1835 prefix = None1838 prefix = None
1836 soft = False1839 soft = False
1837 if max_fulltext_len < len(bytes):1840 if max_fulltext_len < chunks_len:
1838 max_fulltext_len = len(bytes)1841 max_fulltext_len = chunks_len
1839 max_fulltext_prefix = prefix1842 max_fulltext_prefix = prefix
1840 (found_sha1, start_point, end_point,1843 (found_sha1, start_point, end_point,
1841 type) = self._compressor.compress(record.key,1844 type) = self._compressor.compress(record.key,
1842 [bytes], record.sha1, soft=soft,1845 chunks, record.sha1, soft=soft,
1843 nostore_sha=nostore_sha)1846 nostore_sha=nostore_sha)
1844 # delta_ratio = float(len(bytes)) / (end_point - start_point)1847 # delta_ratio = float(chunks_len) / (end_point - start_point)
1845 # Check if we want to continue to include that text1848 # Check if we want to continue to include that text
1846 if (prefix == max_fulltext_prefix1849 if (prefix == max_fulltext_prefix
1847 and end_point < 2 * max_fulltext_len):1850 and end_point < 2 * max_fulltext_len):
@@ -1859,10 +1862,10 @@
1859 if start_new_block:1862 if start_new_block:
1860 self._compressor.pop_last()1863 self._compressor.pop_last()
1861 flush()1864 flush()
1862 max_fulltext_len = len(bytes)1865 max_fulltext_len = chunks_len
1863 (found_sha1, start_point, end_point,1866 (found_sha1, start_point, end_point,
1864 type) = self._compressor.compress(1867 type) = self._compressor.compress(
1865 record.key, [bytes], record.sha1)1868 record.key, chunks, record.sha1)
1866 if record.key[-1] is None:1869 if record.key[-1] is None:
1867 key = record.key[:-1] + (b'sha1:' + found_sha1,)1870 key = record.key[:-1] + (b'sha1:' + found_sha1,)
1868 else:1871 else:
@@ -1915,7 +1918,7 @@
1915 pb.update('Walking content', key_idx, total)1918 pb.update('Walking content', key_idx, total)
1916 if record.storage_kind == 'absent':1919 if record.storage_kind == 'absent':
1917 raise errors.RevisionNotPresent(key, self)1920 raise errors.RevisionNotPresent(key, self)
1918 lines = osutils.split_lines(record.get_bytes_as('fulltext'))1921 lines = record.get_bytes_as('lines')
1919 for line in lines:1922 for line in lines:
1920 yield line, key1923 yield line, key
1921 if pb is not None:1924 if pb is not None:
19221925
=== modified file 'breezy/bzr/groupcompress_repo.py'
--- breezy/bzr/groupcompress_repo.py 2019-10-19 22:53:54 +0000
+++ breezy/bzr/groupcompress_repo.py 2020-01-25 16:26:49 +0000
@@ -698,9 +698,9 @@
698 % (chk_inv.revision_id, p_id_map.key()[0],698 % (chk_inv.revision_id, p_id_map.key()[0],
699 canon_p_id_map.key()[0]))699 canon_p_id_map.key()[0]))
700 self._data_changed = True700 self._data_changed = True
701 yield versionedfile.ChunkedContentFactory(record.key,701 yield versionedfile.ChunkedContentFactory(
702 record.parents, record.sha1,702 record.key, record.parents, record.sha1, canonical_inv.to_lines(),
703 canonical_inv.to_lines())703 chunks_are_lines=True)
704 # We have finished processing all of the inventory records, we704 # We have finished processing all of the inventory records, we
705 # don't need these sets anymore705 # don't need these sets anymore
706 return _filtered_inv_stream()706 return _filtered_inv_stream()
707707
=== modified file 'breezy/bzr/knit.py'
--- breezy/bzr/knit.py 2020-01-25 04:20:44 +0000
+++ breezy/bzr/knit.py 2020-01-25 16:26:49 +0000
@@ -223,7 +223,10 @@
223class FTAnnotatedToUnannotated(KnitAdapter):223class FTAnnotatedToUnannotated(KnitAdapter):
224 """An adapter from FT annotated knits to unannotated ones."""224 """An adapter from FT annotated knits to unannotated ones."""
225225
226 def get_bytes(self, factory):226 def get_bytes(self, factory, target_storage_kind):
227 if target_storage_kind != 'knit-ft-gz':
228 raise errors.UnavailableRepresentation(
229 factory.key, target_storage_kind, factory.storage_kind)
227 annotated_compressed_bytes = factory._raw_record230 annotated_compressed_bytes = factory._raw_record
228 rec, contents = \231 rec, contents = \
229 self._data._parse_record_unchecked(annotated_compressed_bytes)232 self._data._parse_record_unchecked(annotated_compressed_bytes)
@@ -236,7 +239,10 @@
236class DeltaAnnotatedToUnannotated(KnitAdapter):239class DeltaAnnotatedToUnannotated(KnitAdapter):
237 """An adapter for deltas from annotated to unannotated."""240 """An adapter for deltas from annotated to unannotated."""
238241
239 def get_bytes(self, factory):242 def get_bytes(self, factory, target_storage_kind):
243 if target_storage_kind != 'knit-delta-gz':
244 raise errors.UnavailableRepresentation(
245 factory.key, target_storage_kind, factory.storage_kind)
240 annotated_compressed_bytes = factory._raw_record246 annotated_compressed_bytes = factory._raw_record
241 rec, contents = \247 rec, contents = \
242 self._data._parse_record_unchecked(annotated_compressed_bytes)248 self._data._parse_record_unchecked(annotated_compressed_bytes)
@@ -250,19 +256,24 @@
250class FTAnnotatedToFullText(KnitAdapter):256class FTAnnotatedToFullText(KnitAdapter):
251 """An adapter from FT annotated knits to unannotated ones."""257 """An adapter from FT annotated knits to unannotated ones."""
252258
253 def get_bytes(self, factory):259 def get_bytes(self, factory, target_storage_kind):
254 annotated_compressed_bytes = factory._raw_record260 annotated_compressed_bytes = factory._raw_record
255 rec, contents = \261 rec, contents = \
256 self._data._parse_record_unchecked(annotated_compressed_bytes)262 self._data._parse_record_unchecked(annotated_compressed_bytes)
257 content, delta = self._annotate_factory.parse_record(factory.key[-1],263 content, delta = self._annotate_factory.parse_record(factory.key[-1],
258 contents, factory._build_details, None)264 contents, factory._build_details, None)
259 return b''.join(content.text())265 if target_storage_kind == 'fulltext':
266 return b''.join(content.text())
267 elif target_storage_kind in ('chunked', 'lines'):
268 return content.text()
269 raise errors.UnavailableRepresentation(
270 factory.key, target_storage_kind, factory.storage_kind)
260271
261272
262class DeltaAnnotatedToFullText(KnitAdapter):273class DeltaAnnotatedToFullText(KnitAdapter):
263 """An adapter for deltas from annotated to unannotated."""274 """An adapter for deltas from annotated to unannotated."""
264275
265 def get_bytes(self, factory):276 def get_bytes(self, factory, target_storage_kind):
266 annotated_compressed_bytes = factory._raw_record277 annotated_compressed_bytes = factory._raw_record
267 rec, contents = \278 rec, contents = \
268 self._data._parse_record_unchecked(annotated_compressed_bytes)279 self._data._parse_record_unchecked(annotated_compressed_bytes)
@@ -273,32 +284,42 @@
273 [compression_parent], 'unordered', True))284 [compression_parent], 'unordered', True))
274 if basis_entry.storage_kind == 'absent':285 if basis_entry.storage_kind == 'absent':
275 raise errors.RevisionNotPresent(compression_parent, self._basis_vf)286 raise errors.RevisionNotPresent(compression_parent, self._basis_vf)
276 basis_chunks = basis_entry.get_bytes_as('chunked')287 basis_lines = basis_entry.get_bytes_as('lines')
277 basis_lines = osutils.chunks_to_lines(basis_chunks)
278 # Manually apply the delta because we have one annotated content and288 # Manually apply the delta because we have one annotated content and
279 # one plain.289 # one plain.
280 basis_content = PlainKnitContent(basis_lines, compression_parent)290 basis_content = PlainKnitContent(basis_lines, compression_parent)
281 basis_content.apply_delta(delta, rec[1])291 basis_content.apply_delta(delta, rec[1])
282 basis_content._should_strip_eol = factory._build_details[1]292 basis_content._should_strip_eol = factory._build_details[1]
283 return b''.join(basis_content.text())293
294 if target_storage_kind == 'fulltext':
295 return b''.join(basis_content.text())
296 elif target_storage_kind in ('chunked', 'lines'):
297 return basis_content.text()
298 raise errors.UnavailableRepresentation(
299 factory.key, target_storage_kind, factory.storage_kind)
284300
285301
286class FTPlainToFullText(KnitAdapter):302class FTPlainToFullText(KnitAdapter):
287 """An adapter from FT plain knits to unannotated ones."""303 """An adapter from FT plain knits to unannotated ones."""
288304
289 def get_bytes(self, factory):305 def get_bytes(self, factory, target_storage_kind):
290 compressed_bytes = factory._raw_record306 compressed_bytes = factory._raw_record
291 rec, contents = \307 rec, contents = \
292 self._data._parse_record_unchecked(compressed_bytes)308 self._data._parse_record_unchecked(compressed_bytes)
293 content, delta = self._plain_factory.parse_record(factory.key[-1],309 content, delta = self._plain_factory.parse_record(factory.key[-1],
294 contents, factory._build_details, None)310 contents, factory._build_details, None)
295 return b''.join(content.text())311 if target_storage_kind == 'fulltext':
312 return b''.join(content.text())
313 elif target_storage_kind in ('chunked', 'lines'):
314 return content.text()
315 raise errors.UnavailableRepresentation(
316 factory.key, target_storage_kind, factory.storage_kind)
296317
297318
298class DeltaPlainToFullText(KnitAdapter):319class DeltaPlainToFullText(KnitAdapter):
299 """An adapter for deltas from annotated to unannotated."""320 """An adapter for deltas from annotated to unannotated."""
300321
301 def get_bytes(self, factory):322 def get_bytes(self, factory, target_storage_kind):
302 compressed_bytes = factory._raw_record323 compressed_bytes = factory._raw_record
303 rec, contents = \324 rec, contents = \
304 self._data._parse_record_unchecked(compressed_bytes)325 self._data._parse_record_unchecked(compressed_bytes)
@@ -309,14 +330,18 @@
309 [compression_parent], 'unordered', True))330 [compression_parent], 'unordered', True))
310 if basis_entry.storage_kind == 'absent':331 if basis_entry.storage_kind == 'absent':
311 raise errors.RevisionNotPresent(compression_parent, self._basis_vf)332 raise errors.RevisionNotPresent(compression_parent, self._basis_vf)
312 basis_chunks = basis_entry.get_bytes_as('chunked')333 basis_lines = basis_entry.get_bytes_as('lines')
313 basis_lines = osutils.chunks_to_lines(basis_chunks)
314 basis_content = PlainKnitContent(basis_lines, compression_parent)334 basis_content = PlainKnitContent(basis_lines, compression_parent)
315 # Manually apply the delta because we have one annotated content and335 # Manually apply the delta because we have one annotated content and
316 # one plain.336 # one plain.
317 content, _ = self._plain_factory.parse_record(rec[1], contents,337 content, _ = self._plain_factory.parse_record(rec[1], contents,
318 factory._build_details, basis_content)338 factory._build_details, basis_content)
319 return b''.join(content.text())339 if target_storage_kind == 'fulltext':
340 return b''.join(content.text())
341 elif target_storage_kind in ('chunked', 'lines'):
342 return content.text()
343 raise errors.UnavailableRepresentation(
344 factory.key, target_storage_kind, factory.storage_kind)
320345
321346
322class KnitContentFactory(ContentFactory):347class KnitContentFactory(ContentFactory):
@@ -381,19 +406,15 @@
381 self._create_network_bytes()406 self._create_network_bytes()
382 return self._network_bytes407 return self._network_bytes
383 if ('-ft-' in self.storage_kind408 if ('-ft-' in self.storage_kind
384 and storage_kind in ('chunked', 'fulltext')):409 and storage_kind in ('chunked', 'fulltext', 'lines')):
385 adapter_key = (self.storage_kind, 'fulltext')410 adapter_key = (self.storage_kind, storage_kind)
386 adapter_factory = adapter_registry.get(adapter_key)411 adapter_factory = adapter_registry.get(adapter_key)
387 adapter = adapter_factory(None)412 adapter = adapter_factory(None)
388 bytes = adapter.get_bytes(self)413 return adapter.get_bytes(self, storage_kind)
389 if storage_kind == 'chunked':
390 return [bytes]
391 else:
392 return bytes
393 if self._knit is not None:414 if self._knit is not None:
394 # Not redundant with direct conversion above - that only handles415 # Not redundant with direct conversion above - that only handles
395 # fulltext cases.416 # fulltext cases.
396 if storage_kind == 'chunked':417 if storage_kind in ('chunked', 'lines'):
397 return self._knit.get_lines(self.key[0])418 return self._knit.get_lines(self.key[0])
398 elif storage_kind == 'fulltext':419 elif storage_kind == 'fulltext':
399 return self._knit.get_text(self.key[0])420 return self._knit.get_text(self.key[0])
@@ -435,9 +456,9 @@
435 # all the keys etc are contained in the bytes returned in the456 # all the keys etc are contained in the bytes returned in the
436 # first record.457 # first record.
437 return b''458 return b''
438 if storage_kind in ('chunked', 'fulltext'):459 if storage_kind in ('chunked', 'fulltext', 'lines'):
439 chunks = self._generator._get_one_work(self.key).text()460 chunks = self._generator._get_one_work(self.key).text()
440 if storage_kind == 'chunked':461 if storage_kind in ('chunked', 'lines'):
441 return chunks462 return chunks
442 else:463 else:
443 return b''.join(chunks)464 return b''.join(chunks)
@@ -1708,7 +1729,7 @@
1708 except KeyError:1729 except KeyError:
1709 adapter_key = (record.storage_kind, "knit-ft-gz")1730 adapter_key = (record.storage_kind, "knit-ft-gz")
1710 adapter = get_adapter(adapter_key)1731 adapter = get_adapter(adapter_key)
1711 bytes = adapter.get_bytes(record)1732 bytes = adapter.get_bytes(record, adapter_key[1])
1712 else:1733 else:
1713 # It's a knit record, it has a _raw_record field (even if1734 # It's a knit record, it has a _raw_record field (even if
1714 # it was reconstituted from a network stream).1735 # it was reconstituted from a network stream).
@@ -1745,9 +1766,8 @@
1745 buffered = True1766 buffered = True
1746 if not buffered:1767 if not buffered:
1747 self._index.add_records([index_entry])1768 self._index.add_records([index_entry])
1748 elif record.storage_kind == 'chunked':1769 elif record.storage_kind in ('chunked', 'file'):
1749 self.add_lines(record.key, parents,1770 self.add_lines(record.key, parents, record.get_bytes_as('lines'))
1750 osutils.chunks_to_lines(record.get_bytes_as('chunked')))
1751 else:1771 else:
1752 # Not suitable for direct insertion as a1772 # Not suitable for direct insertion as a
1753 # delta, either because it's not the right format, or this1773 # delta, either because it's not the right format, or this
@@ -1757,12 +1777,11 @@
1757 self._access.flush()1777 self._access.flush()
1758 try:1778 try:
1759 # Try getting a fulltext directly from the record.1779 # Try getting a fulltext directly from the record.
1760 bytes = record.get_bytes_as('fulltext')1780 lines = record.get_bytes_as('lines')
1761 except errors.UnavailableRepresentation:1781 except errors.UnavailableRepresentation:
1762 adapter_key = record.storage_kind, 'fulltext'1782 adapter_key = record.storage_kind, 'lines'
1763 adapter = get_adapter(adapter_key)1783 adapter = get_adapter(adapter_key)
1764 bytes = adapter.get_bytes(record)1784 lines = adapter.get_bytes(record, 'lines')
1765 lines = split_lines(bytes)
1766 try:1785 try:
1767 self.add_lines(record.key, parents, lines)1786 self.add_lines(record.key, parents, lines)
1768 except errors.RevisionAlreadyPresent:1787 except errors.RevisionAlreadyPresent:
@@ -2107,7 +2126,7 @@
2107 if key in self.nonlocal_keys:2126 if key in self.nonlocal_keys:
2108 record = next(self.get_record_stream())2127 record = next(self.get_record_stream())
2109 # Create a content object on the fly2128 # Create a content object on the fly
2110 lines = osutils.chunks_to_lines(record.get_bytes_as('chunked'))2129 lines = record.get_bytes_as('lines')
2111 return PlainKnitContent(lines, record.key)2130 return PlainKnitContent(lines, record.key)
2112 else:2131 else:
2113 # local keys we can ask for directly2132 # local keys we can ask for directly
@@ -2198,9 +2217,9 @@
2198 if component_id in self._contents_map:2217 if component_id in self._contents_map:
2199 content = self._contents_map[component_id]2218 content = self._contents_map[component_id]
2200 else:2219 else:
2201 content, delta = self._factory.parse_record(key[-1],2220 content, delta = self._factory.parse_record(
2202 record, record_details, content,2221 key[-1], record, record_details, content,
2203 copy_base_content=multiple_versions)2222 copy_base_content=multiple_versions)
2204 if multiple_versions:2223 if multiple_versions:
2205 self._contents_map[component_id] = content2224 self._contents_map[component_id] = content
22062225
22072226
=== modified file 'breezy/bzr/knitpack_repo.py'
--- breezy/bzr/knitpack_repo.py 2020-01-11 17:50:28 +0000
+++ breezy/bzr/knitpack_repo.py 2020-01-25 16:26:49 +0000
@@ -1092,8 +1092,8 @@
1092 raise errors.BzrError('Mismatched key parent %r:%r' %1092 raise errors.BzrError('Mismatched key parent %r:%r' %
1093 (key, parent_keys))1093 (key, parent_keys))
1094 parents.append(parent_key[1])1094 parents.append(parent_key[1])
1095 text_lines = osutils.split_lines(next(repo.texts.get_record_stream(1095 text_lines = next(repo.texts.get_record_stream(
1096 [key], 'unordered', True)).get_bytes_as('fulltext'))1096 [key], 'unordered', True)).get_bytes_as('lines')
1097 output_texts.add_lines(key, parent_keys, text_lines,1097 output_texts.add_lines(key, parent_keys, text_lines,
1098 random_id=True, check_content=False)1098 random_id=True, check_content=False)
1099 # 5) check that nothing inserted has a reference outside the keyspace.1099 # 5) check that nothing inserted has a reference outside the keyspace.
11001100
=== modified file 'breezy/bzr/reconcile.py'
--- breezy/bzr/reconcile.py 2018-11-30 12:39:04 +0000
+++ breezy/bzr/reconcile.py 2020-01-25 16:26:49 +0000
@@ -35,7 +35,7 @@
35from ..i18n import gettext35from ..i18n import gettext
36from ..trace import mutter36from ..trace import mutter
37from ..tsort import topo_sort37from ..tsort import topo_sort
38from .versionedfile import AdapterFactory, FulltextContentFactory38from .versionedfile import AdapterFactory, ChunkedContentFactory
3939
4040
41class VersionedFileRepoReconciler(object):41class VersionedFileRepoReconciler(object):
@@ -152,8 +152,8 @@
152 # The check for the left most parent only handles knit152 # The check for the left most parent only handles knit
153 # compressors, but this code only applies to knit and weave153 # compressors, but this code only applies to knit and weave
154 # repositories anyway.154 # repositories anyway.
155 bytes = record.get_bytes_as('fulltext')155 chunks = record.get_bytes_as('chunked')
156 yield FulltextContentFactory(record.key, wanted_parents, record.sha1, bytes)156 yield ChunkedContentFactory(record.key, wanted_parents, record.sha1, chunks)
157 else:157 else:
158 adapted_record = AdapterFactory(158 adapted_record = AdapterFactory(
159 record.key, wanted_parents, record)159 record.key, wanted_parents, record)
@@ -344,10 +344,10 @@
344344
345 def fix_parents(stream):345 def fix_parents(stream):
346 for record in stream:346 for record in stream:
347 bytes = record.get_bytes_as('fulltext')347 chunks = record.get_bytes_as('chunked')
348 new_key = (new_file_id, record.key[-1])348 new_key = (new_file_id, record.key[-1])
349 parents = new_parents[new_key]349 parents = new_parents[new_key]
350 yield FulltextContentFactory(new_key, parents, record.sha1, bytes)350 yield ChunkedContentFactory(new_key, parents, record.sha1, chunks)
351 stream = self.repo.texts.get_record_stream(351 stream = self.repo.texts.get_record_stream(
352 needed_keys, 'topological', True)352 needed_keys, 'topological', True)
353 self.repo._remove_file_id(new_file_id)353 self.repo._remove_file_id(new_file_id)
354354
=== modified file 'breezy/bzr/smart/repository.py'
--- breezy/bzr/smart/repository.py 2019-02-15 18:57:38 +0000
+++ breezy/bzr/smart/repository.py 2020-01-25 16:26:49 +0000
@@ -1270,7 +1270,9 @@
1270 inv_delta = inv._make_delta(prev_inv)1270 inv_delta = inv._make_delta(prev_inv)
1271 lines = serializer.delta_to_lines(1271 lines = serializer.delta_to_lines(
1272 prev_inv.revision_id, inv.revision_id, inv_delta)1272 prev_inv.revision_id, inv.revision_id, inv_delta)
1273 yield ChunkedContentFactory(inv.revision_id, None, None, lines)1273 yield ChunkedContentFactory(
1274 inv.revision_id, None, None, lines,
1275 chunks_are_lines=True)
1274 prev_inv = inv1276 prev_inv = inv
12751277
1276 def body_stream(self, repository, ordering, revids):1278 def body_stream(self, repository, ordering, revids):
12771279
=== modified file 'breezy/bzr/versionedfile.py'
--- breezy/bzr/versionedfile.py 2020-01-11 17:50:28 +0000
+++ breezy/bzr/versionedfile.py 2020-01-25 16:26:49 +0000
@@ -56,20 +56,19 @@
5656
5757
58adapter_registry = Registry()58adapter_registry = Registry()
59adapter_registry.register_lazy(('knit-delta-gz', 'fulltext'), 'breezy.bzr.knit',
60 'DeltaPlainToFullText')
61adapter_registry.register_lazy(('knit-ft-gz', 'fulltext'), 'breezy.bzr.knit',
62 'FTPlainToFullText')
63adapter_registry.register_lazy(('knit-annotated-delta-gz', 'knit-delta-gz'),59adapter_registry.register_lazy(('knit-annotated-delta-gz', 'knit-delta-gz'),
64 'breezy.bzr.knit', 'DeltaAnnotatedToUnannotated')60 'breezy.bzr.knit', 'DeltaAnnotatedToUnannotated')
65adapter_registry.register_lazy(('knit-annotated-delta-gz', 'fulltext'),
66 'breezy.bzr.knit', 'DeltaAnnotatedToFullText')
67adapter_registry.register_lazy(('knit-annotated-ft-gz', 'knit-ft-gz'),61adapter_registry.register_lazy(('knit-annotated-ft-gz', 'knit-ft-gz'),
68 'breezy.bzr.knit', 'FTAnnotatedToUnannotated')62 'breezy.bzr.knit', 'FTAnnotatedToUnannotated')
69adapter_registry.register_lazy(('knit-annotated-ft-gz', 'fulltext'),63for target_storage_kind in ('fulltext', 'chunked', 'lines'):
70 'breezy.bzr.knit', 'FTAnnotatedToFullText')64 adapter_registry.register_lazy(('knit-delta-gz', target_storage_kind), 'breezy.bzr.knit',
71# adapter_registry.register_lazy(('knit-annotated-ft-gz', 'chunked'),65 'DeltaPlainToFullText')
72# 'breezy.bzr.knit', 'FTAnnotatedToChunked')66 adapter_registry.register_lazy(('knit-ft-gz', target_storage_kind), 'breezy.bzr.knit',
67 'FTPlainToFullText')
68 adapter_registry.register_lazy(('knit-annotated-ft-gz', target_storage_kind),
69 'breezy.bzr.knit', 'FTAnnotatedToFullText')
70 adapter_registry.register_lazy(('knit-annotated-delta-gz', target_storage_kind),
71 'breezy.bzr.knit', 'DeltaAnnotatedToFullText')
7372
7473
75class ContentFactory(object):74class ContentFactory(object):
@@ -110,21 +109,27 @@
110 :ivar parents: A tuple of parent keys for self.key. If the object has109 :ivar parents: A tuple of parent keys for self.key. If the object has
111 no parent information, None (as opposed to () for an empty list of110 no parent information, None (as opposed to () for an empty list of
112 parents).111 parents).
112 :ivar chunks_are_lines: Whether chunks are lines.
113 """113 """
114114
115 def __init__(self, key, parents, sha1, chunks):115 def __init__(self, key, parents, sha1, chunks, chunks_are_lines=None):
116 """Create a ContentFactory."""116 """Create a ContentFactory."""
117 self.sha1 = sha1117 self.sha1 = sha1
118 self.storage_kind = 'chunked'118 self.storage_kind = 'chunked'
119 self.key = key119 self.key = key
120 self.parents = parents120 self.parents = parents
121 self._chunks = chunks121 self._chunks = chunks
122 self._chunks_are_lines = chunks_are_lines
122123
123 def get_bytes_as(self, storage_kind):124 def get_bytes_as(self, storage_kind):
124 if storage_kind == 'chunked':125 if storage_kind == 'chunked':
125 return self._chunks126 return self._chunks
126 elif storage_kind == 'fulltext':127 elif storage_kind == 'fulltext':
127 return b''.join(self._chunks)128 return b''.join(self._chunks)
129 elif storage_kind == 'lines':
130 if self._chunks_are_lines:
131 return self._chunks
132 return list(osutils.chunks_to_lines(self._chunks))
128 raise errors.UnavailableRepresentation(self.key, storage_kind,133 raise errors.UnavailableRepresentation(self.key, storage_kind,
129 self.storage_kind)134 self.storage_kind)
130135
@@ -160,6 +165,38 @@
160 return self._text165 return self._text
161 elif storage_kind == 'chunked':166 elif storage_kind == 'chunked':
162 return [self._text]167 return [self._text]
168 elif storage_kind == 'lines':
169 return osutils.split_lines(self._text)
170 raise errors.UnavailableRepresentation(self.key, storage_kind,
171 self.storage_kind)
172
173
174class FileContentFactory(ContentFactory):
175 """File-based content factory.
176 """
177
178 def __init__(self, key, parents, fileobj):
179 self.key = key
180 self.parents = parents
181 self.file = fileobj
182 self.storage_kind = 'file'
183 self._sha1 = None
184
185 @property
186 def sha1(self):
187 if self._sha1 is None:
188 self.file.seek(0)
189 self._size, self._sha1 = osutils.size_sha_file(self.file)
190 return self._sha1
191
192 def get_bytes_as(self, storage_kind):
193 self.file.seek(0)
194 if storage_kind == 'fulltext':
195 return self.file.read()
196 elif storage_kind == 'chunked':
197 return list(osutils.file_iterator(self.file))
198 elif storage_kind == 'lines':
199 return self.file.readlines()
163 raise errors.UnavailableRepresentation(self.key, storage_kind,200 raise errors.UnavailableRepresentation(self.key, storage_kind,
164 self.storage_kind)201 self.storage_kind)
165202
@@ -1030,13 +1067,11 @@
1030 if not mpvf.has_version(p))1067 if not mpvf.has_version(p))
1031 # It seems likely that adding all the present parents as fulltexts can1068 # It seems likely that adding all the present parents as fulltexts can
1032 # easily exhaust memory.1069 # easily exhaust memory.
1033 chunks_to_lines = osutils.chunks_to_lines
1034 for record in self.get_record_stream(needed_parents, 'unordered',1070 for record in self.get_record_stream(needed_parents, 'unordered',
1035 True):1071 True):
1036 if record.storage_kind == 'absent':1072 if record.storage_kind == 'absent':
1037 continue1073 continue
1038 mpvf.add_version(chunks_to_lines(record.get_bytes_as('chunked')),1074 mpvf.add_version(record.get_bytes_as('lines'), record.key, [])
1039 record.key, [])
1040 for (key, parent_keys, expected_sha1, mpdiff), lines in zip(1075 for (key, parent_keys, expected_sha1, mpdiff), lines in zip(
1041 records, mpvf.get_line_list(versions)):1076 records, mpvf.get_line_list(versions)):
1042 if len(parent_keys) == 1:1077 if len(parent_keys) == 1:
@@ -1546,7 +1581,9 @@
1546 lines = self._lines[key]1581 lines = self._lines[key]
1547 parents = self._parents[key]1582 parents = self._parents[key]
1548 pending.remove(key)1583 pending.remove(key)
1549 yield ChunkedContentFactory(key, parents, None, lines)1584 yield ChunkedContentFactory(
1585 key, parents, None, lines,
1586 chunks_are_lines=True)
1550 for versionedfile in self.fallback_versionedfiles:1587 for versionedfile in self.fallback_versionedfiles:
1551 for record in versionedfile.get_record_stream(1588 for record in versionedfile.get_record_stream(
1552 pending, 'unordered', True):1589 pending, 'unordered', True):
@@ -1775,9 +1812,9 @@
1775 if lines is not None:1812 if lines is not None:
1776 if not isinstance(lines, list):1813 if not isinstance(lines, list):
1777 raise AssertionError1814 raise AssertionError
1778 yield ChunkedContentFactory((k,), None,1815 yield ChunkedContentFactory(
1779 sha1=osutils.sha_strings(lines),1816 (k,), None, sha1=osutils.sha_strings(lines),
1780 chunks=lines)1817 chunks=lines, chunks_are_lines=True)
1781 else:1818 else:
1782 yield AbsentContentFactory((k,))1819 yield AbsentContentFactory((k,))
17831820
17841821
=== modified file 'breezy/bzr/vf_repository.py'
--- breezy/bzr/vf_repository.py 2020-01-20 00:03:54 +0000
+++ breezy/bzr/vf_repository.py 2020-01-25 16:26:49 +0000
@@ -853,8 +853,8 @@
853 """Check a single text from this repository."""853 """Check a single text from this repository."""
854 if kind == 'inventories':854 if kind == 'inventories':
855 rev_id = record.key[0]855 rev_id = record.key[0]
856 inv = self._deserialise_inventory(rev_id,856 inv = self._deserialise_inventory(
857 record.get_bytes_as('fulltext'))857 rev_id, record.get_bytes_as('fulltext'))
858 if last_object is not None:858 if last_object is not None:
859 delta = inv._make_delta(last_object)859 delta = inv._make_delta(last_object)
860 for old_path, path, file_id, ie in delta:860 for old_path, path, file_id, ie in delta:
@@ -880,14 +880,9 @@
880 """Check a single text."""880 """Check a single text."""
881 # Check it is extractable.881 # Check it is extractable.
882 # TODO: check length.882 # TODO: check length.
883 if record.storage_kind == 'chunked':883 chunks = record.get_bytes_as('chunked')
884 chunks = record.get_bytes_as(record.storage_kind)884 sha1 = osutils.sha_strings(chunks)
885 sha1 = osutils.sha_strings(chunks)885 length = sum(map(len, chunks))
886 length = sum(map(len, chunks))
887 else:
888 content = record.get_bytes_as('fulltext')
889 sha1 = osutils.sha_string(content)
890 length = len(content)
891 if item_data and sha1 != item_data[1]:886 if item_data and sha1 != item_data[1]:
892 checker._report_items.append(887 checker._report_items.append(
893 'sha1 mismatch: %s has sha1 %s expected %s referenced by %s' %888 'sha1 mismatch: %s has sha1 %s expected %s referenced by %s' %
@@ -1197,9 +1192,8 @@
1197 stream = self.inventories.get_record_stream(keys, 'unordered', True)1192 stream = self.inventories.get_record_stream(keys, 'unordered', True)
1198 for record in stream:1193 for record in stream:
1199 if record.storage_kind != 'absent':1194 if record.storage_kind != 'absent':
1200 chunks = record.get_bytes_as('chunked')1195 lines = record.get_bytes_as('lines')
1201 revid = record.key[-1]1196 revid = record.key[-1]
1202 lines = osutils.chunks_to_lines(chunks)
1203 for line in lines:1197 for line in lines:
1204 yield line, revid1198 yield line, revid
12051199
12061200
=== modified file 'breezy/bzr/weave.py'
--- breezy/bzr/weave.py 2019-03-02 21:46:18 +0000
+++ breezy/bzr/weave.py 2020-01-25 16:26:49 +0000
@@ -179,7 +179,7 @@
179 def get_bytes_as(self, storage_kind):179 def get_bytes_as(self, storage_kind):
180 if storage_kind == 'fulltext':180 if storage_kind == 'fulltext':
181 return self._weave.get_text(self.key[-1])181 return self._weave.get_text(self.key[-1])
182 elif storage_kind == 'chunked':182 elif storage_kind in ('chunked', 'lines'):
183 return self._weave.get_lines(self.key[-1])183 return self._weave.get_lines(self.key[-1])
184 else:184 else:
185 raise UnavailableRepresentation(self.key, storage_kind, 'fulltext')185 raise UnavailableRepresentation(self.key, storage_kind, 'fulltext')
@@ -422,20 +422,19 @@
422 raise RevisionNotPresent([record.key[0]], self)422 raise RevisionNotPresent([record.key[0]], self)
423 # adapt to non-tuple interface423 # adapt to non-tuple interface
424 parents = [parent[0] for parent in record.parents]424 parents = [parent[0] for parent in record.parents]
425 if (record.storage_kind == 'fulltext' or425 if record.storage_kind in ('fulltext', 'chunked', 'lines'):
426 record.storage_kind == 'chunked'):
427 self.add_lines(426 self.add_lines(
428 record.key[0], parents,427 record.key[0], parents,
429 osutils.chunks_to_lines(record.get_bytes_as('chunked')))428 record.get_bytes_as('lines'))
430 else:429 else:
431 adapter_key = record.storage_kind, 'fulltext'430 adapter_key = record.storage_kind, 'lines'
432 try:431 try:
433 adapter = adapters[adapter_key]432 adapter = adapters[adapter_key]
434 except KeyError:433 except KeyError:
435 adapter_factory = adapter_registry.get(adapter_key)434 adapter_factory = adapter_registry.get(adapter_key)
436 adapter = adapter_factory(self)435 adapter = adapter_factory(self)
437 adapters[adapter_key] = adapter436 adapters[adapter_key] = adapter
438 lines = split_lines(adapter.get_bytes(record))437 lines = adapter.get_bytes(record, 'lines')
439 try:438 try:
440 self.add_lines(record.key[0], parents, lines)439 self.add_lines(record.key[0], parents, lines)
441 except RevisionAlreadyPresent:440 except RevisionAlreadyPresent:
442441
=== modified file 'breezy/git/annotate.py'
--- breezy/git/annotate.py 2019-10-20 23:46:25 +0000
+++ breezy/git/annotate.py 2020-01-25 16:26:49 +0000
@@ -22,6 +22,7 @@
22 tree_lookup_path,22 tree_lookup_path,
23 )23 )
2424
25from .. import osutils
25from ..errors import (26from ..errors import (
26 NoSuchRevision,27 NoSuchRevision,
27 UnavailableRepresentation,28 UnavailableRepresentation,
@@ -32,7 +33,7 @@
32 )33 )
3334
3435
35class GitFulltextContentFactory(object):36class GitBlobContentFactory(object):
36 """Static data content factory.37 """Static data content factory.
3738
38 This takes a fulltext when created and just returns that during39 This takes a fulltext when created and just returns that during
@@ -52,17 +53,19 @@
52 """Create a ContentFactory."""53 """Create a ContentFactory."""
53 self.store = store54 self.store = store
54 self.key = (path, revision)55 self.key = (path, revision)
55 self.storage_kind = 'fulltext'56 self.storage_kind = 'git-blob'
56 self.parents = None57 self.parents = None
57 self.blob_id = blob_id58 self.blob_id = blob_id
5859
59 def get_bytes_as(self, storage_kind):60 def get_bytes_as(self, storage_kind):
60 if storage_kind == 'fulltext':61 if storage_kind == 'fulltext':
61 return self.store[self.blob_id].as_raw_string()62 return self.store[self.blob_id].as_raw_string()
63 elif storage_kind == 'lines':
64 return osutils.chunks_to_lines(self.store[self.blob_id].as_raw_chunks())
62 elif storage_kind == 'chunked':65 elif storage_kind == 'chunked':
63 return self.store[self.blob_id].as_raw_chunks()66 return self.store[self.blob_id].as_raw_chunks()
64 raise UnavailableRepresentation(self.key, storage_kind,67 raise UnavailableRepresentation(self.key, storage_kind,
65 'fulltext')68 self.storage_kind)
6669
6770
68class GitAbsentContentFactory(object):71class GitAbsentContentFactory(object):
@@ -153,5 +156,5 @@
153 except KeyError:156 except KeyError:
154 yield GitAbsentContentFactory(store, path, text_revision)157 yield GitAbsentContentFactory(store, path, text_revision)
155 else:158 else:
156 yield GitFulltextContentFactory(159 yield GitBlobContentFactory(
157 store, path, text_revision, blob_sha)160 store, path, text_revision, blob_sha)
158161
=== modified file 'breezy/merge.py'
--- breezy/merge.py 2020-01-18 16:14:28 +0000
+++ breezy/merge.py 2020-01-25 16:26:49 +0000
@@ -2007,8 +2007,7 @@
2007 for record in self.vf.get_record_stream(keys, 'unordered', True):2007 for record in self.vf.get_record_stream(keys, 'unordered', True):
2008 if record.storage_kind == 'absent':2008 if record.storage_kind == 'absent':
2009 raise errors.RevisionNotPresent(record.key, self.vf)2009 raise errors.RevisionNotPresent(record.key, self.vf)
2010 result[record.key[-1]] = osutils.chunks_to_lines(2010 result[record.key[-1]] = record.get_bytes_as('lines')
2011 record.get_bytes_as('chunked'))
2012 return result2011 return result
20132012
2014 def plan_merge(self):2013 def plan_merge(self):
20152014
=== modified file 'breezy/plugins/weave_fmt/repository.py'
--- breezy/plugins/weave_fmt/repository.py 2018-11-12 01:41:38 +0000
+++ breezy/plugins/weave_fmt/repository.py 2020-01-25 16:26:49 +0000
@@ -628,19 +628,19 @@
628 if record.storage_kind == 'absent':628 if record.storage_kind == 'absent':
629 raise errors.RevisionNotPresent([record.key[0]], self)629 raise errors.RevisionNotPresent([record.key[0]], self)
630 # adapt to non-tuple interface630 # adapt to non-tuple interface
631 if record.storage_kind == 'fulltext':631 if record.storage_kind in ('fulltext', 'chunks', 'lines'):
632 self.add_lines(record.key, None,632 self.add_lines(record.key, None,
633 osutils.split_lines(record.get_bytes_as('fulltext')))633 record.get_bytes_as('lines'))
634 else:634 else:
635 adapter_key = record.storage_kind, 'fulltext'635 adapter_key = record.storage_kind, 'lines'
636 try:636 try:
637 adapter = adapters[adapter_key]637 adapter = adapters[adapter_key]
638 except KeyError:638 except KeyError:
639 adapter_factory = adapter_registry.get(adapter_key)639 adapter_factory = adapter_registry.get(adapter_key)
640 adapter = adapter_factory(self)640 adapter = adapter_factory(self)
641 adapters[adapter_key] = adapter641 adapters[adapter_key] = adapter
642 lines = osutils.split_lines(adapter.get_bytes(642 lines = adapter.get_bytes(
643 record, record.get_bytes_as(record.storage_kind)))643 record, record.get_bytes_as(record.storage_kind))
644 try:644 try:
645 self.add_lines(record.key, None, lines)645 self.add_lines(record.key, None, lines)
646 except errors.RevisionAlreadyPresent:646 except errors.RevisionAlreadyPresent:
647647
=== modified file 'breezy/tests/per_versionedfile.py'
--- breezy/tests/per_versionedfile.py 2019-06-16 15:54:33 +0000
+++ breezy/tests/per_versionedfile.py 2020-01-25 16:26:49 +0000
@@ -1214,7 +1214,11 @@
1214 # Each is source_kind, requested_kind, adapter class1214 # Each is source_kind, requested_kind, adapter class
1215 scenarios = [1215 scenarios = [
1216 ('knit-delta-gz', 'fulltext', _mod_knit.DeltaPlainToFullText),1216 ('knit-delta-gz', 'fulltext', _mod_knit.DeltaPlainToFullText),
1217 ('knit-delta-gz', 'lines', _mod_knit.DeltaPlainToFullText),
1218 ('knit-delta-gz', 'chunked', _mod_knit.DeltaPlainToFullText),
1217 ('knit-ft-gz', 'fulltext', _mod_knit.FTPlainToFullText),1219 ('knit-ft-gz', 'fulltext', _mod_knit.FTPlainToFullText),
1220 ('knit-ft-gz', 'lines', _mod_knit.FTPlainToFullText),
1221 ('knit-ft-gz', 'chunked', _mod_knit.FTPlainToFullText),
1218 ('knit-annotated-delta-gz', 'knit-delta-gz',1222 ('knit-annotated-delta-gz', 'knit-delta-gz',
1219 _mod_knit.DeltaAnnotatedToUnannotated),1223 _mod_knit.DeltaAnnotatedToUnannotated),
1220 ('knit-annotated-delta-gz', 'fulltext',1224 ('knit-annotated-delta-gz', 'fulltext',
@@ -1223,6 +1227,10 @@
1223 _mod_knit.FTAnnotatedToUnannotated),1227 _mod_knit.FTAnnotatedToUnannotated),
1224 ('knit-annotated-ft-gz', 'fulltext',1228 ('knit-annotated-ft-gz', 'fulltext',
1225 _mod_knit.FTAnnotatedToFullText),1229 _mod_knit.FTAnnotatedToFullText),
1230 ('knit-annotated-ft-gz', 'lines',
1231 _mod_knit.FTAnnotatedToFullText),
1232 ('knit-annotated-ft-gz', 'chunked',
1233 _mod_knit.FTAnnotatedToFullText),
1226 ]1234 ]
1227 for source, requested, klass in scenarios:1235 for source, requested, klass in scenarios:
1228 adapter_factory = versionedfile.adapter_registry.get(1236 adapter_factory = versionedfile.adapter_registry.get(
@@ -1235,16 +1243,16 @@
1235 transport = self.get_transport()1243 transport = self.get_transport()
1236 return make_file_factory(annotated, mapper)(transport)1244 return make_file_factory(annotated, mapper)(transport)
12371245
1238 def helpGetBytes(self, f, ft_adapter, delta_adapter):1246 def helpGetBytes(self, f, ft_name, ft_adapter, delta_name, delta_adapter):
1239 """Grab the interested adapted texts for tests."""1247 """Grab the interested adapted texts for tests."""
1240 # origin is a fulltext1248 # origin is a fulltext
1241 entries = f.get_record_stream([(b'origin',)], 'unordered', False)1249 entries = f.get_record_stream([(b'origin',)], 'unordered', False)
1242 base = next(entries)1250 base = next(entries)
1243 ft_data = ft_adapter.get_bytes(base)1251 ft_data = ft_adapter.get_bytes(base, ft_name)
1244 # merged is both a delta and multiple parents.1252 # merged is both a delta and multiple parents.
1245 entries = f.get_record_stream([(b'merged',)], 'unordered', False)1253 entries = f.get_record_stream([(b'merged',)], 'unordered', False)
1246 merged = next(entries)1254 merged = next(entries)
1247 delta_data = delta_adapter.get_bytes(merged)1255 delta_data = delta_adapter.get_bytes(merged, delta_name)
1248 return ft_data, delta_data1256 return ft_data, delta_data
12491257
1250 def test_deannotation_noeol(self):1258 def test_deannotation_noeol(self):
@@ -1252,10 +1260,9 @@
1252 # we need a full text, and a delta1260 # we need a full text, and a delta
1253 f = self.get_knit()1261 f = self.get_knit()
1254 get_diamond_files(f, 1, trailing_eol=False)1262 get_diamond_files(f, 1, trailing_eol=False)
1255 ft_data, delta_data = self.helpGetBytes(f,1263 ft_data, delta_data = self.helpGetBytes(
1256 _mod_knit.FTAnnotatedToUnannotated(1264 f, 'knit-ft-gz', _mod_knit.FTAnnotatedToUnannotated(None),
1257 None),1265 'knit-delta-gz', _mod_knit.DeltaAnnotatedToUnannotated(None))
1258 _mod_knit.DeltaAnnotatedToUnannotated(None))
1259 self.assertEqual(1266 self.assertEqual(
1260 b'version origin 1 b284f94827db1fa2970d9e2014f080413b547a7e\n'1267 b'version origin 1 b284f94827db1fa2970d9e2014f080413b547a7e\n'
1261 b'origin\n'1268 b'origin\n'
@@ -1271,10 +1278,9 @@
1271 # we need a full text, and a delta1278 # we need a full text, and a delta
1272 f = self.get_knit()1279 f = self.get_knit()
1273 get_diamond_files(f, 1)1280 get_diamond_files(f, 1)
1274 ft_data, delta_data = self.helpGetBytes(f,1281 ft_data, delta_data = self.helpGetBytes(
1275 _mod_knit.FTAnnotatedToUnannotated(1282 f, 'knit-ft-gz', _mod_knit.FTAnnotatedToUnannotated(None),
1276 None),1283 'knit-delta-gz', _mod_knit.DeltaAnnotatedToUnannotated(None))
1277 _mod_knit.DeltaAnnotatedToUnannotated(None))
1278 self.assertEqual(1284 self.assertEqual(
1279 b'version origin 1 00e364d235126be43292ab09cb4686cf703ddc17\n'1285 b'version origin 1 00e364d235126be43292ab09cb4686cf703ddc17\n'
1280 b'origin\n'1286 b'origin\n'
@@ -1293,10 +1299,9 @@
1293 # Reconstructing a full text requires a backing versioned file, and it1299 # Reconstructing a full text requires a backing versioned file, and it
1294 # must have the base lines requested from it.1300 # must have the base lines requested from it.
1295 logged_vf = versionedfile.RecordingVersionedFilesDecorator(f)1301 logged_vf = versionedfile.RecordingVersionedFilesDecorator(f)
1296 ft_data, delta_data = self.helpGetBytes(f,1302 ft_data, delta_data = self.helpGetBytes(
1297 _mod_knit.FTAnnotatedToFullText(1303 f, 'fulltext', _mod_knit.FTAnnotatedToFullText(None),
1298 None),1304 'fulltext', _mod_knit.DeltaAnnotatedToFullText(logged_vf))
1299 _mod_knit.DeltaAnnotatedToFullText(logged_vf))
1300 self.assertEqual(b'origin', ft_data)1305 self.assertEqual(b'origin', ft_data)
1301 self.assertEqual(b'base\nleft\nright\nmerged', delta_data)1306 self.assertEqual(b'base\nleft\nright\nmerged', delta_data)
1302 self.assertEqual([('get_record_stream', [(b'left',)], 'unordered',1307 self.assertEqual([('get_record_stream', [(b'left',)], 'unordered',
@@ -1310,10 +1315,9 @@
1310 # Reconstructing a full text requires a backing versioned file, and it1315 # Reconstructing a full text requires a backing versioned file, and it
1311 # must have the base lines requested from it.1316 # must have the base lines requested from it.
1312 logged_vf = versionedfile.RecordingVersionedFilesDecorator(f)1317 logged_vf = versionedfile.RecordingVersionedFilesDecorator(f)
1313 ft_data, delta_data = self.helpGetBytes(f,1318 ft_data, delta_data = self.helpGetBytes(
1314 _mod_knit.FTAnnotatedToFullText(1319 f, 'fulltext', _mod_knit.FTAnnotatedToFullText(None),
1315 None),1320 'fulltext', _mod_knit.DeltaAnnotatedToFullText(logged_vf))
1316 _mod_knit.DeltaAnnotatedToFullText(logged_vf))
1317 self.assertEqual(b'origin\n', ft_data)1321 self.assertEqual(b'origin\n', ft_data)
1318 self.assertEqual(b'base\nleft\nright\nmerged\n', delta_data)1322 self.assertEqual(b'base\nleft\nright\nmerged\n', delta_data)
1319 self.assertEqual([('get_record_stream', [(b'left',)], 'unordered',1323 self.assertEqual([('get_record_stream', [(b'left',)], 'unordered',
@@ -1330,10 +1334,9 @@
1330 # Reconstructing a full text requires a backing versioned file, and it1334 # Reconstructing a full text requires a backing versioned file, and it
1331 # must have the base lines requested from it.1335 # must have the base lines requested from it.
1332 logged_vf = versionedfile.RecordingVersionedFilesDecorator(f)1336 logged_vf = versionedfile.RecordingVersionedFilesDecorator(f)
1333 ft_data, delta_data = self.helpGetBytes(f,1337 ft_data, delta_data = self.helpGetBytes(
1334 _mod_knit.FTPlainToFullText(1338 f, 'fulltext', _mod_knit.FTPlainToFullText(None),
1335 None),1339 'fulltext', _mod_knit.DeltaPlainToFullText(logged_vf))
1336 _mod_knit.DeltaPlainToFullText(logged_vf))
1337 self.assertEqual(b'origin\n', ft_data)1340 self.assertEqual(b'origin\n', ft_data)
1338 self.assertEqual(b'base\nleft\nright\nmerged\n', delta_data)1341 self.assertEqual(b'base\nleft\nright\nmerged\n', delta_data)
1339 self.assertEqual([('get_record_stream', [(b'left',)], 'unordered',1342 self.assertEqual([('get_record_stream', [(b'left',)], 'unordered',
@@ -1350,10 +1353,9 @@
1350 # Reconstructing a full text requires a backing versioned file, and it1353 # Reconstructing a full text requires a backing versioned file, and it
1351 # must have the base lines requested from it.1354 # must have the base lines requested from it.
1352 logged_vf = versionedfile.RecordingVersionedFilesDecorator(f)1355 logged_vf = versionedfile.RecordingVersionedFilesDecorator(f)
1353 ft_data, delta_data = self.helpGetBytes(f,1356 ft_data, delta_data = self.helpGetBytes(
1354 _mod_knit.FTPlainToFullText(1357 f, 'fulltext', _mod_knit.FTPlainToFullText(None),
1355 None),1358 'fulltext', _mod_knit.DeltaPlainToFullText(logged_vf))
1356 _mod_knit.DeltaPlainToFullText(logged_vf))
1357 self.assertEqual(b'origin', ft_data)1359 self.assertEqual(b'origin', ft_data)
1358 self.assertEqual(b'base\nleft\nright\nmerged', delta_data)1360 self.assertEqual(b'base\nleft\nright\nmerged', delta_data)
1359 self.assertEqual([('get_record_stream', [(b'left',)], 'unordered',1361 self.assertEqual([('get_record_stream', [(b'left',)], 'unordered',

Subscribers

People subscribed via source and target branches