comparison mercurial/lock.py @ 26321:db4c192cb9b3

lock: move acquirefn call to inside the lock We're going to need to call it again as part of reinitialization after a subprocess inherits the lock.
author Siddharth Agarwal <sid0@fb.com>
date Tue, 22 Sep 2015 14:09:42 -0700
parents 1d33842c5b3e
children 927fa07a2ba4
comparison
equal deleted inserted replaced
26320:3ac7acb99b04 26321:db4c192cb9b3
36 # old-style lock: symlink to pid 36 # old-style lock: symlink to pid
37 # new-style lock: symlink to hostname:pid 37 # new-style lock: symlink to hostname:pid
38 38
39 _host = None 39 _host = None
40 40
41 def __init__(self, vfs, file, timeout=-1, releasefn=None, desc=None): 41 def __init__(self, vfs, file, timeout=-1, releasefn=None, acquirefn=None,
42 desc=None):
42 self.vfs = vfs 43 self.vfs = vfs
43 self.f = file 44 self.f = file
44 self.held = 0 45 self.held = 0
45 self.timeout = timeout 46 self.timeout = timeout
46 self.releasefn = releasefn 47 self.releasefn = releasefn
48 self.acquirefn = acquirefn
47 self.desc = desc 49 self.desc = desc
48 self.postrelease = [] 50 self.postrelease = []
49 self.pid = os.getpid() 51 self.pid = os.getpid()
50 self.delay = self.lock() 52 self.delay = self.lock()
53 if self.acquirefn:
54 self.acquirefn()
51 55
52 def __del__(self): 56 def __del__(self):
53 if self.held: 57 if self.held:
54 warnings.warn("use lock.release instead of del lock", 58 warnings.warn("use lock.release instead of del lock",
55 category=DeprecationWarning, 59 category=DeprecationWarning,