Patchwork configitems: register the 'win32mbcs.encoding' config

login
register
mail settings
Submitter Boris Feld
Date Sept. 11, 2017, 1:50 p.m.
Message ID <34ae7b710192ced20310.1505137832@FB>
Download mbox | patch
Permalink /patch/23777/
State Superseded
Headers show

Comments

Boris Feld - Sept. 11, 2017, 1:50 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1498787154 -7200
#      ven. juin 30 03:45:54 2017 +0200
# Node ID 34ae7b710192ced203102f80f6a1f73e42341d3b
# Parent  a763c891f36e55f4869f443c220227d1da747d18
# EXP-Topic config.register.win32mbcs
configitems: register the 'win32mbcs.encoding' config
Yuya Nishihara - Sept. 12, 2017, 2:26 p.m.
On Mon, 11 Sep 2017 15:50:32 +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 34ae7b710192ced203102f80f6a1f73e42341d3b
> # Parent  a763c891f36e55f4869f443c220227d1da747d18
> # EXP-Topic config.register.win32mbcs
> configitems: register the 'win32mbcs.encoding' config
> 
> diff -r a763c891f36e -r 34ae7b710192 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,13 @@
>  # leave the attribute unspecified.
>  testedwith = 'ships-with-hg-core'
>  
> +configtable = {}
> +configitem = registrar.configitem(configtable)
> +
> +configitem('win32mbcs', 'encoding',
> +    default=encoding.encoding,

encoding.encoding may be updated by --encoding option. Perhaps we'll need to
delay the resolution.

Patch

diff -r a763c891f36e -r 34ae7b710192 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,13 @@ 
 # leave the attribute unspecified.
 testedwith = 'ships-with-hg-core'
 
+configtable = {}
+configitem = registrar.configitem(configtable)
+
+configitem('win32mbcs', 'encoding',
+    default=encoding.encoding,
+)
+
 _encoding = None                                # see extsetup
 
 def decode(arg):
@@ -175,7 +183,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():