Skip to content
Snippets Groups Projects
Commit c249de74742b authored by Kevin Bullock's avatar Kevin Bullock
Browse files

compat: use config registrar if available

parent a2eccdeed26d
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,7 @@
import os
# local modules
import compat
import gitrepo
import hgrepo
import overlay
......@@ -84,6 +85,7 @@
buglink = 'https://bitbucket.org/durin42/hg-git/issues'
cmdtable = {}
configtable = {}
try:
from mercurial import registrar
command = registrar.command(cmdtable)
......@@ -87,6 +89,9 @@
try:
from mercurial import registrar
command = registrar.command(cmdtable)
configitem = registrar.configitem(configtable)
compat.registerconfigs(configitem)
except (ImportError, AttributeError):
command = cmdutil.command(cmdtable)
......
......@@ -65,7 +65,16 @@
CONFIG_DEFAULTS = {
}
hasconfigitems = False
def registerconfigs(configitem):
global hasconfigitems
hasconfigitems = True
for section, items in CONFIG_DEFAULTS.iteritems():
for item, default in items.iteritems():
configitem(section, item, default=default)
def config(ui, subtype, section, item):
if subtype == 'string':
subtype = ''
getconfig = getattr(ui, 'config' + subtype)
......@@ -68,5 +77,7 @@
def config(ui, subtype, section, item):
if subtype == 'string':
subtype = ''
getconfig = getattr(ui, 'config' + subtype)
if hasconfigitems:
return getconfig(section, item)
return getconfig(section, item, CONFIG_DEFAULTS[section][item])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment