Mercurial > hg
changeset 49891:76d1e9f229fe
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.
author | Arseniy Alekseyev <aalekseyev@janestreet.com> |
---|---|
date | Wed, 04 Jan 2023 17:03:15 +0000 |
parents | 1b701d425c37 |
children | c7624b1ac8b4 |
files | mercurial/pathutil.py |
diffstat | 1 files changed, 15 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- 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)