Mercurial > hg-stable
changeset 26291:1d33842c5b3e
lock: factor out lock testing into a separate function
This is going to be needed for upcoming work with lock inheritance.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Wed, 16 Sep 2015 19:52:06 -0700 |
parents | 9664d32bd6cb |
children | 007ac1acfcac |
files | mercurial/lock.py |
diffstat | 1 files changed, 15 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/lock.py Wed Sep 16 19:26:59 2015 -0700 +++ b/mercurial/lock.py Wed Sep 16 19:52:06 2015 -0700 @@ -113,18 +113,7 @@ return None raise - def testlock(self): - """return id of locker if lock is valid, else None. - - If old-style lock, we cannot tell what machine locker is on. - with new-style lock, if locker is on this machine, we can - see if locker is alive. If locker is on this machine but - not alive, we can safely break lock. - - The lock file is only deleted when None is returned. - - """ - locker = self._readlock() + def _testlock(self, locker): if locker is None: return None try: @@ -148,6 +137,20 @@ except error.LockError: return locker + def testlock(self): + """return id of locker if lock is valid, else None. + + If old-style lock, we cannot tell what machine locker is on. + with new-style lock, if locker is on this machine, we can + see if locker is alive. If locker is on this machine but + not alive, we can safely break lock. + + The lock file is only deleted when None is returned. + + """ + locker = self._readlock() + return self._testlock(locker) + def release(self): """release the lock and execute callback function if any