fixutf8 module

Martin Geisler mg at daimi.au.dk
Sun Feb 1 12:05:02 CST 2009


stefan at rusek.org writes:

Hi Stefan,

> # HG changeset patch
> # User Stefan Rusek <stefan at rusek.org>
> # Date 1233498913 -3600
> # Node ID c0b585163ff1994a4a2d23d4a2eb372ae65eab08
> # Parent  f9ba30cb7ee4faddf82b837479fa8bb8f2254517
> fixutf8 module
>
> This module automatically converts filenames to UTF-8 internally on
> systems where the default codepage is something other than UTF-8.
> Until recently it was common to set the codepage to latin1 on linux,
> and Windows does not support setting the default codepage to UTF-8 at
> all.
>
> Tested commands:
>
> hg init
> hg clone
> hg push
> hg pull
> hg add
> hg rm
> hg addremove
> hg ci
> hg revert

How about status and other commands which include filenames in their
output? Here I create a file called 'pærer.txt' ('pears.txt' in English)
and get UTF-8 encoded output in my Latin-1 terminal under Linux:

  % hg init
  % touch pærer.txt
  % hg stat
  ? pærer.txt

Also, os.path.splitunc does not exist under Linux, so I suggest applying
this small patch:

diff --git a/hgext/fixutf8.py b/hgext/fixutf8.py
--- a/hgext/fixutf8.py
+++ b/hgext/fixutf8.py
@@ -170,7 +170,8 @@
     # wrap the os and path functions
     def wrapnames(mod, *names):
         for name in names:
-            newfunc = extensions.wrapfunction(mod, name, utf8wrapper)
+            if hasattr(mod, name):
+                extensions.wrapfunction(mod, name, utf8wrapper)
 
     wrapnames(os.path, 'join', 'split', 'splitext', 'splitunc',
             'normpath', 'normcase', 'islink', 'dirname', 'isdir',


-- 
Martin Geisler

VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multiparty Computation) to Python. See: http://viff.dk/.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://selenic.com/pipermail/mercurial-devel/attachments/20090201/01fbcf3c/attachment.pgp 


More information about the Mercurial-devel mailing list