--- a/mercurial/lock.py Mon Jan 12 10:59:08 2009 -0600
+++ b/mercurial/lock.py Mon Jan 12 11:09:14 2009 -0600
@@ -5,20 +5,7 @@
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.
-import errno, os, socket, time, util
-
-class LockException(IOError):
- def __init__(self, errno, strerror, filename, desc):
- IOError.__init__(self, errno, strerror, filename)
- self.desc = desc
-
-class LockHeld(LockException):
- def __init__(self, errno, filename, desc, locker):
- LockException.__init__(self, errno, 'Lock held', filename, desc)
- self.locker = locker
-
-class LockUnavailable(LockException):
- pass
+import errno, os, socket, time, util, error
class lock(object):
# lock is symlink on platforms that support it, file on others.
@@ -48,14 +35,14 @@
try:
self.trylock()
return 1
- except LockHeld, inst:
+ except error.LockHeld, inst:
if timeout != 0:
time.sleep(1)
if timeout > 0:
timeout -= 1
continue
- raise LockHeld(errno.ETIMEDOUT, inst.filename, self.desc,
- inst.locker)
+ raise error.LockHeld(errno.ETIMEDOUT, inst.filename, self.desc,
+ inst.locker)
def trylock(self):
if lock._host is None:
@@ -69,11 +56,11 @@
if why.errno == errno.EEXIST:
locker = self.testlock()
if locker is not None:
- raise LockHeld(errno.EAGAIN, self.f, self.desc,
- locker)
+ raise error.LockHeld(errno.EAGAIN, self.f, self.desc,
+ locker)
else:
- raise LockUnavailable(why.errno, why.strerror,
- why.filename, self.desc)
+ raise error.LockUnavailable(why.errno, why.strerror,
+ why.filename, self.desc)
def testlock(self):
"""return id of locker if lock is valid, else None.
@@ -106,7 +93,7 @@
l.trylock()
os.unlink(self.f)
l.release()
- except (LockHeld, LockUnavailable):
+ except error.LockError:
return locker
def release(self):