Merge lp:~jameinel/bzr/2.3-gzip-py2.7 into lp:bzr

Proposed by John A Meinel
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: no longer in the source branch.
Merged at revision: 5596
Proposed branch: lp:~jameinel/bzr/2.3-gzip-py2.7
Merge into: lp:bzr
Diff against target: 340 lines (+56/-28)
10 files modified
bzrlib/builtins.py (+1/-1)
bzrlib/knit.py (+4/-3)
bzrlib/multiparent.py (+4/-3)
bzrlib/repofmt/weaverepo.py (+5/-4)
bzrlib/repository.py (+1/-1)
bzrlib/tests/per_versionedfile.py (+2/-2)
bzrlib/tests/test_knit.py (+3/-3)
bzrlib/tests/test_tuned_gzip.py (+18/-9)
bzrlib/tuned_gzip.py (+9/-2)
doc/en/release-notes/bzr-2.3.txt (+9/-0)
To merge this branch: bzr merge lp:~jameinel/bzr/2.3-gzip-py2.7
Reviewer Review Type Date Requested Status
Vincent Ladeuil Needs Fixing
Review via email: mp+45896@code.launchpad.net

Commit message

Stop using bzrlib.tuned_gzip.GzipFile.

Description of the change

This removes our use of tuned_gzip.GzipFile. It seems to be broken in python-2.7. We also only use it for Knit format repositories. And we introduced packs back in 2007. So I'm not too concerned about performance tuning 3-year-old deprecated formats.

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote :

Great !

Not being concerned about performance doesn't imply forcing people under pdb though, so may be we can do without the pdb.set_trace() ;)

23 - return MultiParent.from_patch(zip_file.read())
24 + import pdb; pdb.set_trace()
25 + content = zip_file.read()
26 + return MultiParent.from_patch(content)

Apart from that: approve

review: Needs Fixing
Revision history for this message
John A Meinel (jameinel) wrote :

sent to pqm by email

Revision history for this message
John A Meinel (jameinel) wrote :

sent to pqm by email

