comparison mercurial/pathutil.py @ 49967: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
comparison
equal deleted inserted replaced
49966:1b701d425c37 49967:76d1e9f229fe
106 raise error.InputError( 106 raise error.InputError(
107 _(b"path '%s' is inside nested repo %r") 107 _(b"path '%s' is inside nested repo %r")
108 % (path, pycompat.bytestr(base)) 108 % (path, pycompat.bytestr(base))
109 ) 109 )
110 110
111 parts.pop() 111 if self._realfs:
112 # It's important that we check the path parts starting from the root. 112 parts.pop()
113 # We don't want to add "foo/bar/baz" to auditeddir before checking if 113 # It's important that we check the path parts starting from the root.
114 # there's a "foo/.hg" directory. This also means we won't accidentally 114 # We don't want to add "foo/bar/baz" to auditeddir before checking if
115 # traverse a symlink into some other filesystem (which is potentially 115 # there's a "foo/.hg" directory. This also means we won't accidentally
116 # expensive to access). 116 # traverse a symlink into some other filesystem (which is potentially
117 for i in range(len(parts)): 117 # expensive to access).
118 prefix = pycompat.ossep.join(parts[: i + 1]) 118 for i in range(len(parts)):
119 if prefix in self.auditeddir: 119 prefix = pycompat.ossep.join(parts[: i + 1])
120 continue 120 if prefix in self.auditeddir:
121 if self._realfs: 121 continue
122 res = self._checkfs_exists(prefix, path) 122 res = self._checkfs_exists(prefix, path)
123 if self._cached: 123 if self._cached:
124 self.auditeddir.add(prefix) 124 self.auditeddir.add(prefix)
125 if not res: 125 if not res:
126 break 126 break
127 127
128 if self._cached: 128 if self._cached:
129 self.audited.add(path) 129 self.audited.add(path)
130 130
131 def _checkfs_exists(self, prefix, path): 131 def _checkfs_exists(self, prefix, path):