configitems: register the 'win32mbcs.encoding' config
authorBoris Feld <boris.feld@octobus.net>
Fri, 30 Jun 2017 03:45:54 +0200
changeset 34180 37513324f620
parent 34179 036d47d7cf39
child 34181 62490b84ebf8
configitems: register the 'win32mbcs.encoding' config
hgext/win32mbcs.py
--- a/hgext/win32mbcs.py	Sun Sep 03 03:49:15 2017 +0530
+++ b/hgext/win32mbcs.py	Fri Jun 30 03:45:54 2017 +0200
@@ -54,6 +54,7 @@
     encoding,
     error,
     pycompat,
+    registrar,
 )
 
 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
@@ -62,6 +63,15 @@
 # leave the attribute unspecified.
 testedwith = 'ships-with-hg-core'
 
+configtable = {}
+configitem = registrar.configitem(configtable)
+
+# Encoding.encoding may be updated by --encoding option.
+# Use a lambda do delay the resolution.
+configitem('win32mbcs', 'encoding',
+    default=lambda: encoding.encoding,
+)
+
 _encoding = None                                # see extsetup
 
 def decode(arg):
@@ -175,7 +185,7 @@
         return
     # determine encoding for filename
     global _encoding
-    _encoding = ui.config('win32mbcs', 'encoding', encoding.encoding)
+    _encoding = ui.config('win32mbcs', 'encoding')
     # fake is only for relevant environment.
     if _encoding.lower() in problematic_encodings.split():
         for f in funcs.split():