reduce memory used when appendfile appends to real file.
authorVadim Gelfer <vadim.gelfer@gmail.com>
Tue, 09 May 2006 11:08:06 -0700
changeset 2236 d7f866789d7e
parent 2235 457e4247315d
child 2237 4a069064a39b
reduce memory used when appendfile appends to real file.
mercurial/appendfile.py
--- a/mercurial/appendfile.py	Tue May 09 18:03:15 2006 +0200
+++ b/mercurial/appendfile.py	Tue May 09 11:08:06 2006 -0700
@@ -130,14 +130,14 @@
         tmpnames = self.tmpnames.items()
         tmpnames.sort()
         for name, tmpname in tmpnames:
-            fp = open(tmpname, 'rb')
-            s = fp.read()
-            fp.close()
+            ifp = open(tmpname, 'rb')
+            ofp = self.realopener(name, 'a')
+            for chunk in util.filechunkiter(ifp):
+                ofp.write(chunk)
+            ifp.close()
             os.unlink(tmpname)
             del self.tmpnames[name]
-            fp = self.realopener(name, 'a')
-            fp.write(s)
-            fp.close()
+            ofp.close()
 
     def cleanup(self):
         '''delete temp files (this discards unwritten data!)'''