Mercurial > public > mercurial-scm > hg-stable
diff mercurial/lock.py @ 20091:abfe6a8e619b
lock: take both vfs and lock file path relative to vfs to access via vfs
This patch makes "lock.lock.__init__()" take both vfs and lock file
path relative to vfs, instead of absolute path to lock file.
This allows lock file to be accessed via vfs.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Tue, 12 Nov 2013 16:23:52 +0900 |
parents | 76c83107a724 |
children | c697b70f295f |
line wrap: on
line diff
--- a/mercurial/lock.py Tue Nov 12 16:23:52 2013 +0900 +++ b/mercurial/lock.py Tue Nov 12 16:23:52 2013 +0900 @@ -29,7 +29,8 @@ _host = None - def __init__(self, file, timeout=-1, releasefn=None, desc=None): + def __init__(self, vfs, file, timeout=-1, releasefn=None, desc=None): + self.vfs = vfs self.f = file self.held = 0 self.timeout = timeout @@ -75,13 +76,14 @@ lockname = '%s:%s' % (lock._host, self.pid) while not self.held: try: - util.makelock(lockname, self.f) + self.vfs.makelock(lockname, self.f) self.held = 1 except (OSError, IOError), why: if why.errno == errno.EEXIST: locker = self.testlock() if locker is not None: - raise error.LockHeld(errno.EAGAIN, self.f, self.desc, + raise error.LockHeld(errno.EAGAIN, + self.vfs.join(self.f), self.desc, locker) else: raise error.LockUnavailable(why.errno, why.strerror, @@ -99,7 +101,7 @@ """ try: - locker = util.readlock(self.f) + locker = self.vfs.readlock(self.f) except (OSError, IOError), why: if why.errno == errno.ENOENT: return None @@ -119,8 +121,8 @@ # if locker dead, break lock. must do this with another lock # held, or can race and break valid lock. try: - l = lock(self.f + '.break', timeout=0) - util.unlink(self.f) + l = lock(self.vfs, self.f + '.break', timeout=0) + self.vfs.unlink(self.f) l.release() except error.LockError: return locker @@ -140,7 +142,7 @@ if self.releasefn: self.releasefn() try: - util.unlink(self.f) + self.vfs.unlink(self.f) except OSError: pass for callback in self.postrelease: