mercurial/pathutil.py
changeset 28087 0b7ce0b16d8a
parent 27235 054cd38a2f19
child 29893 6f447b9ec263
--- a/mercurial/pathutil.py	Tue Jan 19 22:31:59 2016 +0900
+++ b/mercurial/pathutil.py	Thu Feb 11 17:04:33 2016 -0800
@@ -83,16 +83,17 @@
         parts.pop()
         normparts.pop()
         prefixes = []
-        while parts:
-            prefix = os.sep.join(parts)
-            normprefix = os.sep.join(normparts)
+        # It's important that we check the path parts starting from the root.
+        # This means we won't accidentaly traverse a symlink into some other
+        # filesystem (which is potentially expensive to access).
+        for i in range(len(parts)):
+            prefix = os.sep.join(parts[:i + 1])
+            normprefix = os.sep.join(normparts[:i + 1])
             if normprefix in self.auditeddir:
-                break
+                continue
             if self._realfs:
                 self._checkfs(prefix, path)
             prefixes.append(normprefix)
-            parts.pop()
-            normparts.pop()
 
         self.audited.add(normpath)
         # only add prefixes to the cache after checking everything: we don't