~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_groupcompress.py

Remove support for passing None for end in GroupCompressBlock.extract.

I decided the removal of the extra int in wire-bytes and indices was not a worthy
trade-off versus the ability to _prepare_for_extract and cheaply filter bytes
during fetch. And it makes the code simpler/easier to maintain.

Also, add support for having a 'empty content' record, which has start=end=0.
Support costs very little, and simplifies things.
And now GroupCompressBlock.extract() just returns the bytes. It doesn't try to
sha the content, nor does it return a GCBEntry. We weren't using it anyway.
And it can save ~50 seconds of sha-ing all the content during 'bzr pack' of
a launchpad branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
329
329
                             'length:100\n'
330
330
                             '\n', raw_bytes)
331
331
 
332
 
    def test_extract_no_end(self):
333
 
        # We should be able to extract a record, even if we only know the start
334
 
        # of the bytes.
335
 
        texts = {
336
 
            ('key1',): 'text for key1\nhas bytes that are common\n',
337
 
            ('key2',): 'text for key2\nhas bytes that are common\n',
338
 
        }
339
 
        entries, block = self.make_block(texts)
340
 
        self.assertEqualDiff('text for key1\nhas bytes that are common\n',
341
 
                             block.extract(('key1',), entries[('key1',)].start,
342
 
                                           end=None)[1])
343
 
        self.assertEqualDiff('text for key2\nhas bytes that are common\n',
344
 
                             block.extract(('key2',), entries[('key2',)].start,
345
 
                                           end=None)[1])
346
 
 
347
332
    def test_partial_decomp(self):
348
333
        content_chunks = []
349
334
        # We need a sufficient amount of data so that zlib.decompress has