Mercurial > public > mercurial-scm > hg
comparison mercurial/scmutil.py @ 15665:081e795c60e0 stable
pathauditor: preserve case in abort messages
this patch uses both plain and normcase()-ed pathes to preserve letter
case of path in abort messages.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Fri, 16 Dec 2011 21:09:40 +0900 |
parents | ec8730886f36 |
children | 37a6e9765015 |
comparison
equal
deleted
inserted
replaced
15664:ec8730886f36 | 15665:081e795c60e0 |
---|---|
85 if normpath in self.audited: | 85 if normpath in self.audited: |
86 return | 86 return |
87 # AIX ignores "/" at end of path, others raise EISDIR. | 87 # AIX ignores "/" at end of path, others raise EISDIR. |
88 if util.endswithsep(path): | 88 if util.endswithsep(path): |
89 raise util.Abort(_("path ends in directory separator: %s") % path) | 89 raise util.Abort(_("path ends in directory separator: %s") % path) |
90 parts = util.splitpath(normpath) | 90 parts = util.splitpath(path) |
91 if (os.path.splitdrive(path)[0] | 91 if (os.path.splitdrive(path)[0] |
92 or parts[0].lower() in ('.hg', '.hg.', '') | 92 or parts[0].lower() in ('.hg', '.hg.', '') |
93 or os.pardir in parts): | 93 or os.pardir in parts): |
94 raise util.Abort(_("path contains illegal component: %s") % path) | 94 raise util.Abort(_("path contains illegal component: %s") % path) |
95 if '.hg' in path.lower(): | 95 if '.hg' in path.lower(): |
99 pos = lparts.index(p) | 99 pos = lparts.index(p) |
100 base = os.path.join(*parts[:pos]) | 100 base = os.path.join(*parts[:pos]) |
101 raise util.Abort(_('path %r is inside nested repo %r') | 101 raise util.Abort(_('path %r is inside nested repo %r') |
102 % (path, base)) | 102 % (path, base)) |
103 | 103 |
104 normparts = util.splitpath(normpath) | |
105 assert len(parts) == len(normparts) | |
106 | |
104 parts.pop() | 107 parts.pop() |
108 normparts.pop() | |
105 prefixes = [] | 109 prefixes = [] |
106 while parts: | 110 while parts: |
107 prefix = os.sep.join(parts) | 111 prefix = os.sep.join(parts) |
108 if prefix in self.auditeddir: | 112 normprefix = os.sep.join(normparts) |
113 if normprefix in self.auditeddir: | |
109 break | 114 break |
110 curpath = os.path.join(self.root, prefix) | 115 curpath = os.path.join(self.root, prefix) |
111 try: | 116 try: |
112 st = os.lstat(curpath) | 117 st = os.lstat(curpath) |
113 except OSError, err: | 118 except OSError, err: |
123 elif (stat.S_ISDIR(st.st_mode) and | 128 elif (stat.S_ISDIR(st.st_mode) and |
124 os.path.isdir(os.path.join(curpath, '.hg'))): | 129 os.path.isdir(os.path.join(curpath, '.hg'))): |
125 if not self.callback or not self.callback(curpath): | 130 if not self.callback or not self.callback(curpath): |
126 raise util.Abort(_('path %r is inside nested repo %r') % | 131 raise util.Abort(_('path %r is inside nested repo %r') % |
127 (path, prefix)) | 132 (path, prefix)) |
128 prefixes.append(prefix) | 133 prefixes.append(normprefix) |
129 parts.pop() | 134 parts.pop() |
135 normparts.pop() | |
130 | 136 |
131 self.audited.add(normpath) | 137 self.audited.add(normpath) |
132 # only add prefixes to the cache after checking everything: we don't | 138 # only add prefixes to the cache after checking everything: we don't |
133 # want to add "foo/bar/baz" before checking if there's a "foo/.hg" | 139 # want to add "foo/bar/baz" before checking if there's a "foo/.hg" |
134 self.auditeddir.update(prefixes) | 140 self.auditeddir.update(prefixes) |