Show More
@@ -81,25 +81,7 b' class pathauditor(object):' | |||
|
81 | 81 | normprefix = os.sep.join(normparts) |
|
82 | 82 | if normprefix in self.auditeddir: |
|
83 | 83 | break |
|
84 | curpath = os.path.join(self.root, prefix) | |
|
85 | try: | |
|
86 | st = os.lstat(curpath) | |
|
87 | except OSError as err: | |
|
88 | # EINVAL can be raised as invalid path syntax under win32. | |
|
89 | # They must be ignored for patterns can be checked too. | |
|
90 | if err.errno not in (errno.ENOENT, errno.ENOTDIR, errno.EINVAL): | |
|
91 | raise | |
|
92 | else: | |
|
93 | if stat.S_ISLNK(st.st_mode): | |
|
94 | raise error.Abort( | |
|
95 | _('path %r traverses symbolic link %r') | |
|
96 | % (path, prefix)) | |
|
97 | elif (stat.S_ISDIR(st.st_mode) and | |
|
98 | os.path.isdir(os.path.join(curpath, '.hg'))): | |
|
99 | if not self.callback or not self.callback(curpath): | |
|
100 | raise error.Abort(_("path '%s' is inside nested " | |
|
101 | "repo %r") | |
|
102 | % (path, prefix)) | |
|
84 | self._checkfs(prefix, path) | |
|
103 | 85 | prefixes.append(normprefix) |
|
104 | 86 | parts.pop() |
|
105 | 87 | normparts.pop() |
@@ -109,6 +91,27 b' class pathauditor(object):' | |||
|
109 | 91 | # want to add "foo/bar/baz" before checking if there's a "foo/.hg" |
|
110 | 92 | self.auditeddir.update(prefixes) |
|
111 | 93 | |
|
94 | def _checkfs(self, prefix, path): | |
|
95 | """raise exception if a file system backed check fails""" | |
|
96 | curpath = os.path.join(self.root, prefix) | |
|
97 | try: | |
|
98 | st = os.lstat(curpath) | |
|
99 | except OSError as err: | |
|
100 | # EINVAL can be raised as invalid path syntax under win32. | |
|
101 | # They must be ignored for patterns can be checked too. | |
|
102 | if err.errno not in (errno.ENOENT, errno.ENOTDIR, errno.EINVAL): | |
|
103 | raise | |
|
104 | else: | |
|
105 | if stat.S_ISLNK(st.st_mode): | |
|
106 | raise error.Abort( | |
|
107 | _('path %r traverses symbolic link %r') | |
|
108 | % (path, prefix)) | |
|
109 | elif (stat.S_ISDIR(st.st_mode) and | |
|
110 | os.path.isdir(os.path.join(curpath, '.hg'))): | |
|
111 | if not self.callback or not self.callback(curpath): | |
|
112 | raise error.Abort(_("path '%s' is inside nested " | |
|
113 | "repo %r") % (path, prefix)) | |
|
114 | ||
|
112 | 115 | def check(self, path): |
|
113 | 116 | try: |
|
114 | 117 | self(path) |
General Comments 0
You need to be logged in to leave comments.
Login now