Mercurial > evolve
changeset 3082:326e0ee1eed1
topic: register config items
There is a couple more hoops to jump through but all config items used are now
registered.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 19 Oct 2017 18:18:43 +0200 |
parents | 25a6a2520255 |
children | e91ca8b5ecf7 |
files | hgext3rd/topic/__init__.py |
diffstat | 1 files changed, 35 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py Thu Oct 19 18:17:47 2017 +0200 +++ b/hgext3rd/topic/__init__.py Thu Oct 19 18:18:43 2017 +0200 @@ -67,6 +67,7 @@ from __future__ import absolute_import +import functools import re import time import weakref @@ -144,6 +145,38 @@ minimumhgversion = '4.0' buglink = 'https://bz.mercurial-scm.org/' +if util.safehasattr(registrar, 'configitem'): + configtable = {} + configitem = registrar.configitem(configtable) + + configitem('experimental', 'enforce-topic', + default=False, + ) + configitem('experimental', 'topic-mode', + default=None, + ) + configitem('_internal', 'keep-topic', + default=False, + ) + + def extsetup(ui): + # register config that strickly belong to other code (thg, core, etc) + # + # To ensure all config items we used are registerd, we register them if + # nobody else did so far. + from mercurial import configitems + extraitem = functools.partial(configitems._register, ui._knownconfig) + if ('experimental' not in ui._knownconfig + or not ui._knownconfig['experimental'].get('thg.displaynames')): + extraitem('experimental', 'thg.displaynames', + default=None, + ) + if ('devel' not in ui._knownconfig + or not ui._knownconfig['devel'].get('random')): + extraitem('devel', 'randomseed', + default=None, + ) + def _contexttopic(self, force=False): if not (force or self.mutable()): return '' @@ -249,7 +282,7 @@ repo = repo.unfiltered() - if repo.ui.config('experimental', 'thg.displaynames', None) is None: + if repo.ui.config('experimental', 'thg.displaynames') is None: repo.ui.setconfig('experimental', 'thg.displaynames', 'topics', source='topic-extension') @@ -928,7 +961,7 @@ def _configtopicmode(ui): """ Parse the config to get the topicmode """ - topicmode = ui.config('experimental', 'topic-mode', default=None) + topicmode = ui.config('experimental', 'topic-mode') # Fallback to read enforce-topic if topicmode is None: