# HG changeset patch # User Vadim Gelfer # Date 2006-05-09 18:08:06 # Node ID d7f866789d7ebac94ba671af46368372ead99b54 # Parent 457e4247315d610182d426ef8c23db718b8f032e reduce memory used when appendfile appends to real file. diff --git a/mercurial/appendfile.py b/mercurial/appendfile.py --- a/mercurial/appendfile.py +++ b/mercurial/appendfile.py @@ -130,14 +130,14 @@ class appendopener(object): 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!)'''