add a releasefn keyword to lock.lock
releasefn is a function that will be executed when the lock is released
--- 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