# HG changeset patch # User Arseniy Alekseyev # Date 1672851795 0 # Node ID 76d1e9f229fe163fd0febdaff28d99c7dcc75026 # Parent 1b701d425c37752a3f9073aa988c27f59cd7ec03 merge: disable the whole filesystem access loop if [_realfs] is false This makes it clearer that [auditeddir] is only relevant for [_realfs] checkers, and makes the non-realfs checkers more performant. diff -r 1b701d425c37 -r 76d1e9f229fe mercurial/pathutil.py --- a/mercurial/pathutil.py Wed Jan 04 16:48:32 2023 +0000 +++ b/mercurial/pathutil.py Wed Jan 04 17:03:15 2023 +0000 @@ -108,22 +108,22 @@ % (path, pycompat.bytestr(base)) ) - parts.pop() - # It's important that we check the path parts starting from the root. - # We don't want to add "foo/bar/baz" to auditeddir before checking if - # there's a "foo/.hg" directory. This also means we won't accidentally - # traverse a symlink into some other filesystem (which is potentially - # expensive to access). - for i in range(len(parts)): - prefix = pycompat.ossep.join(parts[: i + 1]) - if prefix in self.auditeddir: - continue - if self._realfs: + if self._realfs: + parts.pop() + # It's important that we check the path parts starting from the root. + # We don't want to add "foo/bar/baz" to auditeddir before checking if + # there's a "foo/.hg" directory. This also means we won't accidentally + # traverse a symlink into some other filesystem (which is potentially + # expensive to access). + for i in range(len(parts)): + prefix = pycompat.ossep.join(parts[: i + 1]) + if prefix in self.auditeddir: + continue res = self._checkfs_exists(prefix, path) - if self._cached: - self.auditeddir.add(prefix) - if not res: - break + if self._cached: + self.auditeddir.add(prefix) + if not res: + break if self._cached: self.audited.add(path)