##// END OF EJS Templates
configitems: register the 'worker.backgroundclose' config
Boris Feld -
r33474:c514b4fb default
parent child Browse files
Show More
@@ -1,224 +1,227 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 :alias: optional list of tuples as alternatives.
35 :alias: optional list of tuples as alternatives.
36 """
36 """
37
37
38 def __init__(self, section, name, default=None, alias=()):
38 def __init__(self, section, name, default=None, alias=()):
39 self.section = section
39 self.section = section
40 self.name = name
40 self.name = name
41 self.default = default
41 self.default = default
42 self.alias = list(alias)
42 self.alias = list(alias)
43
43
44 coreitems = {}
44 coreitems = {}
45
45
46 def _register(configtable, *args, **kwargs):
46 def _register(configtable, *args, **kwargs):
47 item = configitem(*args, **kwargs)
47 item = configitem(*args, **kwargs)
48 section = configtable.setdefault(item.section, {})
48 section = configtable.setdefault(item.section, {})
49 if item.name in section:
49 if item.name in section:
50 msg = "duplicated config item registration for '%s.%s'"
50 msg = "duplicated config item registration for '%s.%s'"
51 raise error.ProgrammingError(msg % (item.section, item.name))
51 raise error.ProgrammingError(msg % (item.section, item.name))
52 section[item.name] = item
52 section[item.name] = item
53
53
54 # special value for case where the default is derived from other values
54 # special value for case where the default is derived from other values
55 dynamicdefault = object()
55 dynamicdefault = object()
56
56
57 # Registering actual config items
57 # Registering actual config items
58
58
59 def getitemregister(configtable):
59 def getitemregister(configtable):
60 return functools.partial(_register, configtable)
60 return functools.partial(_register, configtable)
61
61
62 coreconfigitem = getitemregister(coreitems)
62 coreconfigitem = getitemregister(coreitems)
63
63
64 coreconfigitem('auth', 'cookiefile',
64 coreconfigitem('auth', 'cookiefile',
65 default=None,
65 default=None,
66 )
66 )
67 # bookmarks.pushing: internal hack for discovery
67 # bookmarks.pushing: internal hack for discovery
68 coreconfigitem('bookmarks', 'pushing',
68 coreconfigitem('bookmarks', 'pushing',
69 default=list,
69 default=list,
70 )
70 )
71 # bundle.mainreporoot: internal hack for bundlerepo
71 # bundle.mainreporoot: internal hack for bundlerepo
72 coreconfigitem('bundle', 'mainreporoot',
72 coreconfigitem('bundle', 'mainreporoot',
73 default='',
73 default='',
74 )
74 )
75 # bundle.reorder: experimental config
75 # bundle.reorder: experimental config
76 coreconfigitem('bundle', 'reorder',
76 coreconfigitem('bundle', 'reorder',
77 default='auto',
77 default='auto',
78 )
78 )
79 coreconfigitem('color', 'mode',
79 coreconfigitem('color', 'mode',
80 default='auto',
80 default='auto',
81 )
81 )
82 coreconfigitem('color', 'pagermode',
82 coreconfigitem('color', 'pagermode',
83 default=dynamicdefault,
83 default=dynamicdefault,
84 )
84 )
85 coreconfigitem('devel', 'all-warnings',
85 coreconfigitem('devel', 'all-warnings',
86 default=False,
86 default=False,
87 )
87 )
88 coreconfigitem('devel', 'bundle2.debug',
88 coreconfigitem('devel', 'bundle2.debug',
89 default=False,
89 default=False,
90 )
90 )
91 coreconfigitem('devel', 'check-locks',
91 coreconfigitem('devel', 'check-locks',
92 default=False,
92 default=False,
93 )
93 )
94 coreconfigitem('devel', 'check-relroot',
94 coreconfigitem('devel', 'check-relroot',
95 default=False,
95 default=False,
96 )
96 )
97 coreconfigitem('devel', 'disableloaddefaultcerts',
97 coreconfigitem('devel', 'disableloaddefaultcerts',
98 default=False,
98 default=False,
99 )
99 )
100 coreconfigitem('devel', 'legacy.exchange',
100 coreconfigitem('devel', 'legacy.exchange',
101 default=list,
101 default=list,
102 )
102 )
103 coreconfigitem('devel', 'servercafile',
103 coreconfigitem('devel', 'servercafile',
104 default='',
104 default='',
105 )
105 )
106 coreconfigitem('devel', 'serverexactprotocol',
106 coreconfigitem('devel', 'serverexactprotocol',
107 default='',
107 default='',
108 )
108 )
109 coreconfigitem('devel', 'serverrequirecert',
109 coreconfigitem('devel', 'serverrequirecert',
110 default=False,
110 default=False,
111 )
111 )
112 coreconfigitem('devel', 'strip-obsmarkers',
112 coreconfigitem('devel', 'strip-obsmarkers',
113 default=True,
113 default=True,
114 )
114 )
115 coreconfigitem('format', 'aggressivemergedeltas',
115 coreconfigitem('format', 'aggressivemergedeltas',
116 default=False,
116 default=False,
117 )
117 )
118 coreconfigitem('format', 'chunkcachesize',
118 coreconfigitem('format', 'chunkcachesize',
119 default=None,
119 default=None,
120 )
120 )
121 coreconfigitem('format', 'dotencode',
121 coreconfigitem('format', 'dotencode',
122 default=True,
122 default=True,
123 )
123 )
124 coreconfigitem('format', 'generaldelta',
124 coreconfigitem('format', 'generaldelta',
125 default=False,
125 default=False,
126 )
126 )
127 coreconfigitem('format', 'manifestcachesize',
127 coreconfigitem('format', 'manifestcachesize',
128 default=None,
128 default=None,
129 )
129 )
130 coreconfigitem('format', 'maxchainlen',
130 coreconfigitem('format', 'maxchainlen',
131 default=None,
131 default=None,
132 )
132 )
133 coreconfigitem('format', 'obsstore-version',
133 coreconfigitem('format', 'obsstore-version',
134 default=None,
134 default=None,
135 )
135 )
136 coreconfigitem('format', 'usefncache',
136 coreconfigitem('format', 'usefncache',
137 default=True,
137 default=True,
138 )
138 )
139 coreconfigitem('format', 'usegeneraldelta',
139 coreconfigitem('format', 'usegeneraldelta',
140 default=True,
140 default=True,
141 )
141 )
142 coreconfigitem('format', 'usestore',
142 coreconfigitem('format', 'usestore',
143 default=True,
143 default=True,
144 )
144 )
145 coreconfigitem('hostsecurity', 'ciphers',
145 coreconfigitem('hostsecurity', 'ciphers',
146 default=None,
146 default=None,
147 )
147 )
148 coreconfigitem('hostsecurity', 'disabletls10warning',
148 coreconfigitem('hostsecurity', 'disabletls10warning',
149 default=False,
149 default=False,
150 )
150 )
151 coreconfigitem('patch', 'eol',
151 coreconfigitem('patch', 'eol',
152 default='strict',
152 default='strict',
153 )
153 )
154 coreconfigitem('patch', 'fuzz',
154 coreconfigitem('patch', 'fuzz',
155 default=2,
155 default=2,
156 )
156 )
157 coreconfigitem('progress', 'assume-tty',
157 coreconfigitem('progress', 'assume-tty',
158 default=False,
158 default=False,
159 )
159 )
160 coreconfigitem('progress', 'clear-complete',
160 coreconfigitem('progress', 'clear-complete',
161 default=True,
161 default=True,
162 )
162 )
163 coreconfigitem('progress', 'estimate',
163 coreconfigitem('progress', 'estimate',
164 default=2,
164 default=2,
165 )
165 )
166 coreconfigitem('progress', 'width',
166 coreconfigitem('progress', 'width',
167 default=dynamicdefault,
167 default=dynamicdefault,
168 )
168 )
169 coreconfigitem('server', 'bundle1',
169 coreconfigitem('server', 'bundle1',
170 default=True,
170 default=True,
171 )
171 )
172 coreconfigitem('server', 'bundle1gd',
172 coreconfigitem('server', 'bundle1gd',
173 default=None,
173 default=None,
174 )
174 )
175 coreconfigitem('server', 'compressionengines',
175 coreconfigitem('server', 'compressionengines',
176 default=list,
176 default=list,
177 )
177 )
178 coreconfigitem('server', 'concurrent-push-mode',
178 coreconfigitem('server', 'concurrent-push-mode',
179 default='strict',
179 default='strict',
180 )
180 )
181 coreconfigitem('server', 'disablefullbundle',
181 coreconfigitem('server', 'disablefullbundle',
182 default=False,
182 default=False,
183 )
183 )
184 coreconfigitem('server', 'maxhttpheaderlen',
184 coreconfigitem('server', 'maxhttpheaderlen',
185 default=1024,
185 default=1024,
186 )
186 )
187 coreconfigitem('server', 'preferuncompressed',
187 coreconfigitem('server', 'preferuncompressed',
188 default=False,
188 default=False,
189 )
189 )
190 coreconfigitem('server', 'uncompressedallowsecret',
190 coreconfigitem('server', 'uncompressedallowsecret',
191 default=False,
191 default=False,
192 )
192 )
193 coreconfigitem('server', 'validate',
193 coreconfigitem('server', 'validate',
194 default=False,
194 default=False,
195 )
195 )
196 coreconfigitem('server', 'zliblevel',
196 coreconfigitem('server', 'zliblevel',
197 default=-1,
197 default=-1,
198 )
198 )
199 coreconfigitem('ui', 'clonebundleprefers',
199 coreconfigitem('ui', 'clonebundleprefers',
200 default=list,
200 default=list,
201 )
201 )
202 coreconfigitem('ui', 'interactive',
202 coreconfigitem('ui', 'interactive',
203 default=None,
203 default=None,
204 )
204 )
205 coreconfigitem('ui', 'quiet',
205 coreconfigitem('ui', 'quiet',
206 default=False,
206 default=False,
207 )
207 )
208 coreconfigitem('ui', 'username',
208 coreconfigitem('ui', 'username',
209 alias=[('ui', 'user')]
209 alias=[('ui', 'user')]
210 )
210 )
211 coreconfigitem('worker', 'backgroundclose',
212 default=dynamicdefault,
213 )
211 # Windows defaults to a limit of 512 open files. A buffer of 128
214 # Windows defaults to a limit of 512 open files. A buffer of 128
212 # should give us enough headway.
215 # should give us enough headway.
213 coreconfigitem('worker', 'backgroundclosemaxqueue',
216 coreconfigitem('worker', 'backgroundclosemaxqueue',
214 default=384,
217 default=384,
215 )
218 )
216 coreconfigitem('worker', 'backgroundcloseminfilecount',
219 coreconfigitem('worker', 'backgroundcloseminfilecount',
217 default=2048,
220 default=2048,
218 )
221 )
219 coreconfigitem('worker', 'backgroundclosethreadcount',
222 coreconfigitem('worker', 'backgroundclosethreadcount',
220 default=4,
223 default=4,
221 )
224 )
222 coreconfigitem('worker', 'numcpus',
225 coreconfigitem('worker', 'numcpus',
223 default=None,
226 default=None,
224 )
227 )
General Comments 0
You need to be logged in to leave comments. Login now