comparison mercurial/vfs.py @ 49909:b7cf91ef03ba

merge: skip syntactic path checks in [_checkunknownfile] We don't need to check the paths syntactically, since they are coming from diffing the revisions, so hopefully already checked on the way in. We still need to check what's on the filesystem, to avoid traversing the symlinks or subdirs, which we can't know about statically. Also, we use the directory audit to elide [isfileorlink], this removing ~all lstat calls from hg updates from-empty.
author Arseniy Alekseyev <aalekseyev@janestreet.com>
date Fri, 06 Jan 2023 18:09:19 +0000
parents 2506c3ac73f4
children bc83ebe07bf0
comparison
equal deleted inserted replaced
49908:789e152a6bdb 49909:b7cf91ef03ba
419 path = os.path.relpath(path, self.base) 419 path = os.path.relpath(path, self.base)
420 r = util.checkosfilename(path) 420 r = util.checkosfilename(path)
421 if r: 421 if r:
422 raise error.Abort(b"%s: %r" % (r, path)) 422 raise error.Abort(b"%s: %r" % (r, path))
423 self.audit(path, mode=mode) 423 self.audit(path, mode=mode)
424
425 def isfileorlink_checkdir(
426 self, dircache, path: Optional[bytes] = None
427 ) -> bool:
428 """return True if the path is a regular file or a symlink and
429 the directories along the path are "normal", that is
430 not symlinks or nested hg repositories."""
431 try:
432 for prefix in pathutil.finddirs_rev_noroot(util.localpath(path)):
433 if prefix in dircache:
434 res = dircache[prefix]
435 else:
436 res = self.audit._checkfs_exists(prefix, path)
437 dircache[prefix] = res
438 if not res:
439 return False
440 except (OSError, error.Abort):
441 return False
442 return self.isfileorlink(path)
424 443
425 def __call__( 444 def __call__(
426 self, 445 self,
427 path: bytes, 446 path: bytes,
428 mode: bytes = b"rb", 447 mode: bytes = b"rb",