changeset 49888:445b4d819e9a

pathauditor: no need to normcase the paths The only thing normed paths are used is the key of the caching sets, so the only change of behavior will be that the checks will be repeated for paths that differ by case. If anything, it seems correct for the check to be repeated, in case that actually affects semantics, but the main reasoning is simplifying the code and making it a bit faster. It looks like the code originally comes from commit [081e795c60e0]: it looks like that commit tried to get rid of the existing norming, but presumably did this overly cautiously, preserving it for the cache keys, even though it was pointless even then.
author Arseniy Alekseyev <aalekseyev@janestreet.com>
date Fri, 06 Jan 2023 16:27:31 +0000
parents 44deb5a164dc
children 3aa8e569478a
files mercurial/pathutil.py
diffstat 1 files changed, 4 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/pathutil.py	Wed Jan 04 18:42:20 2023 +0000
+++ b/mercurial/pathutil.py	Fri Jan 06 16:27:31 2023 +0000
@@ -72,8 +72,7 @@
         path may contain a pattern (e.g. foodir/**.txt)"""
 
         path = util.localpath(path)
-        normpath = self.normcase(path)
-        if normpath in self.audited:
+        if path in self.audited:
             return
         # AIX ignores "/" at end of path, others raise EISDIR.
         if util.endswithsep(path):
@@ -109,11 +108,7 @@
                         % (path, pycompat.bytestr(base))
                     )
 
-        normparts = util.splitpath(normpath)
-        assert len(parts) == len(normparts)
-
         parts.pop()
-        normparts.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
@@ -121,16 +116,15 @@
         # expensive to access).
         for i in range(len(parts)):
             prefix = pycompat.ossep.join(parts[: i + 1])
-            normprefix = pycompat.ossep.join(normparts[: i + 1])
-            if normprefix in self.auditeddir:
+            if prefix in self.auditeddir:
                 continue
             if self._realfs:
                 self._checkfs(prefix, path)
             if self._cached:
-                self.auditeddir.add(normprefix)
+                self.auditeddir.add(prefix)
 
         if self._cached:
-            self.audited.add(normpath)
+            self.audited.add(path)
 
     def _checkfs(self, prefix, path):
         # type: (bytes, bytes) -> None