Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/pathutil.py @ 44392:d52e3826cd4b
pathutil: resurrect comment about path auditing order
It was removed at 51c86c6167c1, but expensive symlink traversal isn't the
only reason we should walk path components from the root.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 01 Feb 2020 12:57:32 +0900 |
parents | 51c86c6167c1 |
children | 11f284c8c5e4 |
comparison
equal
deleted
inserted
replaced
44391:bed8d08cfcb2 | 44392:d52e3826cd4b |
---|---|
98 assert len(parts) == len(normparts) | 98 assert len(parts) == len(normparts) |
99 | 99 |
100 parts.pop() | 100 parts.pop() |
101 normparts.pop() | 101 normparts.pop() |
102 # It's important that we check the path parts starting from the root. | 102 # It's important that we check the path parts starting from the root. |
103 # This means we won't accidentally traverse a symlink into some other | 103 # We don't want to add "foo/bar/baz" to auditeddir before checking if |
104 # filesystem (which is potentially expensive to access). | 104 # there's a "foo/.hg" directory. This also means we won't accidentally |
105 # traverse a symlink into some other filesystem (which is potentially | |
106 # expensive to access). | |
105 for i in range(len(parts)): | 107 for i in range(len(parts)): |
106 prefix = pycompat.ossep.join(parts[: i + 1]) | 108 prefix = pycompat.ossep.join(parts[: i + 1]) |
107 normprefix = pycompat.ossep.join(normparts[: i + 1]) | 109 normprefix = pycompat.ossep.join(normparts[: i + 1]) |
108 if normprefix in self.auditeddir: | 110 if normprefix in self.auditeddir: |
109 continue | 111 continue |