/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tuned_gzip.py

  • Committer: Jelmer Vernooij
  • Date: 2011-12-19 10:58:39 UTC
  • mfrom: (6383 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6386.
  • Revision ID: jelmer@canonical.com-20111219105839-uji05ck4rkm1mj4j
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2006-2011 Canonical Ltd
2
2
# Written by Robert Collins <robert.collins@canonical.com>
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
 
 
18
from __future__ import absolute_import
 
19
 
18
20
"""Bzrlib specific gzip tunings. We plan to feed these to the upstream gzip."""
19
21
 
20
22
from cStringIO import StringIO
27
29
import zlib
28
30
 
29
31
# we want a \n preserved, break on \n only splitlines.
30
 
import bzrlib
 
32
from bzrlib import symbol_versioning
31
33
 
32
34
__all__ = ["GzipFile", "bytes_to_gzip"]
33
35
 
118
120
    Yes, its only 1.6 seconds, but they add up.
119
121
    """
120
122
 
 
123
    def __init__(self, *args, **kwargs):
 
124
        symbol_versioning.warn(
 
125
            symbol_versioning.deprecated_in((2, 3, 0))
 
126
            % 'bzrlib.tuned_gzip.GzipFile',
 
127
            DeprecationWarning, stacklevel=2)
 
128
        gzip.GzipFile.__init__(self, *args, **kwargs)
 
129
 
121
130
    def _add_read_data(self, data):
122
131
        # 4169 calls in 183
123
132
        # temp var for len(data) and switch to +='s.
395
404
        # (4 seconds to 1 seconds for the sample upgrades I was testing).
396
405
        self.write(''.join(lines))
397
406
 
 
407
    if sys.version_info > (2, 7):
 
408
        # As of Python 2.7 the crc32 must be positive when close is called
 
409
        def close(self):
 
410
            if self.fileobj is None:
 
411
                return
 
412
            if self.mode == gzip.WRITE:
 
413
                self.crc &= 0xFFFFFFFFL
 
414
            gzip.GzipFile.close(self)
398
415