Rev 35: Get the tests passing again in http://bazaar.launchpad.net/%7Ebzr/bzr-groupcompress/trunk

John Arbash Meinel john at arbash-meinel.com
Thu Mar 5 17:29:39 GMT 2009


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

------------------------------------------------------------
revno: 35
revision-id: john at arbash-meinel.com-20090305172911-4ajyqk6tt0gd43oe
parent: john at arbash-meinel.com-20090305172017-mefnbegtuk4vt99i
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: trunk
timestamp: Thu 2009-03-05 11:29:11 -0600
message:
  Get the tests passing again
  Also fix the Compressor.extract() for the new changes.
-------------- next part --------------
=== modified file 'groupcompress.py'
--- a/groupcompress.py	2009-03-05 16:52:38 +0000
+++ b/groupcompress.py	2009-03-05 17:29:11 +0000
@@ -165,8 +165,10 @@
         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)
+            zcontent = bytes[pos2+1:]
+            if zcontent:
+                out._content = zlib.decompress(zcontent)
+                out._size = len(out._content)
             return out
         pos = pos2 + 1
         pos2 = pos + z_header_length
@@ -409,12 +411,14 @@
         # TODO: Fix this, we shouldn't really be peeking here
         entry = self._block._entries[key]
         if entry.type == 'fulltext':
-            bytes = stored_bytes
+            assert stored_bytes[0] == 'f'
+            bytes = stored_bytes[1:]
         else:
             assert entry.type == 'delta'
             # XXX: This is inefficient at best
             source = ''.join(self.lines)
-            bytes = _groupcompress_pyx.apply_delta(source, stored_bytes)
+            assert stored_bytes[0] == 'd'
+            bytes = _groupcompress_pyx.apply_delta(source, stored_bytes[1:])
             assert entry.sha1 == sha_string(bytes)
         return bytes, entry.sha1
 

=== modified file 'tests/test_groupcompress.py'
--- a/tests/test_groupcompress.py	2009-03-05 03:29:49 +0000
+++ b/tests/test_groupcompress.py	2009-03-05 17:29:11 +0000
@@ -63,7 +63,7 @@
             'strange\ncommon\n', None)
         self.assertEqual(sha_string('strange\ncommon\n'), sha1)
         expected_lines = [
-            'strange\ncommon\n',
+            'f', 'strange\ncommon\n',
             ]
         self.assertEqual(expected_lines, compressor.lines)
         self.assertEqual(sum(map(len, expected_lines)), end_point)
@@ -95,9 +95,9 @@
                                     'different\n'), sha1_2)
         expected_lines.extend([
             # source and target length
-            '\x34\x36',
+            'd\x35\x36',
             # copy the line common
-            '\x91\x08\x2c', #copy, offset 0x08, len 0x2c
+            '\x91\x09\x2c', #copy, offset 0x09, len 0x2c
             # add the line different, and the trailing newline
             '\x0adifferent\n', # insert 10 bytes
             ])
@@ -122,13 +122,13 @@
                        'different\nmoredifferent\nand then some more\n'),
             sha1_3)
         expected_lines.extend([
-            '\x63\x5f' # source and target length
+            'd\x65\x5f' # source and target length
             # insert new
             '\x03new',
             # Copy of first parent 'common' range
-            '\x91\x07\x31' # copy, offset 0x07, 0x31 bytes
+            '\x91\x08\x31' # copy, offset 0x08, 0x31 bytes
             # Copy of second parent 'different' range
-            '\x91\x38\x2b' # copy, offset 0x38, 0x2b bytes
+            '\x91\x3a\x2b' # copy, offset 0x3a, 0x2b bytes
             ])
         self.assertEqualDiffEncoded(expected_lines, compressor.lines)
         self.assertEqual(sum(map(len, expected_lines)), end_point)



More information about the bazaar-commits mailing list