changeset 1753:e6e70450edb9

Raise a different exception when the lock is not available When the filesystem is read-only or if we have some other error, there is no need to wait. Raise a lock.LockUnavailable exception.
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Mon, 20 Feb 2006 01:09:40 +0100
parents 457cdec745f8
children fdfe89a3962d
files mercurial/lock.py
diffstat 1 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/lock.py	Sun Feb 19 22:41:49 2006 +0100
+++ b/mercurial/lock.py	Mon Feb 20 01:09:40 2006 +0100
@@ -5,10 +5,14 @@
 # This software may be used and distributed according to the terms
 # of the GNU General Public License, incorporated herein by reference.
 
-import os, time
+import errno, os, time
 import util
 
-class LockHeld(Exception):
+class LockException(Exception):
+    pass
+class LockHeld(LockException):
+    pass
+class LockUnavailable(LockException):
     pass
 
 class lock(object):
@@ -38,8 +42,11 @@
         try:
             util.makelock(str(pid), self.f)
             self.held = 1
-        except (OSError, IOError):
-            raise LockHeld(util.readlock(self.f))
+        except (OSError, IOError), why:
+            if why.errno == errno.EEXIST:
+                raise LockHeld(util.readlock(self.f))
+            else:
+                raise LockUnavailable(why)
 
     def release(self):
         if self.held: