##// END OF EJS Templates
configitems: register the 'bookmarks.pushing' config
marmoute -
r33178:640a0760 default
parent child Browse files
Show More
@@ -1,103 +1,107 b''
1 # configitems.py - centralized declaration of configuration option
1 # configitems.py - centralized declaration of configuration option
2 #
2 #
3 # Copyright 2017 Pierre-Yves David <pierre-yves.david@octobus.net>
3 # Copyright 2017 Pierre-Yves David <pierre-yves.david@octobus.net>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 import functools
10 import functools
11
11
12 from . import (
12 from . import (
13 error,
13 error,
14 )
14 )
15
15
16 def loadconfigtable(ui, extname, configtable):
16 def loadconfigtable(ui, extname, configtable):
17 """update config item known to the ui with the extension ones"""
17 """update config item known to the ui with the extension ones"""
18 for section, items in configtable.items():
18 for section, items in configtable.items():
19 knownitems = ui._knownconfig.setdefault(section, {})
19 knownitems = ui._knownconfig.setdefault(section, {})
20 knownkeys = set(knownitems)
20 knownkeys = set(knownitems)
21 newkeys = set(items)
21 newkeys = set(items)
22 for key in sorted(knownkeys & newkeys):
22 for key in sorted(knownkeys & newkeys):
23 msg = "extension '%s' overwrite config item '%s.%s'"
23 msg = "extension '%s' overwrite config item '%s.%s'"
24 msg %= (extname, section, key)
24 msg %= (extname, section, key)
25 ui.develwarn(msg, config='warn-config')
25 ui.develwarn(msg, config='warn-config')
26
26
27 knownitems.update(items)
27 knownitems.update(items)
28
28
29 class configitem(object):
29 class configitem(object):
30 """represent a known config item
30 """represent a known config item
31
31
32 :section: the official config section where to find this item,
32 :section: the official config section where to find this item,
33 :name: the official name within the section,
33 :name: the official name within the section,
34 :default: default value for this item,
34 :default: default value for this item,
35 """
35 """
36
36
37 def __init__(self, section, name, default=None):
37 def __init__(self, section, name, default=None):
38 self.section = section
38 self.section = section
39 self.name = name
39 self.name = name
40 self.default = default
40 self.default = default
41
41
42 coreitems = {}
42 coreitems = {}
43
43
44 def _register(configtable, *args, **kwargs):
44 def _register(configtable, *args, **kwargs):
45 item = configitem(*args, **kwargs)
45 item = configitem(*args, **kwargs)
46 section = configtable.setdefault(item.section, {})
46 section = configtable.setdefault(item.section, {})
47 if item.name in section:
47 if item.name in section:
48 msg = "duplicated config item registration for '%s.%s'"
48 msg = "duplicated config item registration for '%s.%s'"
49 raise error.ProgrammingError(msg % (item.section, item.name))
49 raise error.ProgrammingError(msg % (item.section, item.name))
50 section[item.name] = item
50 section[item.name] = item
51
51
52 # Registering actual config items
52 # Registering actual config items
53
53
54 def getitemregister(configtable):
54 def getitemregister(configtable):
55 return functools.partial(_register, configtable)
55 return functools.partial(_register, configtable)
56
56
57 coreconfigitem = getitemregister(coreitems)
57 coreconfigitem = getitemregister(coreitems)
58
58
59 coreconfigitem('auth', 'cookiefile',
59 coreconfigitem('auth', 'cookiefile',
60 default=None,
60 default=None,
61 )
61 )
62 # bookmarks.pushing: internal hack for discovery
63 coreconfigitem('bookmarks', 'pushing',
64 default=list,
65 )
62 coreconfigitem('color', 'mode',
66 coreconfigitem('color', 'mode',
63 default='auto',
67 default='auto',
64 )
68 )
65 coreconfigitem('devel', 'all-warnings',
69 coreconfigitem('devel', 'all-warnings',
66 default=False,
70 default=False,
67 )
71 )
68 coreconfigitem('devel', 'bundle2.debug',
72 coreconfigitem('devel', 'bundle2.debug',
69 default=False,
73 default=False,
70 )
74 )
71 coreconfigitem('devel', 'check-locks',
75 coreconfigitem('devel', 'check-locks',
72 default=False,
76 default=False,
73 )
77 )
74 coreconfigitem('devel', 'check-relroot',
78 coreconfigitem('devel', 'check-relroot',
75 default=False,
79 default=False,
76 )
80 )
77 coreconfigitem('devel', 'disableloaddefaultcerts',
81 coreconfigitem('devel', 'disableloaddefaultcerts',
78 default=False,
82 default=False,
79 )
83 )
80 coreconfigitem('devel', 'servercafile',
84 coreconfigitem('devel', 'servercafile',
81 default='',
85 default='',
82 )
86 )
83 coreconfigitem('devel', 'serverexactprotocol',
87 coreconfigitem('devel', 'serverexactprotocol',
84 default='',
88 default='',
85 )
89 )
86 coreconfigitem('devel', 'serverrequirecert',
90 coreconfigitem('devel', 'serverrequirecert',
87 default=False,
91 default=False,
88 )
92 )
89 coreconfigitem('devel', 'strip-obsmarkers',
93 coreconfigitem('devel', 'strip-obsmarkers',
90 default=True,
94 default=True,
91 )
95 )
92 coreconfigitem('patch', 'fuzz',
96 coreconfigitem('patch', 'fuzz',
93 default=2,
97 default=2,
94 )
98 )
95 coreconfigitem('ui', 'clonebundleprefers',
99 coreconfigitem('ui', 'clonebundleprefers',
96 default=list,
100 default=list,
97 )
101 )
98 coreconfigitem('ui', 'interactive',
102 coreconfigitem('ui', 'interactive',
99 default=None,
103 default=None,
100 )
104 )
101 coreconfigitem('ui', 'quiet',
105 coreconfigitem('ui', 'quiet',
102 default=False,
106 default=False,
103 )
107 )
General Comments 0
You need to be logged in to leave comments. Login now