changeset 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 036d47d7cf39
children 62490b84ebf8
files hgext/win32mbcs.py
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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():