[PATCH] win32mbcs: use extsetup() to wrap functions only once
shunichi.goto at gmail.com
shunichi.goto at gmail.com
Fri Nov 19 03:10:49 CST 2010
# HG changeset patch
# User Shun-ichi GOTO <shunichi.goto at gmail.com>
# Date 1290157635 -32400
# Node ID 30967c86462b3a407ff2de737e2b8c4cf208b317
# Parent a229184d6ce45af31d156809736c8cf2c9df4181
win32mbcs: use extsetup() to wrap functions only once.
Using reposetup() may cause multiple-wrap issue in some situation
like "hg serve".
diff -r a229184d6ce4 -r 30967c86462b hgext/win32mbcs.py
--- a/hgext/win32mbcs.py Tue Nov 16 09:59:24 2010 +0900
+++ b/hgext/win32mbcs.py Fri Nov 19 18:07:15 2010 +0900
@@ -33,7 +33,8 @@
Note that there are some limitations on using this extension:
- You should use single encoding in one repository.
-
+- If the repository path ends with 0x5c, .hg/hgrc cannot be read.
+- win32mbcs is not compatible with fixutf8 extention.
By default, win32mbcs uses encoding.encoding decided by Mercurial.
You can specify the encoding by config option::
@@ -48,7 +49,7 @@
from mercurial.i18n import _
from mercurial import util, encoding
-_encoding = None # see reposetup()
+_encoding = None # see extsetup
def decode(arg):
if isinstance(arg, str):
@@ -136,7 +137,7 @@
sjis s_jis shift_jis_2004 shiftjis2004 sjis_2004 sjis2004
shift_jisx0213 shiftjisx0213 sjisx0213 s_jisx0213 950 cp950 ms950 '''
-def reposetup(ui, repo):
+def extsetup(ui):
# TODO: decide use of config section for this extension
if not os.path.supports_unicode_filenames:
ui.warn(_("[win32mbcs] cannot activate on this platform.\n"))
@@ -149,6 +150,10 @@
for f in funcs.split():
wrapname(f, wrapper)
wrapname("mercurial.osutil.listdir", wrapperforlistdir)
- ui.debug("[win32mbcs] activated with encoding: %s\n"
- % _encoding)
+ # Check sys.args manually instead of using ui.debug() because
+ # command line options is not yet applied when
+ # extensions.loadall() is called.
+ if '--debug' in sys.argv:
+ ui.write("[win32mbcs] activated with encoding: %s\n"
+ % _encoding)
More information about the Mercurial-devel
mailing list