changeset 2236:d7f866789d7e

reduce memory used when appendfile appends to real file.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Tue, 09 May 2006 11:08:06 -0700
parents 457e4247315d
children 4a069064a39b
files mercurial/appendfile.py
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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!)'''