comparison mercurial/lock.py @ 26387:e16f80f89a29

lock: recognize parent locks while acquiring This is part of a series that will allow locks to be inherited by subprocesses in limited circumstances. This patch enables the logic introduced in previous patches.
author Siddharth Agarwal <sid0@fb.com>
date Thu, 24 Sep 2015 22:07:55 -0700
parents 0fceb34806e1
children 5f94e64f182c
comparison
equal deleted inserted replaced
26386:146cccdb282b 26387:e16f80f89a29
100 try: 100 try:
101 self.vfs.makelock(lockname, self.f) 101 self.vfs.makelock(lockname, self.f)
102 self.held = 1 102 self.held = 1
103 except (OSError, IOError) as why: 103 except (OSError, IOError) as why:
104 if why.errno == errno.EEXIST: 104 if why.errno == errno.EEXIST:
105 locker = self.testlock() 105 locker = self._readlock()
106 # special case where a parent process holds the lock -- this
107 # is different from the pid being different because we do
108 # want the unlock and postrelease functions to be called,
109 # but the lockfile to not be removed.
110 if locker == self.parentlock:
111 self._parentheld = True
112 self.held = 1
113 return
114 locker = self._testlock(locker)
106 if locker is not None: 115 if locker is not None:
107 raise error.LockHeld(errno.EAGAIN, 116 raise error.LockHeld(errno.EAGAIN,
108 self.vfs.join(self.f), self.desc, 117 self.vfs.join(self.f), self.desc,
109 locker) 118 locker)
110 else: 119 else: