# HG changeset patch # User Thomas Arendsen Hein # Date 1164047788 -3600 # Node ID 4308f4cdc07b2f034db7bcaf52b04be7082fefb8 # Parent 193e9c6d1a6d94dcd6f67bb3151312fe099c5cba Don't step into an endless loop when lock file is empty. diff -r 193e9c6d1a6d -r 4308f4cdc07b mercurial/lock.py --- a/mercurial/lock.py Sun Nov 19 23:47:19 2006 +0100 +++ b/mercurial/lock.py Mon Nov 20 19:36:28 2006 +0100 @@ -71,7 +71,7 @@ except (OSError, IOError), why: if why.errno == errno.EEXIST: locker = self.testlock() - if locker: + if locker is not None: raise LockHeld(errno.EAGAIN, self.f, self.desc, locker) else: @@ -79,11 +79,16 @@ why.filename, self.desc) 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. + """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 = util.readlock(self.f) try: host, pid = locker.split(":", 1)