diff -r 9664d32bd6cb -r 1d33842c5b3e mercurial/lock.py --- 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