Mercurial > hg-stable
changeset 7640:7197812e8d44
error: move lock errors
rename LockException to LockError
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 12 Jan 2009 11:09:14 -0600 |
parents | ae7a614a6a57 |
children | d2f753830f80 |
files | mercurial/dispatch.py mercurial/error.py mercurial/hg.py mercurial/localrepo.py mercurial/lock.py mercurial/streamclone.py |
diffstat | 6 files changed, 30 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/dispatch.py Mon Jan 12 10:59:08 2009 -0600 +++ b/mercurial/dispatch.py Mon Jan 12 11:09:14 2009 -0600 @@ -63,13 +63,13 @@ commands.help_(ui, 'shortlist') except error.RepoError, inst: ui.warn(_("abort: %s!\n") % inst) - except lock.LockHeld, inst: + except error.LockHeld, inst: if inst.errno == errno.ETIMEDOUT: reason = _('timed out waiting for lock held by %s') % inst.locker else: reason = _('lock held by %s') % inst.locker ui.warn(_("abort: %s: %s\n") % (inst.desc or inst.filename, reason)) - except lock.LockUnavailable, inst: + except error.LockUnavailable, inst: ui.warn(_("abort: could not lock %s: %s\n") % (inst.desc or inst.filename, inst.strerror)) except error.RevlogError, inst:
--- a/mercurial/error.py Mon Jan 12 10:59:08 2009 -0600 +++ b/mercurial/error.py Mon Jan 12 11:09:14 2009 -0600 @@ -33,3 +33,16 @@ class CapabilityError(RepoError): pass + +class LockError(IOError): + def __init__(self, errno, strerror, filename, desc): + IOError.__init__(self, errno, strerror, filename) + self.desc = desc + +class LockHeld(LockError): + def __init__(self, errno, filename, desc, locker): + LockError.__init__(self, errno, 'Lock held', filename, desc) + self.locker = locker + +class LockUnavailable(LockError): + pass
--- a/mercurial/hg.py Mon Jan 12 10:59:08 2009 -0600 +++ b/mercurial/hg.py Mon Jan 12 11:09:14 2009 -0600 @@ -8,7 +8,7 @@ from i18n import _ import localrepo, bundlerepo, httprepo, sshrepo, statichttprepo -import errno, lock, os, shutil, util, extensions +import errno, lock, os, shutil, util, extensions, error import merge as _merge import verify as _verify @@ -161,7 +161,7 @@ # not pointed to by changesets, thus causing verify to # fail src_lock = src_repo.lock() - except lock.LockException: + except error.LockError: copy = False if copy:
--- a/mercurial/localrepo.py Mon Jan 12 10:59:08 2009 -0600 +++ b/mercurial/localrepo.py Mon Jan 12 11:09:14 2009 -0600 @@ -637,7 +637,7 @@ def _lock(self, lockname, wait, releasefn, acquirefn, desc): try: l = lock.lock(lockname, 0, releasefn, desc=desc) - except lock.LockHeld, inst: + except error.LockHeld, inst: if not wait: raise self.ui.warn(_("waiting for lock on %s held by %r\n") % @@ -1023,7 +1023,7 @@ wlock = self.wlock(False) for f in fixup: self.dirstate.normal(f) - except lock.LockException: + except lock.LockError: pass finally: del wlock
--- 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):
--- a/mercurial/streamclone.py Mon Jan 12 10:59:08 2009 -0600 +++ b/mercurial/streamclone.py Mon Jan 12 11:09:14 2009 -0600 @@ -5,7 +5,7 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -import util, lock +import util, error from i18n import _ class StreamException(Exception): @@ -51,7 +51,7 @@ total_bytes += size finally: del l - except (lock.LockHeld, lock.LockUnavailable): + except error.LockError: raise StreamException(2) yield '0\n'