# HG changeset patch # User Siddharth Agarwal # Date 2015-09-17 02:52:06 # Node ID 1d33842c5b3efb6cc58c99544c7a3a8ef821d04f # Parent 9664d32bd6cb98ed2112a97307ef234b33266d4a lock: factor out lock testing into a separate function This is going to be needed for upcoming work with lock inheritance. diff --git a/mercurial/lock.py b/mercurial/lock.py --- a/mercurial/lock.py +++ b/mercurial/lock.py @@ -113,18 +113,7 @@ class lock(object): 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 @@ class lock(object): 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