Rev 4006: Change the signature on VersionedFiles adapters to allow less typing and more flexability inside adapters. in http://people.ubuntu.com/~robertc/baz2.0/versioned_files.network
Robert Collins
robertc at robertcollins.net
Sun Feb 15 21:24:37 GMT 2009
At http://people.ubuntu.com/~robertc/baz2.0/versioned_files.network
------------------------------------------------------------
revno: 4006
revision-id: robertc at robertcollins.net-20090215212420-2h3c8fdf0w2h6e0v
parent: pqm at pqm.ubuntu.com-20090212154913-cleqwmh36ss3gswk
committer: Robert Collins <robertc at robertcollins.net>
branch nick: VersionedFiles.adapter_signature
timestamp: Mon 2009-02-16 08:24:20 +1100
message:
Change the signature on VersionedFiles adapters to allow less typing and more flexability inside adapters.
=== modified file 'NEWS'
--- a/NEWS 2009-02-11 22:25:18 +0000
+++ b/NEWS 2009-02-15 21:24:20 +0000
@@ -44,6 +44,12 @@
command object before the command is run (or help generated from
it), without overriding the command. (Robert Collins)
+ * ``VersionedFiles`` record adapters have had their signature change
+ from ``(record, record.get_bytes_as(record.storage_kind))`` to
+ ``(record)`` reducing excess duplication and allowing adapters
+ to access private data in record to obtain content more
+ efficiently. (Robert Collins)
+
bzr 1.12rc1 "1234567890" 2009-02-10
-----------------------------------
=== modified file 'bzrlib/knit.py'
--- a/bzrlib/knit.py 2009-02-02 05:56:34 +0000
+++ b/bzrlib/knit.py 2009-02-15 21:24:20 +0000
@@ -151,7 +151,8 @@
class FTAnnotatedToUnannotated(KnitAdapter):
"""An adapter from FT annotated knits to unannotated ones."""
- def get_bytes(self, factory, annotated_compressed_bytes):
+ def get_bytes(self, factory):
+ annotated_compressed_bytes = factory.get_bytes_as(factory.storage_kind)
rec, contents = \
self._data._parse_record_unchecked(annotated_compressed_bytes)
content = self._annotate_factory.parse_fulltext(contents, rec[1])
@@ -162,7 +163,8 @@
class DeltaAnnotatedToUnannotated(KnitAdapter):
"""An adapter for deltas from annotated to unannotated."""
- def get_bytes(self, factory, annotated_compressed_bytes):
+ def get_bytes(self, factory):
+ annotated_compressed_bytes = factory.get_bytes_as(factory.storage_kind)
rec, contents = \
self._data._parse_record_unchecked(annotated_compressed_bytes)
delta = self._annotate_factory.parse_line_delta(contents, rec[1],
@@ -175,7 +177,8 @@
class FTAnnotatedToFullText(KnitAdapter):
"""An adapter from FT annotated knits to unannotated ones."""
- def get_bytes(self, factory, annotated_compressed_bytes):
+ def get_bytes(self, factory):
+ annotated_compressed_bytes = factory.get_bytes_as(factory.storage_kind)
rec, contents = \
self._data._parse_record_unchecked(annotated_compressed_bytes)
content, delta = self._annotate_factory.parse_record(factory.key[-1],
@@ -186,7 +189,8 @@
class DeltaAnnotatedToFullText(KnitAdapter):
"""An adapter for deltas from annotated to unannotated."""
- def get_bytes(self, factory, annotated_compressed_bytes):
+ def get_bytes(self, factory):
+ annotated_compressed_bytes = factory.get_bytes_as(factory.storage_kind)
rec, contents = \
self._data._parse_record_unchecked(annotated_compressed_bytes)
delta = self._annotate_factory.parse_line_delta(contents, rec[1],
@@ -209,7 +213,8 @@
class FTPlainToFullText(KnitAdapter):
"""An adapter from FT plain knits to unannotated ones."""
- def get_bytes(self, factory, compressed_bytes):
+ def get_bytes(self, factory):
+ compressed_bytes = factory.get_bytes_as(factory.storage_kind)
rec, contents = \
self._data._parse_record_unchecked(compressed_bytes)
content, delta = self._plain_factory.parse_record(factory.key[-1],
@@ -220,7 +225,8 @@
class DeltaPlainToFullText(KnitAdapter):
"""An adapter for deltas from annotated to unannotated."""
- def get_bytes(self, factory, compressed_bytes):
+ def get_bytes(self, factory):
+ compressed_bytes = factory.get_bytes_as(factory.storage_kind)
rec, contents = \
self._data._parse_record_unchecked(compressed_bytes)
delta = self._plain_factory.parse_line_delta(contents, rec[1])
@@ -1408,8 +1414,7 @@
except KeyError:
adapter_key = (record.storage_kind, "knit-ft-gz")
adapter = get_adapter(adapter_key)
- bytes = adapter.get_bytes(
- record, record.get_bytes_as(record.storage_kind))
+ bytes = adapter.get_bytes(record)
else:
bytes = record.get_bytes_as(record.storage_kind)
options = [record._build_details[0]]
@@ -1459,8 +1464,7 @@
# fallback kvfs.
adapter_key = record.storage_kind, 'fulltext'
adapter = get_adapter(adapter_key)
- lines = split_lines(adapter.get_bytes(
- record, record.get_bytes_as(record.storage_kind)))
+ lines = split_lines(adapter.get_bytes(record))
try:
self.add_lines(record.key, parents, lines)
except errors.RevisionAlreadyPresent:
=== modified file 'bzrlib/tests/test_versionedfile.py'
--- a/bzrlib/tests/test_versionedfile.py 2009-01-22 01:03:44 +0000
+++ b/bzrlib/tests/test_versionedfile.py 2009-02-15 21:24:20 +0000
@@ -1279,12 +1279,11 @@
# origin is a fulltext
entries = f.get_record_stream([('origin',)], 'unordered', False)
base = entries.next()
- ft_data = ft_adapter.get_bytes(base, base.get_bytes_as(base.storage_kind))
+ ft_data = ft_adapter.get_bytes(base)
# merged is both a delta and multiple parents.
entries = f.get_record_stream([('merged',)], 'unordered', False)
merged = entries.next()
- delta_data = delta_adapter.get_bytes(merged,
- merged.get_bytes_as(merged.storage_kind))
+ delta_data = delta_adapter.get_bytes(merged)
return ft_data, delta_data
def test_deannotation_noeol(self):
=== modified file 'bzrlib/weave.py'
--- a/bzrlib/weave.py 2008-12-12 14:33:13 +0000
+++ b/bzrlib/weave.py 2009-02-15 21:24:20 +0000
@@ -372,8 +372,7 @@
adapter_factory = adapter_registry.get(adapter_key)
adapter = adapter_factory(self)
adapters[adapter_key] = adapter
- lines = split_lines(adapter.get_bytes(
- record, record.get_bytes_as(record.storage_kind)))
+ lines = split_lines(adapter.get_bytes(record))
try:
self.add_lines(record.key[0], parents, lines)
except RevisionAlreadyPresent:
More information about the bazaar-commits
mailing list