Rev 45: bring back the code that handles _NO_LABELS. in http://bazaar.launchpad.net/%7Ebzr/bzr-groupcompress/internal_index

John Arbash Meinel john at arbash-meinel.com
Thu Mar 5 04:26:32 GMT 2009


At http://bazaar.launchpad.net/%7Ebzr/bzr-groupcompress/internal_index

------------------------------------------------------------
revno: 45
revision-id: john at arbash-meinel.com-20090305042604-9d9sl2idrw3lvlqu
parent: john at arbash-meinel.com-20090305040549-1egrt0x9kqzl3d7j
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: internal_index
timestamp: Wed 2009-03-04 22:26:04 -0600
message:
  bring back the code that handles _NO_LABELS.
  Basically, we omit the header, and just hold the content.
  This drops the chk from 1.5MB => 1.1MB, and the texts from 8.1=>7.7
-------------- next part --------------
=== modified file 'groupcompress.py'
--- a/groupcompress.py	2009-03-05 04:05:49 +0000
+++ b/groupcompress.py	2009-03-05 04:26:04 +0000
@@ -165,6 +165,8 @@
         header_length = int(bytes[pos:pos2])
         if z_header_length == 0:
             assert header_length == 0
+            out._content = zlib.decompress(bytes[pos2+1:])
+            out._size = len(out._content)
             return out
         pos = pos2 + 1
         pos2 = pos + z_header_length
@@ -207,6 +209,20 @@
         :param sha1: TODO (should we validate only when sha1 is supplied?)
         :return: The bytes for the content
         """
+        if _NO_LABELS:
+            start, end = index_memo[3:5]
+            c = self._content[start]
+            if c == 'f':
+                bytes = self._content[start+1:end]
+                type = 'fulltext'
+            else:
+                assert c == 'd'
+                type = 'delta'
+                delta = self._content[start+1:end]
+                bytes = _groupcompress_pyx.apply_delta(self._content, delta)
+            entry = GroupCompressBlockEntry(key, type, sha_string(bytes),
+                                            start, end-start)
+            return entry, bytes
         entry = self._entries[key]
         if entry.type == 'fulltext':
             assert self._content[entry.start] == 'f'
@@ -267,6 +283,11 @@
         z_bytes.append(c.flush(zlib.Z_SYNC_FLUSH))
         z_len = sum(map(len, z_bytes))
         c_len = len(content)
+        if _NO_LABELS:
+            z_bytes = []
+            z_len = 0
+            info_len = 0
+            c = zlib.compressobj()
         z_bytes.append(c.compress(content))
         z_bytes.append(c.flush())
         chunks = [self.GCB_HEADER,



More information about the bazaar-commits mailing list