Patchwork [3,of,3] extensions: register config item early

login
register
mail settings
Submitter Boris Feld
Date Sept. 13, 2017, 6:36 a.m.
Message ID <2603449fbeb1c6af8c0e.1505284599@FB>
Download mbox | patch
Permalink /patch/23832/
State Accepted
Headers show

Comments

Boris Feld - Sept. 13, 2017, 6:36 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1504564453 -7200
#      mar. sept. 05 00:34:13 2017 +0200
# Node ID 2603449fbeb1c6af8c0e26f18eb4d12ea0ca7b5c
# Parent  61359c114a007e20e8d4799ab9b849d124ae9639
# EXP-Topic config.register.schedule
extensions: register config item early

Config items are likely to be used in during extensions setup. So we much
register them before that.

For example this apply to the 'win32text.warn' options.
Yuya Nishihara - Sept. 14, 2017, 2:56 p.m.
On Wed, 13 Sep 2017 08:36:39 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1504564453 -7200
> #      mar. sept. 05 00:34:13 2017 +0200
> # Node ID 2603449fbeb1c6af8c0e26f18eb4d12ea0ca7b5c
> # Parent  61359c114a007e20e8d4799ab9b849d124ae9639
> # EXP-Topic config.register.schedule
> extensions: register config item early
> 
> Config items are likely to be used in during extensions setup. So we much
> register them before that.

Seems fine, queued, thanks.

Patch

diff -r 61359c114a00 -r 2603449fbeb1 mercurial/extensions.py
--- a/mercurial/extensions.py	mar. sept. 05 00:31:59 2017 +0200
+++ b/mercurial/extensions.py	mar. sept. 05 00:34:13 2017 +0200
@@ -232,6 +232,18 @@ 
             if isinstance(inst, error.Hint) and inst.hint:
                 ui.warn(_("*** (%s)\n") % inst.hint)
             ui.traceback()
+    # list of (objname, loadermod, loadername) tuple:
+    # - objname is the name of an object in extension module,
+    #   from which extra information is loaded
+    # - loadermod is the module where loader is placed
+    # - loadername is the name of the function,
+    #   which takes (ui, extensionname, extraobj) arguments
+    #
+    # This one is for the list of item that must be run before running any setup
+    earlyextraloaders = [
+        ('configtable', configitems, 'loadconfigtable'),
+    ]
+    _loadextra(ui, newindex, earlyextraloaders)
 
     broken = set()
     for name in _order[newindex:]:
@@ -280,7 +292,6 @@ 
     extraloaders = [
         ('cmdtable', commands, 'loadcmdtable'),
         ('colortable', color, 'loadcolortable'),
-        ('configtable', configitems, 'loadconfigtable'),
         ('filesetpredicate', fileset, 'loadpredicate'),
         ('internalmerge', filemerge, 'loadinternalmerge'),
         ('revsetpredicate', revset, 'loadpredicate'),