Show More
@@ -116,7 +116,9 b' class pathauditor:' | |||
|
116 | 116 | if prefix in self.auditeddir: |
|
117 | 117 | res = self.auditeddir[prefix] |
|
118 | 118 | else: |
|
119 |
res = |
|
|
119 | res = pathauditor._checkfs_exists( | |
|
120 | self.root, prefix, path, self.callback | |
|
121 | ) | |
|
120 | 122 | if self._cached: |
|
121 | 123 | self.auditeddir[prefix] = res |
|
122 | 124 | if not res: |
@@ -125,11 +127,17 b' class pathauditor:' | |||
|
125 | 127 | if self._cached: |
|
126 | 128 | self.audited.add(path) |
|
127 | 129 | |
|
128 | def _checkfs_exists(self, prefix: bytes, path: bytes) -> bool: | |
|
130 | @staticmethod | |
|
131 | def _checkfs_exists( | |
|
132 | root, | |
|
133 | prefix: bytes, | |
|
134 | path: bytes, | |
|
135 | callback: Optional[Callable[[bytes], bool]] = None, | |
|
136 | ): | |
|
129 | 137 | """raise exception if a file system backed check fails. |
|
130 | 138 | |
|
131 | 139 | Return a bool that indicates that the directory (or file) exists.""" |
|
132 |
curpath = os.path.join( |
|
|
140 | curpath = os.path.join(root, prefix) | |
|
133 | 141 | try: |
|
134 | 142 | st = os.lstat(curpath) |
|
135 | 143 | except OSError as err: |
@@ -149,7 +157,7 b' class pathauditor:' | |||
|
149 | 157 | elif stat.S_ISDIR(st.st_mode) and os.path.isdir( |
|
150 | 158 | os.path.join(curpath, b'.hg') |
|
151 | 159 | ): |
|
152 |
if not |
|
|
160 | if not callback or not callback(curpath): | |
|
153 | 161 | msg = _(b"path '%s' is inside nested repo %r") |
|
154 | 162 | raise error.Abort(msg % (path, pycompat.bytestr(prefix))) |
|
155 | 163 | return True |
@@ -427,13 +427,19 b' class vfs(abstractvfs):' | |||
|
427 | 427 | ) -> bool: |
|
428 | 428 | """return True if the path is a regular file or a symlink and |
|
429 | 429 | the directories along the path are "normal", that is |
|
430 |
not symlinks or nested hg repositories. |
|
|
430 | not symlinks or nested hg repositories. | |
|
431 | ||
|
432 | Ignores the `_audit` setting, and checks the directories regardless. | |
|
433 | `dircache` is used to cache the directory checks. | |
|
434 | """ | |
|
431 | 435 | try: |
|
432 | 436 | for prefix in pathutil.finddirs_rev_noroot(util.localpath(path)): |
|
433 | 437 | if prefix in dircache: |
|
434 | 438 | res = dircache[prefix] |
|
435 | 439 | else: |
|
436 |
res = |
|
|
440 | res = pathutil.pathauditor._checkfs_exists( | |
|
441 | self.base, prefix, path | |
|
442 | ) | |
|
437 | 443 | dircache[prefix] = res |
|
438 | 444 | if not res: |
|
439 | 445 | return False |
General Comments 0
You need to be logged in to leave comments.
Login now