Patchwork [V2] configitems: register the 'win32mbcs.encoding' config

login
register
mail settings
Submitter Boris Feld
Date Sept. 13, 2017, 10:30 a.m.
Message ID <5fb90f89802ce9428913.1505298654@FB>
Download mbox | patch
Permalink /patch/23860/
State Accepted
Headers show

Comments

Boris Feld - Sept. 13, 2017, 10:30 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1498787154 -7200
#      ven. juin 30 03:45:54 2017 +0200
# Node ID 5fb90f89802ce9428913ef67df6a96d66e218d51
# Parent  a763c891f36e55f4869f443c220227d1da747d18
# EXP-Topic config.register.win32mbcs
configitems: register the 'win32mbcs.encoding' config
Yuya Nishihara - Sept. 14, 2017, 2:55 p.m.
On Wed, 13 Sep 2017 12:30:54 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1498787154 -7200
> #      ven. juin 30 03:45:54 2017 +0200
> # Node ID 5fb90f89802ce9428913ef67df6a96d66e218d51
> # Parent  a763c891f36e55f4869f443c220227d1da747d18
> # EXP-Topic config.register.win32mbcs
> configitems: register the 'win32mbcs.encoding' config

Queued this, thanks.

Patch

diff -r a763c891f36e -r 5fb90f89802c hgext/win32mbcs.py
--- a/hgext/win32mbcs.py	mar. sept. 05 15:18:45 2017 -0700
+++ b/hgext/win32mbcs.py	ven. juin 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():