reduce memory used when appendfile appends to real file.
--- 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!)'''