##// END OF EJS Templates
reposvfs: add a ward to check if locks are properly taken...
Boris Feld -
r33437:0720e626 default
parent child Browse files
Show More
@@ -423,6 +423,12 b' class localrepository(object):'
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()
@@ -496,6 +502,25 b' class localrepository(object):'
496 return ret
502 return ret
497 return checkvfs
503 return checkvfs
498
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
523
499 def close(self):
524 def close(self):
500 self._writecaches()
525 self._writecaches()
501
526
@@ -49,6 +49,11 b''
49 > with repo.vfs(b'branch', 'a'):
49 > with repo.vfs(b'branch', 'a'):
50 > pass
50 > pass
51 >
51 >
52 > @command(b'no-lock-write', [], '')
53 > def nolockwrite(ui, repo):
54 > with repo.svfs(b'fncache', 'a'):
55 > pass
56 >
52 > @command(b'stripintr', [], '')
57 > @command(b'stripintr', [], '')
53 > def stripintr(ui, repo):
58 > def stripintr(ui, repo):
54 > lo = repo.lock()
59 > lo = repo.lock()
@@ -114,6 +119,9 b' Writing without lock'
114 $ hg no-wlock-write
119 $ hg no-wlock-write
115 devel-warn: write with no wlock: "branch" at: $TESTTMP/buggylocking.py:* (nowlockwrite) (glob)
120 devel-warn: write with no wlock: "branch" at: $TESTTMP/buggylocking.py:* (nowlockwrite) (glob)
116
121
122 $ hg no-lock-write
123 devel-warn: write with no lock: "fncache" at: $TESTTMP/buggylocking.py:* (nolockwrite) (glob)
124
117 Stripping from a transaction
125 Stripping from a transaction
118
126
119 $ echo a > a
127 $ echo a > a
General Comments 0
You need to be logged in to leave comments. Login now