[BUG] transport/memory.py doesn't handle strings

Robey Pointer robey at lag.net
Wed Oct 19 20:06:57 BST 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On 18 Oct 2005, at 23:17, Aaron Bentley wrote:

>> Yuck. :(  My coworkershave been known to checkin 100+MB tarballs,  
>> and you don't want to  load that all into memory at once.
>
> We already do.  Look at osutils.pumpfile.

Ouch!  Well just to prove that I'm not always just sniping from the  
sidelines, here's a small patch to fix that one. :)

robey


=== modified file 'bzrlib/osutils.py'
- --- bzrlib/osutils.py
+++ bzrlib/osutils.py
@@ -224,9 +224,16 @@
          return False


+def filereader(f, blocksize=128*1024):
+    x = f.read(blocksize)
+    while x != '':
+        yield x
+        x = f.read(blocksize)
+
   def pumpfile(fromfile, tofile):
      """Copy contents of one file to another."""
- -    tofile.write(fromfile.read())
+    for block in filereader(fromfile):
+        tofile.write(block)


  def sha_file(f):

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Darwin)

iD8DBQFDVplVQQDkKvyJ6cMRAuoCAJ9GY3ab0Nw2Q4sqOUBk0McZqb8hAgCdG4T2
lhsFmIRvdU8NZM4WYnuPJNQ=
=1ukX
-----END PGP SIGNATURE-----




More information about the bazaar mailing list