Patchwork [1,of,6] configitems: extract the logic to build a registrar on any configtable

login
register
mail settings
Submitter Pierre-Yves David
Date June 22, 2017, 7:34 a.m.
Message ID <1b9be14a52e0789ffbaa.1498116870@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/21604/
State Changes Requested
Headers show

Comments

Pierre-Yves David - June 22, 2017, 7:34 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1497699533 -7200
#      Sat Jun 17 13:38:53 2017 +0200
# Node ID 1b9be14a52e0789ffbaae58252f0b753fe213f86
# Parent  698542a0f8e8e7270661fbe20d53085d967f5305
# EXP-Topic config.register
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 1b9be14a52e0
configitems: extract the logic to build a registrar on any configtable

Having the logic available independently from the mapping used is a necessary
step toward extensions support.
via Mercurial-devel - June 26, 2017, 4:55 a.m.
On Thu, Jun 22, 2017 at 12:34 AM, Pierre-Yves David
<pierre-yves.david@ens-lyon.org> wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1497699533 -7200
> #      Sat Jun 17 13:38:53 2017 +0200
> # Node ID 1b9be14a52e0789ffbaae58252f0b753fe213f86
> # Parent  698542a0f8e8e7270661fbe20d53085d967f5305
> # EXP-Topic config.register
> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
> #              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 1b9be14a52e0
> configitems: extract the logic to build a registrar on any configtable

Sorry, but this no longer applies. Could you rebase and resend,
thanks? (I tried applying it to the parent noted above and then
rebasing, but there were more conflicts on patch 2, so I'd rather let
you resolve them.)
Pierre-Yves David - June 26, 2017, 9:51 a.m.
On 06/26/2017 06:55 AM, Martin von Zweigbergk wrote:
> On Thu, Jun 22, 2017 at 12:34 AM, Pierre-Yves David
> <pierre-yves.david@ens-lyon.org> wrote:
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@octobus.net>
>> # Date 1497699533 -7200
>> #      Sat Jun 17 13:38:53 2017 +0200
>> # Node ID 1b9be14a52e0789ffbaae58252f0b753fe213f86
>> # Parent  698542a0f8e8e7270661fbe20d53085d967f5305
>> # EXP-Topic config.register
>> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
>> #              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 1b9be14a52e0
>> configitems: extract the logic to build a registrar on any configtable
> 
> Sorry, but this no longer applies. Could you rebase and resend,
> thanks? (I tried applying it to the parent noted above and then
> rebasing, but there were more conflicts on patch 2, so I'd rather let
> you resolve them.)

Conflict likely comes from the dropped patch in the previous series. Can 
you have a look at the follow up first, I'll rebases on that.

 
https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-June/100311.html

Cheers,

Patch

diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -7,6 +7,8 @@ 
 
 from __future__ import absolute_import
 
+import functools
+
 from . import (
     error,
 )
@@ -26,9 +28,9 @@  class configitem(object):
 
 coreitems = {}
 
-def coreconfigitem(*args, **kwargs):
+def _register(configtable, *args, **kwargs):
     item = configitem(*args, **kwargs)
-    section = coreitems.setdefault(item.section, {})
+    section = configtable.setdefault(item.section, {})
     if item.name in section:
         msg = "duplicated config item registration for '%s.%s'"
         raise error.ProgrammingError(msg % (item.section, item.name))
@@ -36,6 +38,11 @@  def coreconfigitem(*args, **kwargs):
 
 # Registering actual config items
 
+def getitemregister(configtable):
+    return functools.partial(_register, configtable)
+
+coreconfigitem = getitemregister(coreitems)
+
 coreconfigitem('patch', 'fuzz',
     default=2,
 )