pathutil: use `finddirs_rev_noroot` instead of `parts`
authorArseniy Alekseyev <aalekseyev@janestreet.com>
Fri, 06 Jan 2023 16:42:24 +0000
changeset 49981 789e152a6bdb
parent 49980 7623d79f872c
child 49982 b7cf91ef03ba
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]
mercurial/pathutil.py
--- a/mercurial/pathutil.py	Fri Jan 06 17:29:42 2023 +0000
+++ b/mercurial/pathutil.py	Fri Jan 06 16:42:24 2023 +0000
@@ -107,14 +107,12 @@
                     )
 
         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])
+            for prefix in finddirs_rev_noroot(path):
                 if prefix in self.auditeddir:
                     res = self.auditeddir[prefix]
                 else: