Mercurial > public > mercurial-scm > hg-stable
diff 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 |
line wrap: on
line diff
--- a/mercurial/lock.py Thu Sep 24 22:00:51 2015 -0700 +++ b/mercurial/lock.py Thu Sep 24 22:07:55 2015 -0700 @@ -102,7 +102,16 @@ self.held = 1 except (OSError, IOError) as why: if why.errno == errno.EEXIST: - locker = self.testlock() + locker = self._readlock() + # special case where a parent process holds the lock -- this + # is different from the pid being different because we do + # want the unlock and postrelease functions to be called, + # but the lockfile to not be removed. + if locker == self.parentlock: + self._parentheld = True + self.held = 1 + return + locker = self._testlock(locker) if locker is not None: raise error.LockHeld(errno.EAGAIN, self.vfs.join(self.f), self.desc,