##// END OF EJS Templates
vfs: extract the audit path logic into a submethod...
Boris Feld -
r40785:34f15db8 default
parent child Browse files
Show More
@@ -1030,12 +1030,12 class localrepository(object):
1030 path = path[len(repo.path) + 1:]
1030 path = path[len(repo.path) + 1:]
1031 if path.startswith('cache/'):
1031 if path.startswith('cache/'):
1032 msg = 'accessing cache with vfs instead of cachevfs: "%s"'
1032 msg = 'accessing cache with vfs instead of cachevfs: "%s"'
1033 repo.ui.develwarn(msg % path, stacklevel=2, config="cache-vfs")
1033 repo.ui.develwarn(msg % path, stacklevel=3, config="cache-vfs")
1034 if path.startswith('journal.') or path.startswith('undo.'):
1034 if path.startswith('journal.') or path.startswith('undo.'):
1035 # journal is covered by 'lock'
1035 # journal is covered by 'lock'
1036 if repo._currentlock(repo._lockref) is None:
1036 if repo._currentlock(repo._lockref) is None:
1037 repo.ui.develwarn('write with no lock: "%s"' % path,
1037 repo.ui.develwarn('write with no lock: "%s"' % path,
1038 stacklevel=2, config='check-locks')
1038 stacklevel=3, config='check-locks')
1039 elif repo._currentlock(repo._wlockref) is None:
1039 elif repo._currentlock(repo._wlockref) is None:
1040 # rest of vfs files are covered by 'wlock'
1040 # rest of vfs files are covered by 'wlock'
1041 #
1041 #
@@ -1044,7 +1044,7 class localrepository(object):
1044 if path.startswith(prefix):
1044 if path.startswith(prefix):
1045 return
1045 return
1046 repo.ui.develwarn('write with no wlock: "%s"' % path,
1046 repo.ui.develwarn('write with no wlock: "%s"' % path,
1047 stacklevel=2, config='check-locks')
1047 stacklevel=3, config='check-locks')
1048 return ret
1048 return ret
1049 return checkvfs
1049 return checkvfs
1050
1050
@@ -1063,7 +1063,7 class localrepository(object):
1063 path = path[len(repo.sharedpath) + 1:]
1063 path = path[len(repo.sharedpath) + 1:]
1064 if repo._currentlock(repo._lockref) is None:
1064 if repo._currentlock(repo._lockref) is None:
1065 repo.ui.develwarn('write with no lock: "%s"' % path,
1065 repo.ui.develwarn('write with no lock: "%s"' % path,
1066 stacklevel=3)
1066 stacklevel=4)
1067 return ret
1067 return ret
1068 return checksvfs
1068 return checksvfs
1069
1069
@@ -337,6 +337,13 class vfs(abstractvfs):
337 return
337 return
338 os.chmod(name, self.createmode & 0o666)
338 os.chmod(name, self.createmode & 0o666)
339
339
340 def _auditpath(self, path, mode):
341 if self._audit:
342 r = util.checkosfilename(path)
343 if r:
344 raise error.Abort("%s: %r" % (r, path))
345 self.audit(path, mode=mode)
346
340 def __call__(self, path, mode="r", atomictemp=False, notindexed=False,
347 def __call__(self, path, mode="r", atomictemp=False, notindexed=False,
341 backgroundclose=False, checkambig=False, auditpath=True):
348 backgroundclose=False, checkambig=False, auditpath=True):
342 '''Open ``path`` file, which is relative to vfs root.
349 '''Open ``path`` file, which is relative to vfs root.
@@ -369,11 +376,7 class vfs(abstractvfs):
369 cases (see also issue5418 and issue5584 for detail).
376 cases (see also issue5418 and issue5584 for detail).
370 '''
377 '''
371 if auditpath:
378 if auditpath:
372 if self._audit:
379 self._auditpath(path, mode)
373 r = util.checkosfilename(path)
374 if r:
375 raise error.Abort("%s: %r" % (r, path))
376 self.audit(path, mode=mode)
377 f = self.join(path)
380 f = self.join(path)
378
381
379 if "b" not in mode:
382 if "b" not in mode:
General Comments 0
You need to be logged in to leave comments. Login now