Mercurial > hg
changeset 13382:d747774ca9da
Make sure bundlerepo doesn't leak temp files (issue2491)
Add empty repository.close() and call it in dispatch.
Remove bundlerepository.__del__(), merging it into bundlerepository.close(),
which overrides repository.close().
http://docs.python.org/reference/datamodel.html says:
"It is not guaranteed that __del__() methods are called for objects that
still exist when the interpreter exits."
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Sat, 12 Feb 2011 10:58:11 +0100 |
parents | d073468e3c5f |
children | 70ef5b610222 |
files | mercurial/bundlerepo.py mercurial/dispatch.py mercurial/repo.py tests/test-bundle.t |
diffstat | 4 files changed, 16 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bundlerepo.py Fri Feb 11 19:32:49 2011 +0100 +++ b/mercurial/bundlerepo.py Sat Feb 12 10:58:11 2011 +0100 @@ -251,11 +251,6 @@ self.bundle.close() if self.tempfile is not None: os.unlink(self.tempfile) - - def __del__(self): - del self.bundle - if self.tempfile is not None: - os.unlink(self.tempfile) if self._tempparent: shutil.rmtree(self._tempparent, True)
--- a/mercurial/dispatch.py Fri Feb 11 19:32:49 2011 +0100 +++ b/mercurial/dispatch.py Sat Feb 12 10:58:11 2011 +0100 @@ -589,8 +589,12 @@ msg = ' '.join(' ' in a and repr(a) or a for a in fullargs) ui.log("command", msg + "\n") d = lambda: util.checksignature(func)(ui, *args, **cmdoptions) - return runcommand(lui, repo, cmd, fullargs, ui, options, d, - cmdpats, cmdoptions) + try: + return runcommand(lui, repo, cmd, fullargs, ui, options, d, + cmdpats, cmdoptions) + finally: + if repo: + repo.close() def _runcommand(ui, options, cmd, cmdfunc): def checkargs():
--- a/mercurial/repo.py Fri Feb 11 19:32:49 2011 +0100 +++ b/mercurial/repo.py Sat Feb 12 10:58:11 2011 +0100 @@ -35,3 +35,6 @@ def cancopy(self): return self.local() + + def close(self): + pass
--- a/tests/test-bundle.t Fri Feb 11 19:32:49 2011 +0100 +++ b/tests/test-bundle.t Sat Feb 12 10:58:11 2011 +0100 @@ -188,6 +188,13 @@ date: Thu Jan 01 00:00:00 1970 +0000 summary: 0.0 +Make sure bundlerepo doesn't leak tempfiles (issue2491) + + $ ls .hg + 00changelog.i + cache + requires + store Pull ../full.hg into empty (with hook)