diff -r 789e152a6bdb -r b7cf91ef03ba mercurial/vfs.py --- a/mercurial/vfs.py Fri Jan 06 16:42:24 2023 +0000 +++ b/mercurial/vfs.py Fri Jan 06 18:09:19 2023 +0000 @@ -422,6 +422,25 @@ raise error.Abort(b"%s: %r" % (r, path)) self.audit(path, mode=mode) + def isfileorlink_checkdir( + self, dircache, path: Optional[bytes] = None + ) -> bool: + """return True if the path is a regular file or a symlink and + the directories along the path are "normal", that is + not symlinks or nested hg repositories.""" + try: + for prefix in pathutil.finddirs_rev_noroot(util.localpath(path)): + if prefix in dircache: + res = dircache[prefix] + else: + res = self.audit._checkfs_exists(prefix, path) + dircache[prefix] = res + if not res: + return False + except (OSError, error.Abort): + return False + return self.isfileorlink(path) + def __call__( self, path: bytes,