Rev 4013: Handle record streams where a fulltext is obtainable from a record but not the storage_kind. in http://people.ubuntu.com/~robertc/baz2.0/versioned_files.network

Robert Collins robertc at robertcollins.net
Fri Feb 20 06:48:32 GMT 2009


At http://people.ubuntu.com/~robertc/baz2.0/versioned_files.network

------------------------------------------------------------
revno: 4013
revision-id: robertc at robertcollins.net-20090220064830-wyj52q6rl2gygqsa
parent: robertc at robertcollins.net-20090220060022-682t76tgrlj1x0ri
committer: Robert Collins <robertc at robertcollins.net>
branch nick: VersionedFiles.NetworkRecordStream
timestamp: Fri 2009-02-20 17:48:30 +1100
message:
  Handle record streams where a fulltext is obtainable from a record but not the storage_kind.
=== modified file 'bzrlib/knit.py'
--- a/bzrlib/knit.py	2009-02-20 06:00:22 +0000
+++ b/bzrlib/knit.py	2009-02-20 06:48:30 +0000
@@ -1507,18 +1507,20 @@
             elif record.storage_kind == 'chunked':
                 self.add_lines(record.key, parents,
                     osutils.chunks_to_lines(record.get_bytes_as('chunked')))
-            elif record.storage_kind == 'fulltext':
-                self.add_lines(record.key, parents,
-                    split_lines(record.get_bytes_as('fulltext')))
             else:
-                # Not a fulltext, and not suitable for direct insertion as a
+                # Not suitable for direct insertion as a
                 # delta, either because it's not the right format, or this
                 # KnitVersionedFiles doesn't permit deltas (_max_delta_chain ==
                 # 0) or because it depends on a base only present in the
                 # fallback kvfs.
-                adapter_key = record.storage_kind, 'fulltext'
-                adapter = get_adapter(adapter_key)
-                lines = split_lines(adapter.get_bytes(record))
+                try:
+                    # Try getting a fulltext directly from the record.
+                    bytes = record.get_bytes_as('fulltext')
+                except errors.UnavailableRepresentation:
+                    adapter_key = record.storage_kind, 'fulltext'
+                    adapter = get_adapter(adapter_key)
+                    bytes = adapter.get_bytes(record)
+                lines = split_lines(bytes)
                 try:
                     self.add_lines(record.key, parents, lines)
                 except errors.RevisionAlreadyPresent:




More information about the bazaar-commits mailing list