[PATCH] Fixed an area where an exception would be raised, if while testing for a lock, that lock files has already been removed

Nowell Strite nowell at strite.org
Tue Jul 27 16:30:16 CDT 2010


# HG changeset patch
# User Nowell Strite <nowell at strite.org>
# Date 1280265233 14400
# Node ID 42b968409fea0458acdc09c638ecbd09ce17a0b6
# Parent  fc360de6621728c40e51370114eac05b23728e70
Fixed an area where an exception would be raised, if while testing for a lock, that lock files has already been removed.

diff -r fc360de66217 -r 42b968409fea mercurial/lock.py
--- a/mercurial/lock.py	Mon Jul 26 23:26:15 2010 +0200
+++ b/mercurial/lock.py	Tue Jul 27 17:13:53 2010 -0400
@@ -96,7 +96,16 @@
         The lock file is only deleted when None is returned.
 
         """
-        locker = util.readlock(self.f)
+        try:
+            locker = util.readlock(self.f)
+        except (OSError, IOError), why:
+            """We should return None if we receive an exception stating
+            that the lock file does not exist.
+            """
+            if why.errno == errno.ENOENT:
+                return None
+            else:
+                raise
         try:
             host, pid = locker.split(":", 1)
         except ValueError:


More information about the Mercurial-devel mailing list