Comments
Patch
@@ -389,8 +389,14 @@ class localrepository(object):
if inst.errno != errno.ENOENT:
raise
+ getsvfs = vfsmod.vfs
+ if (self.ui.configbool('devel', 'all-warnings') or
+ self.ui.configbool('devel', 'check-locks')):
+ def getsvfs(*args, **kwargs):
+ kwargs['ward'] = self._getsvfsward()
+ return vfsmod.vfs(*args, **kwargs)
self.store = store.store(
- self.requirements, self.sharedpath, vfsmod.vfs)
+ self.requirements, self.sharedpath, getsvfs)
self.spath = self.store.path
self.svfs = self.store.vfs
self.sjoin = self.store.join
@@ -458,6 +464,23 @@ class localrepository(object):
stacklevel=2)
return checkvfs
+ def _getsvfsward(self):
+ """build a ward for self.svfs"""
+ rref = weakref.ref(self)
+ def checksvfs(f, mode, atomictemp):
+ repo = rref()
+ if repo is None or not util.safehasattr(repo, '_lockref'):
+ return
+ if mode in ('r', 'rb'):
+ return
+ assert f.startswith(repo.sharedpath), (repo.path, f)
+ # truncate name relative to the repository (.hg)
+ relname = f[len(repo.sharedpath) + 1:]
+ if repo._currentlock(repo._lockref) is None:
+ repo.ui.develwarn('write with no lock: "%s"' % relname,
+ stacklevel=3)
+ return checksvfs
+
def close(self):
self._writecaches()
@@ -49,6 +49,11 @@
> with repo.vfs(b'branch', 'a'):
> pass
>
+ > @command(b'no-lock-write', [], '')
+ > def nolockwrite(ui, repo):
+ > with repo.svfs(b'fncache', 'a'):
+ > pass
+ >
> @command(b'stripintr', [], '')
> def stripintr(ui, repo):
> lo = repo.lock()
@@ -114,6 +119,9 @@ Writing without lock
$ hg no-wlock-write
devel-warn: write with no wlock: "branch" at: $TESTTMP/buggylocking.py:* (nowlockwrite) (glob)
+ $ hg no-lock-write
+ devel-warn: write with no lock: "store/fncache" at: $TESTTMP/buggylocking.py:* (nolockwrite) (glob)
+
Stripping from a transaction
$ echo a > a