Revision history for this message
John A Meinel (jameinel) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/builtins.py'
2--- bzrlib/builtins.py 2011-01-11 16:21:00 +0000
3+++ bzrlib/builtins.py 2011-01-11 20:49:28 +0000
4@@ -1,4 +1,4 @@
5-# Copyright (C) 2005-2010 Canonical Ltd
6+# Copyright (C) 2005-2011 Canonical Ltd
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10
11=== modified file 'bzrlib/knit.py'
12--- bzrlib/knit.py 2010-06-04 03:09:35 +0000
13+++ bzrlib/knit.py 2011-01-11 20:49:28 +0000
14@@ -1,4 +1,4 @@
15-# Copyright (C) 2006-2010 Canonical Ltd
16+# Copyright (C) 2006-2011 Canonical Ltd
17 #
18 # This program is free software; you can redistribute it and/or modify
19 # it under the terms of the GNU General Public License as published by
20@@ -54,6 +54,7 @@
21
22 from cStringIO import StringIO
23 from itertools import izip
24+import gzip
25 import operator
26 import os
27 import sys
28@@ -1879,7 +1880,7 @@
29 :return: the header and the decompressor stream.
30 as (stream, header_record)
31 """
32- df = tuned_gzip.GzipFile(mode='rb', fileobj=StringIO(raw_data))
33+ df = gzip.GzipFile(mode='rb', fileobj=StringIO(raw_data))
34 try:
35 # Current serialise
36 rec = self._check_header(key, df.readline())
37@@ -1894,7 +1895,7 @@
38 # 4168 calls in 2880 217 internal
39 # 4168 calls to _parse_record_header in 2121
40 # 4168 calls to readlines in 330
41- df = tuned_gzip.GzipFile(mode='rb', fileobj=StringIO(data))
42+ df = gzip.GzipFile(mode='rb', fileobj=StringIO(data))
43 try:
44 record_contents = df.readlines()
45 except Exception, e:
46
47=== modified file 'bzrlib/multiparent.py'
48--- bzrlib/multiparent.py 2010-08-11 01:31:11 +0000
49+++ bzrlib/multiparent.py 2011-01-11 20:49:28 +0000
50@@ -1,4 +1,4 @@
51-# Copyright (C) 2007-2010 Canonical Ltd
52+# Copyright (C) 2007-2011 Canonical Ltd
53 #
54 # This program is free software; you can redistribute it and/or modify
55 # it under the terms of the GNU General Public License as published by
56@@ -30,7 +30,7 @@
57 )
58 from bzrlib import bencode
59 """)
60-from bzrlib.tuned_gzip import GzipFile
61+from gzip import GzipFile
62
63
64 def topo_iter_keys(vf, keys=None):
65@@ -564,7 +564,8 @@
66 zip_file = GzipFile(None, mode='rb', fileobj=sio)
67 try:
68 file_version_id = zip_file.readline()
69- return MultiParent.from_patch(zip_file.read())
70+ content = zip_file.read()
71+ return MultiParent.from_patch(content)
72 finally:
73 zip_file.close()
74
75
76=== modified file 'bzrlib/repofmt/weaverepo.py'
77--- bzrlib/repofmt/weaverepo.py 2010-11-20 21:41:05 +0000
78+++ bzrlib/repofmt/weaverepo.py 2011-01-11 20:49:28 +0000
79@@ -1,4 +1,4 @@
80-# Copyright (C) 2007-2010 Canonical Ltd
81+# Copyright (C) 2007-2011 Canonical Ltd
82 #
83 # This program is free software; you can redistribute it and/or modify
84 # it under the terms of the GNU General Public License as published by
85@@ -20,6 +20,7 @@
86 ghosts.
87 """
88
89+import gzip
90 import os
91 from cStringIO import StringIO
92 import urllib
93@@ -40,6 +41,7 @@
94 lockdir,
95 osutils,
96 trace,
97+ tuned_gzip,
98 urlutils,
99 versionedfile,
100 weave,
101@@ -56,7 +58,6 @@
102 RepositoryFormat,
103 )
104 from bzrlib.store.text import TextStore
105-from bzrlib.tuned_gzip import GzipFile, bytes_to_gzip
106 from bzrlib.versionedfile import (
107 AbsentContentFactory,
108 FulltextContentFactory,
109@@ -589,7 +590,7 @@
110 raise ValueError('bad idea to put / in %r' % (key,))
111 text = ''.join(lines)
112 if self._compressed:
113- text = bytes_to_gzip(text)
114+ text = tuned_gzip.bytes_to_gzip(text)
115 path = self._map(key)
116 self._transport.put_bytes_non_atomic(path, text, create_parent_dir=True)
117
118@@ -637,7 +638,7 @@
119 else:
120 return None
121 if compressed:
122- text = GzipFile(mode='rb', fileobj=StringIO(text)).read()
123+ text = gzip.GzipFile(mode='rb', fileobj=StringIO(text)).read()
124 return text
125
126 def _map(self, key):
127
128=== modified file 'bzrlib/repository.py'
129--- bzrlib/repository.py 2011-01-11 03:28:39 +0000
130+++ bzrlib/repository.py 2011-01-11 20:49:28 +0000
131@@ -1,4 +1,4 @@
132-# Copyright (C) 2005-2010 Canonical Ltd
133+# Copyright (C) 2005-2011 Canonical Ltd
134 #
135 # This program is free software; you can redistribute it and/or modify
136 # it under the terms of the GNU General Public License as published by
137
138=== modified file 'bzrlib/tests/per_versionedfile.py'
139--- bzrlib/tests/per_versionedfile.py 2010-12-24 22:40:27 +0000
140+++ bzrlib/tests/per_versionedfile.py 2011-01-11 20:49:28 +0000
141@@ -1,4 +1,4 @@
142-# Copyright (C) 2006-2010 Canonical Ltd
143+# Copyright (C) 2006-2011 Canonical Ltd
144 #
145 # Authors:
146 # Johan Rydberg <jrydberg@gnu.org>
147@@ -21,6 +21,7 @@
148 # TODO: might be nice to create a versionedfile with some type of corruption
149 # considered typical and check that it can be detected/corrected.
150
151+from gzip import GzipFile
152 from itertools import chain, izip
153 from StringIO import StringIO
154
155@@ -51,7 +52,6 @@
156 )
157 from bzrlib.tests.http_utils import TestCaseWithWebserver
158 from bzrlib.transport.memory import MemoryTransport
159-from bzrlib.tuned_gzip import GzipFile
160 import bzrlib.versionedfile as versionedfile
161 from bzrlib.versionedfile import (
162 ConstantMapper,
163
164=== modified file 'bzrlib/tests/test_knit.py'
165--- bzrlib/tests/test_knit.py 2010-06-20 11:18:38 +0000
166+++ bzrlib/tests/test_knit.py 2011-01-11 20:49:28 +0000
167@@ -1,4 +1,4 @@
168-# Copyright (C) 2006-2010 Canonical Ltd
169+# Copyright (C) 2006-2011 Canonical Ltd
170 #
171 # This program is free software; you can redistribute it and/or modify
172 # it under the terms of the GNU General Public License as published by
173@@ -17,6 +17,7 @@
174 """Tests for Knit data structure"""
175
176 from cStringIO import StringIO
177+import gzip
178 import sys
179
180 from bzrlib import (
181@@ -27,7 +28,6 @@
182 pack,
183 tests,
184 transport,
185- tuned_gzip,
186 )
187 from bzrlib.errors import (
188 KnitHeaderError,
189@@ -692,7 +692,7 @@
190
191 def create_gz_content(self, text):
192 sio = StringIO()
193- gz_file = tuned_gzip.GzipFile(mode='wb', fileobj=sio)
194+ gz_file = gzip.GzipFile(mode='wb', fileobj=sio)
195 gz_file.write(text)
196 gz_file.close()
197 return sio.getvalue()
198
199=== modified file 'bzrlib/tests/test_tuned_gzip.py'
200--- bzrlib/tests/test_tuned_gzip.py 2010-09-25 20:08:01 +0000
201+++ bzrlib/tests/test_tuned_gzip.py 2011-01-11 20:49:28 +0000
202@@ -1,4 +1,4 @@
203-# Copyright (C) 2006, 2009, 2010 Canonical Ltd
204+# Copyright (C) 2006, 2009, 2010, 2011 Canonical Ltd
205 #
206 # This program is free software; you can redistribute it and/or modify
207 # it under the terms of the GNU General Public License as published by
208@@ -21,11 +21,14 @@
209 # do not use bzrlib test cases here - this should be suitable for sending
210 # upstream.
211 from cStringIO import StringIO
212-from unittest import TestCase
213 import zlib
214
215
216-from bzrlib import tuned_gzip
217+from bzrlib import (
218+ symbol_versioning,
219+ tuned_gzip,
220+ tests,
221+ )
222
223
224 class FakeDecompress(object):
225@@ -42,7 +45,7 @@
226 return ''
227
228
229-class TestFakeDecompress(TestCase):
230+class TestFakeDecompress(tests.TestCase):
231 """We use a fake decompressor to test GzipFile.
232
233 This class tests the behaviours we want from it.
234@@ -67,14 +70,16 @@
235 self.assertEqual('1234567', decompress.unused_data)
236
237
238-class TestGzip(TestCase):
239+class TestGzip(tests.TestCase):
240
241 def test__read_short_remainder(self):
242 # a _read call at the end of a compressed hunk should
243 # read more bytes if there is less than 8 bytes (the
244 # gzip trailer) unread.
245 stream = StringIO('\0\0\0\0\0\0\0\0')
246- myfile = tuned_gzip.GzipFile(fileobj=stream)
247+ myfile = self.applyDeprecated(
248+ symbol_versioning.deprecated_in((2, 3, 0)),
249+ tuned_gzip.GzipFile, fileobj=stream)
250 # disable the _new_member check, we are microtesting.
251 myfile._new_member = False
252 myfile.crc = zlib.crc32('')
253@@ -89,21 +94,25 @@
254 def test_negative_crc(self):
255 """Content with a negative crc should not break when written"""
256 sio = StringIO()
257- gfile = tuned_gzip.GzipFile(mode="w", fileobj=sio)
258+ gfile = self.applyDeprecated(
259+ symbol_versioning.deprecated_in((2, 3, 0)),
260+ tuned_gzip.GzipFile, mode="w", fileobj=sio)
261 gfile.write("\xFF")
262 gfile.close()
263 self.assertEqual(gfile.crc & 0xFFFFFFFFL, 0xFF000000L)
264 self.assertEqual(sio.getvalue()[-8:-4], "\x00\x00\x00\xFF")
265
266
267-class TestToGzip(TestCase):
268+class TestToGzip(tests.TestCase):
269
270 def assertToGzip(self, chunks):
271 bytes = ''.join(chunks)
272 gzfromchunks = tuned_gzip.chunks_to_gzip(chunks)
273 gzfrombytes = tuned_gzip.bytes_to_gzip(bytes)
274 self.assertEqual(gzfrombytes, gzfromchunks)
275- decoded = tuned_gzip.GzipFile(fileobj=StringIO(gzfromchunks)).read()
276+ decoded = self.applyDeprecated(
277+ symbol_versioning.deprecated_in((2, 3, 0)),
278+ tuned_gzip.GzipFile, fileobj=StringIO(gzfromchunks)).read()
279 self.assertEqual(bytes, decoded)
280
281 def test_single_chunk(self):
282
283=== modified file 'bzrlib/tuned_gzip.py'
284--- bzrlib/tuned_gzip.py 2010-09-25 20:08:01 +0000
285+++ bzrlib/tuned_gzip.py 2011-01-11 20:49:28 +0000
286@@ -1,4 +1,4 @@
287-# Copyright (C) 2006-2010 Canonical Ltd
288+# Copyright (C) 2006-2011 Canonical Ltd
289 # Written by Robert Collins <robert.collins@canonical.com>
290 #
291 # This program is free software; you can redistribute it and/or modify
292@@ -27,7 +27,7 @@
293 import zlib
294
295 # we want a \n preserved, break on \n only splitlines.
296-import bzrlib
297+from bzrlib import symbol_versioning
298
299 __all__ = ["GzipFile", "bytes_to_gzip"]
300
301@@ -118,6 +118,13 @@
302 Yes, its only 1.6 seconds, but they add up.
303 """
304
305+ def __init__(self, *args, **kwargs):
306+ symbol_versioning.warn(
307+ symbol_versioning.deprecated_in((2, 3, 0))
308+ % 'bzrlib.tuned_gzip.GzipFile',
309+ DeprecationWarning, stacklevel=2)
310+ gzip.GzipFile.__init__(self, *args, **kwargs)
311+
312 def _add_read_data(self, data):
313 # 4169 calls in 183
314 # temp var for len(data) and switch to +='s.
315
316=== modified file 'doc/en/release-notes/bzr-2.3.txt'
317--- doc/en/release-notes/bzr-2.3.txt 2011-01-11 20:10:31 +0000
318+++ doc/en/release-notes/bzr-2.3.txt 2011-01-11 20:49:28 +0000
319@@ -66,6 +66,11 @@
320 trying to set the tags in the master branch. This had been broken by the
321 bug fix for bug #603395. (John Arbash Meinel, #701212)
322
323+* Stop using ``bzrlib.tuned_gzip.GzipFile``. It is incompatible with
324+ python-2.7 and was only used for Knit format repositories, which haven't
325+ been recommended since 2007. The file itself will be removed in the next
326+ release. (John Arbash Meinel)
327+
328 Documentation
329 *************
330
331@@ -88,6 +93,10 @@
332 already opened that repository). Implementations of these APIs will
333 need to be updated to accept these arguments. (Andrew Bennetts)
334
335+* ``bzrlib.tuned_gzip.GzipFile`` is now deprecated and will be removed in
336+ the bzr-2.4 series. Code that was using it can just use the python
337+ stdlib ``gzip.GzipFile``. (John Arbash Meinel)
338+
339 Internals
340 *********
341