Mercurial > public > mercurial-scm > hg
comparison mercurial/pathutil.py @ 49908:789e152a6bdb
pathutil: use `finddirs_rev_noroot` instead of `parts`
The benefit this brings is very tiny, if it's even there,
since we still didn't get rid of the [parts] computation.
It probably won't be worth it without the subsequent patch
that adds one more use of [finddirs_rev_noroot]
author | Arseniy Alekseyev <aalekseyev@janestreet.com> |
---|---|
date | Fri, 06 Jan 2023 16:42:24 +0000 |
parents | 7623d79f872c |
children | bc83ebe07bf0 |
comparison
equal
deleted
inserted
replaced
49907:7623d79f872c | 49908:789e152a6bdb |
---|---|
105 _(b"path '%s' is inside nested repo %r") | 105 _(b"path '%s' is inside nested repo %r") |
106 % (path, pycompat.bytestr(base)) | 106 % (path, pycompat.bytestr(base)) |
107 ) | 107 ) |
108 | 108 |
109 if self._realfs: | 109 if self._realfs: |
110 parts.pop() | |
111 # It's important that we check the path parts starting from the root. | 110 # It's important that we check the path parts starting from the root. |
112 # We don't want to add "foo/bar/baz" to auditeddir before checking if | 111 # We don't want to add "foo/bar/baz" to auditeddir before checking if |
113 # there's a "foo/.hg" directory. This also means we won't accidentally | 112 # there's a "foo/.hg" directory. This also means we won't accidentally |
114 # traverse a symlink into some other filesystem (which is potentially | 113 # traverse a symlink into some other filesystem (which is potentially |
115 # expensive to access). | 114 # expensive to access). |
116 for i in range(len(parts)): | 115 for prefix in finddirs_rev_noroot(path): |
117 prefix = pycompat.ossep.join(parts[: i + 1]) | |
118 if prefix in self.auditeddir: | 116 if prefix in self.auditeddir: |
119 res = self.auditeddir[prefix] | 117 res = self.auditeddir[prefix] |
120 else: | 118 else: |
121 res = self._checkfs_exists(prefix, path) | 119 res = self._checkfs_exists(prefix, path) |
122 if self._cached: | 120 if self._cached: |