[PATCH 1 of 4 STABLE] i18n: use UTF-8-ed string to check use of characters reserved for Windows

Matt Mackall mpm at selenic.com
Sat Dec 24 16:30:44 CST 2011


On Sat, 2011-12-24 at 23:31 +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
> # Date 1324735129 -32400
> # Branch stable
> # Node ID 01fe3735501eeca6004a36d1f961ec50414ef163
> # Parent  32a6e00e4cfe84573b9d4dc71155d0dc23b75faf
> i18n: use UTF-8-ed string to check use of characters reserved for Windows
> 
> some problematic encoding (e.g.: cp932) uses characters reserved for
> Windows (e.g.: "|") in byte sequence of multi byte characters.

If I understand this correctly, this bug is specific to the win32mbcs
extension and thus belongs in that extension.

> so, direct checking on byte sequence causes unexpected warning/abort
> in such encoding.
> 
> this patch uses UTF-8-ed string instead of raw one.
> 
> in UTF-8-ed string, such ambiguous byte sequences are converted into
> non-ASCII area, and real uses of reserved characters are kept as same
> as it is.
> 
> this logic is cheaper than iteration per character instead of per
> byte, because this does not require invocations of "encode()" on each
> characters.
> 
> diff -r 32a6e00e4cfe -r 01fe3735501e mercurial/util.py
> --- a/mercurial/util.py	Tue Dec 20 14:11:14 2011 -0600
> +++ b/mercurial/util.py	Sat Dec 24 22:58:49 2011 +0900
> @@ -533,7 +533,7 @@
>      for n in path.replace('\\', '/').split('/'):
>          if not n:
>              continue
> -        for c in n:
> +        for c in encoding.fromlocal(n):
>              if c in _winreservedchars:
>                  return _("filename contains '%s', which is reserved "
>                           "on Windows") % c
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list