~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/groupcompress.py

  • Committer: Patch Queue Manager
  • Date: 2011-11-18 05:41:48 UTC
  • mfrom: (6257.4.2 remove-pylzma)
  • Revision ID: pqm@pqm.ubuntu.com-20111118054148-blm76siz9s4y51dw
(mbp) remove dead code for lzma compression (Martin Pool)

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
import time
20
20
import zlib
21
 
try:
22
 
    import pylzma
23
 
except ImportError:
24
 
    pylzma = None
25
21
 
26
22
from bzrlib.lazy_import import lazy_import
27
23
lazy_import(globals(), """
57
53
# groupcompress blocks.
58
54
BATCH_SIZE = 2**16
59
55
 
60
 
_USE_LZMA = False and (pylzma is not None)
61
 
 
62
56
# osutils.sha_string('')
63
57
_null_sha1 = 'da39a3ee5e6b4b0d3255bfef95601890afd80709'
64
58
 
153
147
                self._content = ''
154
148
            elif self._compressor_name == 'lzma':
155
149
                # We don't do partial lzma decomp yet
 
150
                import pylzma
156
151
                self._content = pylzma.decompress(z_content)
157
152
            elif self._compressor_name == 'zlib':
158
153
                # Start a zlib decompressor
299
294
        self._content = content
300
295
        self._z_content_chunks = None
301
296
 
302
 
    def _create_z_content_using_lzma(self):
303
 
        if self._content_chunks is not None:
304
 
            self._content = ''.join(self._content_chunks)
305
 
            self._content_chunks = None
306
 
        if self._content is None:
307
 
            raise AssertionError('Nothing to compress')
308
 
        z_content = pylzma.compress(self._content)
309
 
        self._z_content_chunks = (z_content,)
310
 
        self._z_content_length = len(z_content)
311
 
 
312
297
    def _create_z_content_from_chunks(self, chunks):
313
298
        compressor = zlib.compressobj(zlib.Z_DEFAULT_COMPRESSION)
314
299
        # Peak in this point is 1 fulltext, 1 compressed text, + zlib overhead
322
307
    def _create_z_content(self):
323
308
        if self._z_content_chunks is not None:
324
309
            return
325
 
        if _USE_LZMA:
326
 
            self._create_z_content_using_lzma()
327
 
            return
328
310
        if self._content_chunks is not None:
329
311
            chunks = self._content_chunks
330
312
        else:
334
316
    def to_chunks(self):
335
317
        """Create the byte stream as a series of 'chunks'"""
336
318
        self._create_z_content()
337
 
        if _USE_LZMA:
338
 
            header = self.GCB_LZ_HEADER
339
 
        else:
340
 
            header = self.GCB_HEADER
 
319
        header = self.GCB_HEADER
341
320
        chunks = ['%s%d\n%d\n'
342
321
                  % (header, self._z_content_length, self._content_length),
343
322
                 ]