mercurial/lock.py
changeset 3686 4308f4cdc07b
parent 2859 345bac2bc4ec
child 3877 abaee83ce0a6
--- 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)