Mercurial > public > mercurial-scm > hg-stable
diff mercurial/merge.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 | d8d478f9ee0f |
children | 6169493ac3f9 |
line wrap: on
line diff
--- a/mercurial/merge.py Fri Feb 11 22:24:10 2011 +0800 +++ b/mercurial/merge.py Fri Dec 24 15:23:01 2010 +0100 @@ -32,6 +32,7 @@ else: bits = l[:-1].split("\0") self._state[bits[0]] = bits[1:] + f.close() except IOError, err: if err.errno != errno.ENOENT: raise @@ -42,6 +43,7 @@ f.write(hex(self._local) + "\n") for d, v in self._state.iteritems(): f.write("\0".join([d] + v) + "\n") + f.close() self._dirty = False def add(self, fcl, fco, fca, fd, flags): hash = util.sha1(fcl.path()).hexdigest() @@ -67,6 +69,7 @@ state, hash, lfile, afile, anode, ofile, flags = self._state[dfile] f = self._repo.opener("merge/" + hash) self._repo.wwrite(dfile, f.read(), flags) + f.close() fcd = wctx[dfile] fco = octx[ofile] fca = self._repo.filectx(afile, fileid=anode)