Mercurial > public > mercurial-scm > hg-stable
diff mercurial/dirstate.py @ 14168:135e244776f0
prevent transient leaks of file handle by using new helper functions
These leaks may occur in environments that don't employ a reference
counting GC, i.e. PyPy.
This implies:
- changing opener(...).read() calls to opener.read(...)
- changing opener(...).write() calls to opener.write(...)
- changing open(...).read(...) to util.readfile(...)
- changing open(...).write(...) to util.writefile(...)
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Mon, 02 May 2011 10:11:18 +0200 |
parents | 23f2736abce3 |
children | 38af0f514134 |
line wrap: on
line diff
--- a/mercurial/dirstate.py Mon May 02 10:11:05 2011 +0200 +++ b/mercurial/dirstate.py Mon May 02 10:11:18 2011 +0200 @@ -74,7 +74,7 @@ @propertycache def _branch(self): try: - return self._opener("branch").read().strip() or "default" + return self._opener.read("branch").strip() or "default" except IOError: return "default" @@ -220,13 +220,13 @@ if branch in ['tip', '.', 'null']: raise util.Abort(_('the name \'%s\' is reserved') % branch) self._branch = encoding.fromlocal(branch) - self._opener("branch", "w").write(self._branch + '\n') + self._opener.write("branch", self._branch + '\n') def _read(self): self._map = {} self._copymap = {} try: - st = self._opener("dirstate").read() + st = self._opener.read("dirstate") except IOError, err: if err.errno != errno.ENOENT: raise