# HG changeset patch # User Pierre-Yves David <pierre-yves.da...@ens-lyon.org> # Date 1470672882 -7200 # Mon Aug 08 18:14:42 2016 +0200 # Node ID e4af8c0de378cd1c7eddc83e086d9416f83755f5 # Parent 8d3ae769555bd7134bb70f31b16e67d17726b627 # EXP-Topic vfs.ward reposvfs: add a ward to check if locks are properly taken
We use the 'ward' to check for the store lock when accessing file in '.hg/store' for writing. This caught a couple of instance where the transaction was released after the lock, we should probably have a dedicated checker for that case. diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -344,8 +344,14 @@ class localrepository(object): if inst.errno != errno.ENOENT: raise + getsvfs = scmutil.vfs + if (self.ui.configbool('devel', 'all-warnings') or + self.ui.configbool('devel', 'check-locks')): + def getsvfs(*args, **kwargs): + kwargs['ward'] = self._getsvfsward() + return scmutil.vfs(*args, **kwargs) self.store = store.store( - self.requirements, self.sharedpath, scmutil.vfs) + self.requirements, self.sharedpath, getsvfs) self.spath = self.store.path self.svfs = self.store.vfs self.sjoin = self.store.join @@ -410,6 +416,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=2) + return checksvfs + def close(self): self._writecaches() _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel