Mercurial > hg
changeset 1530:abfab59fce79
add a releasefn keyword to lock.lock
releasefn is a function that will be executed when the lock is released
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Fri, 11 Nov 2005 15:34:09 -0800 |
parents | a208e86bbc34 |
children | 2ba8bf7defda |
files | mercurial/lock.py |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/lock.py Fri Nov 11 15:34:06 2005 -0800 +++ b/mercurial/lock.py Fri Nov 11 15:34:09 2005 -0800 @@ -12,10 +12,11 @@ pass class lock: - def __init__(self, file, wait=1): + def __init__(self, file, wait=1, releasefn=None): self.f = file self.held = 0 self.wait = wait + self.releasefn = releasefn self.lock() def __del__(self): @@ -43,6 +44,8 @@ def release(self): if self.held: self.held = 0 + if self.releasefn: + self.releasefn() try: os.unlink(self.f) except: pass