comparison mercurial/localrepo.py @ 33437:0720e6265c8a

reposvfs: add a ward to check if locks are properly taken we wrap 'repo.svfs.audit' 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.
author Boris Feld <boris.feld@octobus.net>
date Mon, 08 Aug 2016 18:14:42 +0200
parents 9bb4decd43b0
children ec306bc6915b
comparison
equal deleted inserted replaced
33436:9bb4decd43b0 33437:0720e6265c8a
421 self.requirements, self.sharedpath, vfsmod.vfs) 421 self.requirements, self.sharedpath, vfsmod.vfs)
422 self.spath = self.store.path 422 self.spath = self.store.path
423 self.svfs = self.store.vfs 423 self.svfs = self.store.vfs
424 self.sjoin = self.store.join 424 self.sjoin = self.store.join
425 self.vfs.createmode = self.store.createmode 425 self.vfs.createmode = self.store.createmode
426 if (self.ui.configbool('devel', 'all-warnings') or
427 self.ui.configbool('devel', 'check-locks')):
428 if util.safehasattr(self.svfs, 'vfs'): # this is filtervfs
429 self.svfs.vfs.audit = self._getsvfsward(self.svfs.vfs.audit)
430 else: # standard vfs
431 self.svfs.audit = self._getsvfsward(self.svfs.audit)
426 self._applyopenerreqs() 432 self._applyopenerreqs()
427 if create: 433 if create:
428 self._writerequirements() 434 self._writerequirements()
429 435
430 self._dirstatevalidatewarned = False 436 self._dirstatevalidatewarned = False
493 return 499 return
494 repo.ui.develwarn('write with no wlock: "%s"' % path, 500 repo.ui.develwarn('write with no wlock: "%s"' % path,
495 stacklevel=2) 501 stacklevel=2)
496 return ret 502 return ret
497 return checkvfs 503 return checkvfs
504
505 def _getsvfsward(self, origfunc):
506 """build a ward for self.svfs"""
507 rref = weakref.ref(self)
508 def checksvfs(path, mode=None):
509 ret = origfunc(path, mode=mode)
510 repo = rref()
511 if repo is None or not util.safehasattr(repo, '_lockref'):
512 return
513 if mode in (None, 'r', 'rb'):
514 return
515 if path.startswith(repo.sharedpath):
516 # truncate name relative to the repository (.hg)
517 path = path[len(repo.sharedpath) + 1:]
518 if repo._currentlock(repo._lockref) is None:
519 repo.ui.develwarn('write with no lock: "%s"' % path,
520 stacklevel=3)
521 return ret
522 return checksvfs
498 523
499 def close(self): 524 def close(self):
500 self._writecaches() 525 self._writecaches()
501 526
502 def _loadextensions(self): 527 def _loadextensions(self):