Show More
@@ -1,224 +1,227 b'' | |||
|
1 | 1 | # configitems.py - centralized declaration of configuration option |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2017 Pierre-Yves David <pierre-yves.david@octobus.net> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | 8 | from __future__ import absolute_import |
|
9 | 9 | |
|
10 | 10 | import functools |
|
11 | 11 | |
|
12 | 12 | from . import ( |
|
13 | 13 | error, |
|
14 | 14 | ) |
|
15 | 15 | |
|
16 | 16 | def loadconfigtable(ui, extname, configtable): |
|
17 | 17 | """update config item known to the ui with the extension ones""" |
|
18 | 18 | for section, items in configtable.items(): |
|
19 | 19 | knownitems = ui._knownconfig.setdefault(section, {}) |
|
20 | 20 | knownkeys = set(knownitems) |
|
21 | 21 | newkeys = set(items) |
|
22 | 22 | for key in sorted(knownkeys & newkeys): |
|
23 | 23 | msg = "extension '%s' overwrite config item '%s.%s'" |
|
24 | 24 | msg %= (extname, section, key) |
|
25 | 25 | ui.develwarn(msg, config='warn-config') |
|
26 | 26 | |
|
27 | 27 | knownitems.update(items) |
|
28 | 28 | |
|
29 | 29 | class configitem(object): |
|
30 | 30 | """represent a known config item |
|
31 | 31 | |
|
32 | 32 | :section: the official config section where to find this item, |
|
33 | 33 | :name: the official name within the section, |
|
34 | 34 | :default: default value for this item, |
|
35 | 35 | :alias: optional list of tuples as alternatives. |
|
36 | 36 | """ |
|
37 | 37 | |
|
38 | 38 | def __init__(self, section, name, default=None, alias=()): |
|
39 | 39 | self.section = section |
|
40 | 40 | self.name = name |
|
41 | 41 | self.default = default |
|
42 | 42 | self.alias = list(alias) |
|
43 | 43 | |
|
44 | 44 | coreitems = {} |
|
45 | 45 | |
|
46 | 46 | def _register(configtable, *args, **kwargs): |
|
47 | 47 | item = configitem(*args, **kwargs) |
|
48 | 48 | section = configtable.setdefault(item.section, {}) |
|
49 | 49 | if item.name in section: |
|
50 | 50 | msg = "duplicated config item registration for '%s.%s'" |
|
51 | 51 | raise error.ProgrammingError(msg % (item.section, item.name)) |
|
52 | 52 | section[item.name] = item |
|
53 | 53 | |
|
54 | 54 | # special value for case where the default is derived from other values |
|
55 | 55 | dynamicdefault = object() |
|
56 | 56 | |
|
57 | 57 | # Registering actual config items |
|
58 | 58 | |
|
59 | 59 | def getitemregister(configtable): |
|
60 | 60 | return functools.partial(_register, configtable) |
|
61 | 61 | |
|
62 | 62 | coreconfigitem = getitemregister(coreitems) |
|
63 | 63 | |
|
64 | 64 | coreconfigitem('auth', 'cookiefile', |
|
65 | 65 | default=None, |
|
66 | 66 | ) |
|
67 | 67 | # bookmarks.pushing: internal hack for discovery |
|
68 | 68 | coreconfigitem('bookmarks', 'pushing', |
|
69 | 69 | default=list, |
|
70 | 70 | ) |
|
71 | 71 | # bundle.mainreporoot: internal hack for bundlerepo |
|
72 | 72 | coreconfigitem('bundle', 'mainreporoot', |
|
73 | 73 | default='', |
|
74 | 74 | ) |
|
75 | 75 | # bundle.reorder: experimental config |
|
76 | 76 | coreconfigitem('bundle', 'reorder', |
|
77 | 77 | default='auto', |
|
78 | 78 | ) |
|
79 | 79 | coreconfigitem('color', 'mode', |
|
80 | 80 | default='auto', |
|
81 | 81 | ) |
|
82 | 82 | coreconfigitem('color', 'pagermode', |
|
83 | 83 | default=dynamicdefault, |
|
84 | 84 | ) |
|
85 | 85 | coreconfigitem('devel', 'all-warnings', |
|
86 | 86 | default=False, |
|
87 | 87 | ) |
|
88 | 88 | coreconfigitem('devel', 'bundle2.debug', |
|
89 | 89 | default=False, |
|
90 | 90 | ) |
|
91 | 91 | coreconfigitem('devel', 'check-locks', |
|
92 | 92 | default=False, |
|
93 | 93 | ) |
|
94 | 94 | coreconfigitem('devel', 'check-relroot', |
|
95 | 95 | default=False, |
|
96 | 96 | ) |
|
97 | 97 | coreconfigitem('devel', 'disableloaddefaultcerts', |
|
98 | 98 | default=False, |
|
99 | 99 | ) |
|
100 | 100 | coreconfigitem('devel', 'legacy.exchange', |
|
101 | 101 | default=list, |
|
102 | 102 | ) |
|
103 | 103 | coreconfigitem('devel', 'servercafile', |
|
104 | 104 | default='', |
|
105 | 105 | ) |
|
106 | 106 | coreconfigitem('devel', 'serverexactprotocol', |
|
107 | 107 | default='', |
|
108 | 108 | ) |
|
109 | 109 | coreconfigitem('devel', 'serverrequirecert', |
|
110 | 110 | default=False, |
|
111 | 111 | ) |
|
112 | 112 | coreconfigitem('devel', 'strip-obsmarkers', |
|
113 | 113 | default=True, |
|
114 | 114 | ) |
|
115 | 115 | coreconfigitem('format', 'aggressivemergedeltas', |
|
116 | 116 | default=False, |
|
117 | 117 | ) |
|
118 | 118 | coreconfigitem('format', 'chunkcachesize', |
|
119 | 119 | default=None, |
|
120 | 120 | ) |
|
121 | 121 | coreconfigitem('format', 'dotencode', |
|
122 | 122 | default=True, |
|
123 | 123 | ) |
|
124 | 124 | coreconfigitem('format', 'generaldelta', |
|
125 | 125 | default=False, |
|
126 | 126 | ) |
|
127 | 127 | coreconfigitem('format', 'manifestcachesize', |
|
128 | 128 | default=None, |
|
129 | 129 | ) |
|
130 | 130 | coreconfigitem('format', 'maxchainlen', |
|
131 | 131 | default=None, |
|
132 | 132 | ) |
|
133 | 133 | coreconfigitem('format', 'obsstore-version', |
|
134 | 134 | default=None, |
|
135 | 135 | ) |
|
136 | 136 | coreconfigitem('format', 'usefncache', |
|
137 | 137 | default=True, |
|
138 | 138 | ) |
|
139 | 139 | coreconfigitem('format', 'usegeneraldelta', |
|
140 | 140 | default=True, |
|
141 | 141 | ) |
|
142 | 142 | coreconfigitem('format', 'usestore', |
|
143 | 143 | default=True, |
|
144 | 144 | ) |
|
145 | 145 | coreconfigitem('hostsecurity', 'ciphers', |
|
146 | 146 | default=None, |
|
147 | 147 | ) |
|
148 | 148 | coreconfigitem('hostsecurity', 'disabletls10warning', |
|
149 | 149 | default=False, |
|
150 | 150 | ) |
|
151 | 151 | coreconfigitem('patch', 'eol', |
|
152 | 152 | default='strict', |
|
153 | 153 | ) |
|
154 | 154 | coreconfigitem('patch', 'fuzz', |
|
155 | 155 | default=2, |
|
156 | 156 | ) |
|
157 | 157 | coreconfigitem('progress', 'assume-tty', |
|
158 | 158 | default=False, |
|
159 | 159 | ) |
|
160 | 160 | coreconfigitem('progress', 'clear-complete', |
|
161 | 161 | default=True, |
|
162 | 162 | ) |
|
163 | 163 | coreconfigitem('progress', 'estimate', |
|
164 | 164 | default=2, |
|
165 | 165 | ) |
|
166 | 166 | coreconfigitem('progress', 'width', |
|
167 | 167 | default=dynamicdefault, |
|
168 | 168 | ) |
|
169 | 169 | coreconfigitem('server', 'bundle1', |
|
170 | 170 | default=True, |
|
171 | 171 | ) |
|
172 | 172 | coreconfigitem('server', 'bundle1gd', |
|
173 | 173 | default=None, |
|
174 | 174 | ) |
|
175 | 175 | coreconfigitem('server', 'compressionengines', |
|
176 | 176 | default=list, |
|
177 | 177 | ) |
|
178 | 178 | coreconfigitem('server', 'concurrent-push-mode', |
|
179 | 179 | default='strict', |
|
180 | 180 | ) |
|
181 | 181 | coreconfigitem('server', 'disablefullbundle', |
|
182 | 182 | default=False, |
|
183 | 183 | ) |
|
184 | 184 | coreconfigitem('server', 'maxhttpheaderlen', |
|
185 | 185 | default=1024, |
|
186 | 186 | ) |
|
187 | 187 | coreconfigitem('server', 'preferuncompressed', |
|
188 | 188 | default=False, |
|
189 | 189 | ) |
|
190 | 190 | coreconfigitem('server', 'uncompressedallowsecret', |
|
191 | 191 | default=False, |
|
192 | 192 | ) |
|
193 | 193 | coreconfigitem('server', 'validate', |
|
194 | 194 | default=False, |
|
195 | 195 | ) |
|
196 | 196 | coreconfigitem('server', 'zliblevel', |
|
197 | 197 | default=-1, |
|
198 | 198 | ) |
|
199 | 199 | coreconfigitem('ui', 'clonebundleprefers', |
|
200 | 200 | default=list, |
|
201 | 201 | ) |
|
202 | 202 | coreconfigitem('ui', 'interactive', |
|
203 | 203 | default=None, |
|
204 | 204 | ) |
|
205 | 205 | coreconfigitem('ui', 'quiet', |
|
206 | 206 | default=False, |
|
207 | 207 | ) |
|
208 | 208 | coreconfigitem('ui', 'username', |
|
209 | 209 | alias=[('ui', 'user')] |
|
210 | 210 | ) |
|
211 | coreconfigitem('worker', 'backgroundclose', | |
|
212 | default=dynamicdefault, | |
|
213 | ) | |
|
211 | 214 | # Windows defaults to a limit of 512 open files. A buffer of 128 |
|
212 | 215 | # should give us enough headway. |
|
213 | 216 | coreconfigitem('worker', 'backgroundclosemaxqueue', |
|
214 | 217 | default=384, |
|
215 | 218 | ) |
|
216 | 219 | coreconfigitem('worker', 'backgroundcloseminfilecount', |
|
217 | 220 | default=2048, |
|
218 | 221 | ) |
|
219 | 222 | coreconfigitem('worker', 'backgroundclosethreadcount', |
|
220 | 223 | default=4, |
|
221 | 224 | ) |
|
222 | 225 | coreconfigitem('worker', 'numcpus', |
|
223 | 226 | default=None, |
|
224 | 227 | ) |
General Comments 0
You need to be logged in to leave comments.
Login now