comparison hgext/win32mbcs.py @ 34180:37513324f620

configitems: register the 'win32mbcs.encoding' config
author Boris Feld <boris.feld@octobus.net>
date Fri, 30 Jun 2017 03:45:54 +0200
parents 9929af2b09b4
children 75979c8d4572
comparison
equal deleted inserted replaced
34179:036d47d7cf39 34180:37513324f620
52 from mercurial.i18n import _ 52 from mercurial.i18n import _
53 from mercurial import ( 53 from mercurial import (
54 encoding, 54 encoding,
55 error, 55 error,
56 pycompat, 56 pycompat,
57 registrar,
57 ) 58 )
58 59
59 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for 60 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
60 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should 61 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
61 # be specifying the version(s) of Mercurial they are tested with, or 62 # be specifying the version(s) of Mercurial they are tested with, or
62 # leave the attribute unspecified. 63 # leave the attribute unspecified.
63 testedwith = 'ships-with-hg-core' 64 testedwith = 'ships-with-hg-core'
65
66 configtable = {}
67 configitem = registrar.configitem(configtable)
68
69 # Encoding.encoding may be updated by --encoding option.
70 # Use a lambda do delay the resolution.
71 configitem('win32mbcs', 'encoding',
72 default=lambda: encoding.encoding,
73 )
64 74
65 _encoding = None # see extsetup 75 _encoding = None # see extsetup
66 76
67 def decode(arg): 77 def decode(arg):
68 if isinstance(arg, str): 78 if isinstance(arg, str):
173 (pycompat.sysplatform != 'cygwin')): 183 (pycompat.sysplatform != 'cygwin')):
174 ui.warn(_("[win32mbcs] cannot activate on this platform.\n")) 184 ui.warn(_("[win32mbcs] cannot activate on this platform.\n"))
175 return 185 return
176 # determine encoding for filename 186 # determine encoding for filename
177 global _encoding 187 global _encoding
178 _encoding = ui.config('win32mbcs', 'encoding', encoding.encoding) 188 _encoding = ui.config('win32mbcs', 'encoding')
179 # fake is only for relevant environment. 189 # fake is only for relevant environment.
180 if _encoding.lower() in problematic_encodings.split(): 190 if _encoding.lower() in problematic_encodings.split():
181 for f in funcs.split(): 191 for f in funcs.split():
182 wrapname(f, wrapper) 192 wrapname(f, wrapper)
183 if pycompat.osname == 'nt': 193 if pycompat.osname == 'nt':