Mercurial > hg
comparison mercurial/posix.py @ 15566:7786b7dfbc46
merge with stable
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 23 Nov 2011 16:35:17 -0600 |
parents | b61fa7481a68 |
children | 2ebe3d0ce91d |
comparison
equal
deleted
inserted
replaced
15562:a82b6038ff08 | 15566:7786b7dfbc46 |
---|---|
174 def normcase(path): | 174 def normcase(path): |
175 try: | 175 try: |
176 u = path.decode('utf-8') | 176 u = path.decode('utf-8') |
177 except UnicodeDecodeError: | 177 except UnicodeDecodeError: |
178 # percent-encode any characters that don't round-trip | 178 # percent-encode any characters that don't round-trip |
179 p2 = path.decode('utf-8', 'replace').encode('utf-8') | 179 p2 = path.decode('utf-8', 'ignore').encode('utf-8') |
180 s = "" | 180 s = "" |
181 for a, b in zip(path, p2): | 181 pos = 0 |
182 if a != b: | 182 for c in path: |
183 s += "%%%02X" % ord(a) | 183 if p2[pos:pos + 1] == c: |
184 s += c | |
185 pos += 1 | |
184 else: | 186 else: |
185 s += a | 187 s += "%%%02X" % ord(c) |
186 u = s.decode('utf-8') | 188 u = s.decode('utf-8') |
187 | 189 |
188 # Decompose then lowercase (HFS+ technote specifies lower) | 190 # Decompose then lowercase (HFS+ technote specifies lower) |
189 return unicodedata.normalize('NFD', u).lower().encode('utf-8') | 191 return unicodedata.normalize('NFD', u).lower().encode('utf-8') |
190 | 192 |