Rev 6450: (jelmer) Avoid caching complete files in memory when accessing over HTTP. in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/

Patch Queue Manager pqm at pqm.ubuntu.com
Sat Jan 28 02:39:17 UTC 2012


At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 6450 [merge]
revision-id: pqm at pqm.ubuntu.com-20120128023916-3eosqh9rfscupjb0
parent: pqm at pqm.ubuntu.com-20120127201913-dod5friqxdsfru9w
parent: jelmer at samba.org-20120128021019-047mhvjsr9t72xfi
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Sat 2012-01-28 02:39:16 +0000
message:
  (jelmer) Avoid caching complete files in memory when accessing over HTTP.
   (Jelmer Vernooij)
modified:
  bzrlib/transport/http/__init__.py http_transport.py-20050711212304-506c5fd1059ace96
  bzrlib/transport/http/response.py _response.py-20060613154423-a2ci7hd4iw5c7fnt-1
  bzrlib/weave.py                knit.py-20050627021749-759c29984154256b
=== modified file 'bzrlib/transport/http/__init__.py'
--- a/bzrlib/transport/http/__init__.py	2011-12-19 13:23:58 +0000
+++ b/bzrlib/transport/http/__init__.py	2012-01-27 19:05:33 +0000
@@ -21,7 +21,6 @@
 
 from __future__ import absolute_import
 
-from cStringIO import StringIO
 import re
 import urlparse
 import sys
@@ -119,12 +118,7 @@
         :param relpath: The relative path to the file
         """
         code, response_file = self._get(relpath, None)
-        # FIXME: some callers want an iterable... One step forward, three steps
-        # backwards :-/ And not only an iterable, but an iterable that can be
-        # seeked backwards, so we will never be able to do that.  One such
-        # known client is bzrlib.bundle.serializer.v4.get_bundle_reader. At the
-        # time of this writing it's even the only known client -- vila20071203
-        return StringIO(response_file.read())
+        return response_file
 
     def _get(self, relpath, ranges, tail_amount=0):
         """Get a file, or part of a file.

=== modified file 'bzrlib/transport/http/response.py'
--- a/bzrlib/transport/http/response.py	2011-12-19 13:23:58 +0000
+++ b/bzrlib/transport/http/response.py	2012-01-23 20:10:03 +0000
@@ -82,6 +82,12 @@
         # Default to the whole file of unspecified size
         self.set_range(0, -1)
 
+    def close(self):
+        """Close this file.
+
+        Dummy implementation for consistency with the 'file' API.
+        """
+
     def set_range(self, start, size):
         """Change the range mapping"""
         self._start = start

=== modified file 'bzrlib/weave.py'
--- a/bzrlib/weave.py	2011-12-19 13:23:58 +0000
+++ b/bzrlib/weave.py	2012-01-28 02:10:19 +0000
@@ -920,7 +920,8 @@
         self._transport = transport
         self._filemode = filemode
         try:
-            _read_weave_v5(self._transport.get(name + WeaveFile.WEAVE_SUFFIX), self)
+            f = self._transport.get(name + WeaveFile.WEAVE_SUFFIX)
+            _read_weave_v5(StringIO(f.read()), self)
         except errors.NoSuchFile:
             if not create:
                 raise




More information about the bazaar-commits mailing list