Rev 5596: (jameinel) Stop using bzrlib.tuned_gzip.GzipFile. (John A Meinel) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Jan 12 00:08:45 UTC 2011
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5596 [merge]
revision-id: pqm at pqm.ubuntu.com-20110112000841-bsgwos6fnhv9nlc7
parent: pqm at pqm.ubuntu.com-20110111230209-nlp91k4usdikg3om
parent: john at arbash-meinel.com-20110111204544-xz2j3vw9520nor7l
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2011-01-12 00:08:41 +0000
message:
(jameinel) Stop using bzrlib.tuned_gzip.GzipFile. (John A Meinel)
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/knit.py knit.py-20051212171256-f056ac8f0fbe1bd9
bzrlib/multiparent.py __init__.py-20070410133617-n1jdhcc1n1mibarp-1
bzrlib/repofmt/weaverepo.py presplitout.py-20070125045333-wfav3tsh73oxu3zk-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/tests/per_versionedfile.py test_versionedfile.py-20060222045249-db45c9ed14a1c2e5
bzrlib/tests/test_knit.py test_knit.py-20051212171302-95d4c00dd5f11f2b
bzrlib/tests/test_tuned_gzip.py test_tuned_gzip.py-20060418042056-c576dfc708984968
bzrlib/tuned_gzip.py tuned_gzip.py-20060407014720-5aadc518e928e8d2
doc/en/release-notes/bzr-2.3.txt NEWS-20050323055033-4e00b5db738777ff
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2011-01-11 16:21:00 +0000
+++ b/bzrlib/builtins.py 2011-01-11 20:21:53 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005-2010 Canonical Ltd
+# Copyright (C) 2005-2011 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
=== modified file 'bzrlib/knit.py'
--- a/bzrlib/knit.py 2010-06-04 03:09:35 +0000
+++ b/bzrlib/knit.py 2011-01-11 20:42:36 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2010 Canonical Ltd
+# Copyright (C) 2006-2011 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -54,6 +54,7 @@
from cStringIO import StringIO
from itertools import izip
+import gzip
import operator
import os
import sys
@@ -1879,7 +1880,7 @@
:return: the header and the decompressor stream.
as (stream, header_record)
"""
- df = tuned_gzip.GzipFile(mode='rb', fileobj=StringIO(raw_data))
+ df = gzip.GzipFile(mode='rb', fileobj=StringIO(raw_data))
try:
# Current serialise
rec = self._check_header(key, df.readline())
@@ -1894,7 +1895,7 @@
# 4168 calls in 2880 217 internal
# 4168 calls to _parse_record_header in 2121
# 4168 calls to readlines in 330
- df = tuned_gzip.GzipFile(mode='rb', fileobj=StringIO(data))
+ df = gzip.GzipFile(mode='rb', fileobj=StringIO(data))
try:
record_contents = df.readlines()
except Exception, e:
=== modified file 'bzrlib/multiparent.py'
--- a/bzrlib/multiparent.py 2010-08-11 01:31:11 +0000
+++ b/bzrlib/multiparent.py 2011-01-11 18:48:11 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2007-2010 Canonical Ltd
+# Copyright (C) 2007-2011 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
)
from bzrlib import bencode
""")
-from bzrlib.tuned_gzip import GzipFile
+from gzip import GzipFile
def topo_iter_keys(vf, keys=None):
@@ -564,7 +564,8 @@
zip_file = GzipFile(None, mode='rb', fileobj=sio)
try:
file_version_id = zip_file.readline()
- return MultiParent.from_patch(zip_file.read())
+ content = zip_file.read()
+ return MultiParent.from_patch(content)
finally:
zip_file.close()
=== modified file 'bzrlib/repofmt/weaverepo.py'
--- a/bzrlib/repofmt/weaverepo.py 2010-11-20 21:41:05 +0000
+++ b/bzrlib/repofmt/weaverepo.py 2011-01-11 20:45:44 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2007-2010 Canonical Ltd
+# Copyright (C) 2007-2011 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
ghosts.
"""
+import gzip
import os
from cStringIO import StringIO
import urllib
@@ -40,6 +41,7 @@
lockdir,
osutils,
trace,
+ tuned_gzip,
urlutils,
versionedfile,
weave,
@@ -56,7 +58,6 @@
RepositoryFormat,
)
from bzrlib.store.text import TextStore
-from bzrlib.tuned_gzip import GzipFile, bytes_to_gzip
from bzrlib.versionedfile import (
AbsentContentFactory,
FulltextContentFactory,
@@ -589,7 +590,7 @@
raise ValueError('bad idea to put / in %r' % (key,))
text = ''.join(lines)
if self._compressed:
- text = bytes_to_gzip(text)
+ text = tuned_gzip.bytes_to_gzip(text)
path = self._map(key)
self._transport.put_bytes_non_atomic(path, text, create_parent_dir=True)
@@ -637,7 +638,7 @@
else:
return None
if compressed:
- text = GzipFile(mode='rb', fileobj=StringIO(text)).read()
+ text = gzip.GzipFile(mode='rb', fileobj=StringIO(text)).read()
return text
def _map(self, key):
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2011-01-11 03:28:39 +0000
+++ b/bzrlib/repository.py 2011-01-11 20:21:53 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005-2010 Canonical Ltd
+# Copyright (C) 2005-2011 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
=== modified file 'bzrlib/tests/per_versionedfile.py'
--- a/bzrlib/tests/per_versionedfile.py 2010-12-24 22:40:27 +0000
+++ b/bzrlib/tests/per_versionedfile.py 2011-01-11 17:54:38 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2010 Canonical Ltd
+# Copyright (C) 2006-2011 Canonical Ltd
#
# Authors:
# Johan Rydberg <jrydberg at gnu.org>
@@ -21,6 +21,7 @@
# TODO: might be nice to create a versionedfile with some type of corruption
# considered typical and check that it can be detected/corrected.
+from gzip import GzipFile
from itertools import chain, izip
from StringIO import StringIO
@@ -51,7 +52,6 @@
)
from bzrlib.tests.http_utils import TestCaseWithWebserver
from bzrlib.transport.memory import MemoryTransport
-from bzrlib.tuned_gzip import GzipFile
import bzrlib.versionedfile as versionedfile
from bzrlib.versionedfile import (
ConstantMapper,
=== modified file 'bzrlib/tests/test_knit.py'
--- a/bzrlib/tests/test_knit.py 2010-06-20 11:18:38 +0000
+++ b/bzrlib/tests/test_knit.py 2011-01-11 17:54:38 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2010 Canonical Ltd
+# Copyright (C) 2006-2011 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -17,6 +17,7 @@
"""Tests for Knit data structure"""
from cStringIO import StringIO
+import gzip
import sys
from bzrlib import (
@@ -27,7 +28,6 @@
pack,
tests,
transport,
- tuned_gzip,
)
from bzrlib.errors import (
KnitHeaderError,
@@ -692,7 +692,7 @@
def create_gz_content(self, text):
sio = StringIO()
- gz_file = tuned_gzip.GzipFile(mode='wb', fileobj=sio)
+ gz_file = gzip.GzipFile(mode='wb', fileobj=sio)
gz_file.write(text)
gz_file.close()
return sio.getvalue()
=== modified file 'bzrlib/tests/test_tuned_gzip.py'
--- a/bzrlib/tests/test_tuned_gzip.py 2010-09-25 20:08:01 +0000
+++ b/bzrlib/tests/test_tuned_gzip.py 2011-01-11 18:10:55 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006, 2009, 2010 Canonical Ltd
+# Copyright (C) 2006, 2009, 2010, 2011 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -21,11 +21,14 @@
# do not use bzrlib test cases here - this should be suitable for sending
# upstream.
from cStringIO import StringIO
-from unittest import TestCase
import zlib
-from bzrlib import tuned_gzip
+from bzrlib import (
+ symbol_versioning,
+ tuned_gzip,
+ tests,
+ )
class FakeDecompress(object):
@@ -42,7 +45,7 @@
return ''
-class TestFakeDecompress(TestCase):
+class TestFakeDecompress(tests.TestCase):
"""We use a fake decompressor to test GzipFile.
This class tests the behaviours we want from it.
@@ -67,14 +70,16 @@
self.assertEqual('1234567', decompress.unused_data)
-class TestGzip(TestCase):
+class TestGzip(tests.TestCase):
def test__read_short_remainder(self):
# a _read call at the end of a compressed hunk should
# read more bytes if there is less than 8 bytes (the
# gzip trailer) unread.
stream = StringIO('\0\0\0\0\0\0\0\0')
- myfile = tuned_gzip.GzipFile(fileobj=stream)
+ myfile = self.applyDeprecated(
+ symbol_versioning.deprecated_in((2, 3, 0)),
+ tuned_gzip.GzipFile, fileobj=stream)
# disable the _new_member check, we are microtesting.
myfile._new_member = False
myfile.crc = zlib.crc32('')
@@ -89,21 +94,25 @@
def test_negative_crc(self):
"""Content with a negative crc should not break when written"""
sio = StringIO()
- gfile = tuned_gzip.GzipFile(mode="w", fileobj=sio)
+ gfile = self.applyDeprecated(
+ symbol_versioning.deprecated_in((2, 3, 0)),
+ tuned_gzip.GzipFile, mode="w", fileobj=sio)
gfile.write("\xFF")
gfile.close()
self.assertEqual(gfile.crc & 0xFFFFFFFFL, 0xFF000000L)
self.assertEqual(sio.getvalue()[-8:-4], "\x00\x00\x00\xFF")
-class TestToGzip(TestCase):
+class TestToGzip(tests.TestCase):
def assertToGzip(self, chunks):
bytes = ''.join(chunks)
gzfromchunks = tuned_gzip.chunks_to_gzip(chunks)
gzfrombytes = tuned_gzip.bytes_to_gzip(bytes)
self.assertEqual(gzfrombytes, gzfromchunks)
- decoded = tuned_gzip.GzipFile(fileobj=StringIO(gzfromchunks)).read()
+ decoded = self.applyDeprecated(
+ symbol_versioning.deprecated_in((2, 3, 0)),
+ tuned_gzip.GzipFile, fileobj=StringIO(gzfromchunks)).read()
self.assertEqual(bytes, decoded)
def test_single_chunk(self):
=== modified file 'bzrlib/tuned_gzip.py'
--- a/bzrlib/tuned_gzip.py 2010-09-25 20:08:01 +0000
+++ b/bzrlib/tuned_gzip.py 2011-01-11 18:10:55 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2010 Canonical Ltd
+# Copyright (C) 2006-2011 Canonical Ltd
# Written by Robert Collins <robert.collins at canonical.com>
#
# This program is free software; you can redistribute it and/or modify
@@ -27,7 +27,7 @@
import zlib
# we want a \n preserved, break on \n only splitlines.
-import bzrlib
+from bzrlib import symbol_versioning
__all__ = ["GzipFile", "bytes_to_gzip"]
@@ -118,6 +118,13 @@
Yes, its only 1.6 seconds, but they add up.
"""
+ def __init__(self, *args, **kwargs):
+ symbol_versioning.warn(
+ symbol_versioning.deprecated_in((2, 3, 0))
+ % 'bzrlib.tuned_gzip.GzipFile',
+ DeprecationWarning, stacklevel=2)
+ gzip.GzipFile.__init__(self, *args, **kwargs)
+
def _add_read_data(self, data):
# 4169 calls in 183
# temp var for len(data) and switch to +='s.
=== modified file 'doc/en/release-notes/bzr-2.3.txt'
--- a/doc/en/release-notes/bzr-2.3.txt 2011-01-11 20:20:13 +0000
+++ b/doc/en/release-notes/bzr-2.3.txt 2011-01-12 00:08:41 +0000
@@ -69,6 +69,11 @@
trying to set the tags in the master branch. This had been broken by the
bug fix for bug #603395. (John Arbash Meinel, #701212)
+* Stop using ``bzrlib.tuned_gzip.GzipFile``. It is incompatible with
+ python-2.7 and was only used for Knit format repositories, which haven't
+ been recommended since 2007. The file itself will be removed in the next
+ release. (John Arbash Meinel)
+
Documentation
*************
@@ -91,6 +96,10 @@
already opened that repository). Implementations of these APIs will
need to be updated to accept these arguments. (Andrew Bennetts)
+* ``bzrlib.tuned_gzip.GzipFile`` is now deprecated and will be removed in
+ the bzr-2.4 series. Code that was using it can just use the python
+ stdlib ``gzip.GzipFile``. (John Arbash Meinel)
+
Internals
*********
More information about the bazaar-commits
mailing list