# HG changeset patch # User Benoit Boissinot # Date 2005-11-11 23:34:09 # Node ID abfab59fce790a3cc49f4cfa8a42884db2057116 # Parent a208e86bbc34ff49af3ec748f4c8a29696a24b3f add a releasefn keyword to lock.lock releasefn is a function that will be executed when the lock is released diff --git a/mercurial/lock.py b/mercurial/lock.py --- a/mercurial/lock.py +++ b/mercurial/lock.py @@ -12,10 +12,11 @@ class LockHeld(Exception): 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 @@ class lock: def release(self): if self.held: self.held = 0 + if self.releasefn: + self.releasefn() try: os.unlink(self.f) except: pass