Mercurial > public > mercurial-scm > hg-stable
diff mercurial/revlog.py @ 13400:14f3795a5ed7
explicitly close files
Add missing calls to close() to many places where files are
opened. Relying on reference counting to catch them soon-ish is not
portable and fails in environments with a proper GC, such as PyPy.
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Fri, 24 Dec 2010 15:23:01 +0100 |
parents | 77351c88dd10 |
children | b51bf961b3cb |
line wrap: on
line diff
--- a/mercurial/revlog.py Fri Feb 11 22:24:10 2011 +0800 +++ b/mercurial/revlog.py Fri Dec 24 15:23:01 2010 +0100 @@ -243,6 +243,7 @@ try: f = self.opener(self.indexfile) i = f.read() + f.close() if len(i) > 0: v = struct.unpack(versionformat, i[:4])[0] except IOError, inst: @@ -1167,6 +1168,7 @@ if not dfh and not self._inline: # addrevision switched from inline to conventional # reopen the index + ifh.close() dfh = self.opener(self.datafile, "a") ifh = self.opener(self.indexfile, "a") finally: @@ -1226,6 +1228,7 @@ f = self.opener(self.datafile) f.seek(0, 2) actual = f.tell() + f.close() dd = actual - expected except IOError, inst: if inst.errno != errno.ENOENT: @@ -1236,6 +1239,7 @@ f = self.opener(self.indexfile) f.seek(0, 2) actual = f.tell() + f.close() s = self._io.size i = max(0, actual // s) di = actual - (i * s)