Show More
@@ -1,218 +1,221 | |||
|
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 | coreconfigitem('color', 'pagermode', | |
|
83 | default=dynamicdefault, | |
|
84 | ) | |
|
82 | 85 | coreconfigitem('devel', 'all-warnings', |
|
83 | 86 | default=False, |
|
84 | 87 | ) |
|
85 | 88 | coreconfigitem('devel', 'bundle2.debug', |
|
86 | 89 | default=False, |
|
87 | 90 | ) |
|
88 | 91 | coreconfigitem('devel', 'check-locks', |
|
89 | 92 | default=False, |
|
90 | 93 | ) |
|
91 | 94 | coreconfigitem('devel', 'check-relroot', |
|
92 | 95 | default=False, |
|
93 | 96 | ) |
|
94 | 97 | coreconfigitem('devel', 'disableloaddefaultcerts', |
|
95 | 98 | default=False, |
|
96 | 99 | ) |
|
97 | 100 | coreconfigitem('devel', 'legacy.exchange', |
|
98 | 101 | default=list, |
|
99 | 102 | ) |
|
100 | 103 | coreconfigitem('devel', 'servercafile', |
|
101 | 104 | default='', |
|
102 | 105 | ) |
|
103 | 106 | coreconfigitem('devel', 'serverexactprotocol', |
|
104 | 107 | default='', |
|
105 | 108 | ) |
|
106 | 109 | coreconfigitem('devel', 'serverrequirecert', |
|
107 | 110 | default=False, |
|
108 | 111 | ) |
|
109 | 112 | coreconfigitem('devel', 'strip-obsmarkers', |
|
110 | 113 | default=True, |
|
111 | 114 | ) |
|
112 | 115 | coreconfigitem('format', 'aggressivemergedeltas', |
|
113 | 116 | default=False, |
|
114 | 117 | ) |
|
115 | 118 | coreconfigitem('format', 'chunkcachesize', |
|
116 | 119 | default=None, |
|
117 | 120 | ) |
|
118 | 121 | coreconfigitem('format', 'dotencode', |
|
119 | 122 | default=True, |
|
120 | 123 | ) |
|
121 | 124 | coreconfigitem('format', 'generaldelta', |
|
122 | 125 | default=False, |
|
123 | 126 | ) |
|
124 | 127 | coreconfigitem('format', 'manifestcachesize', |
|
125 | 128 | default=None, |
|
126 | 129 | ) |
|
127 | 130 | coreconfigitem('format', 'maxchainlen', |
|
128 | 131 | default=None, |
|
129 | 132 | ) |
|
130 | 133 | coreconfigitem('format', 'obsstore-version', |
|
131 | 134 | default=None, |
|
132 | 135 | ) |
|
133 | 136 | coreconfigitem('format', 'usefncache', |
|
134 | 137 | default=True, |
|
135 | 138 | ) |
|
136 | 139 | coreconfigitem('format', 'usegeneraldelta', |
|
137 | 140 | default=True, |
|
138 | 141 | ) |
|
139 | 142 | coreconfigitem('format', 'usestore', |
|
140 | 143 | default=True, |
|
141 | 144 | ) |
|
142 | 145 | coreconfigitem('hostsecurity', 'ciphers', |
|
143 | 146 | default=None, |
|
144 | 147 | ) |
|
145 | 148 | coreconfigitem('hostsecurity', 'disabletls10warning', |
|
146 | 149 | default=False, |
|
147 | 150 | ) |
|
148 | 151 | coreconfigitem('patch', 'eol', |
|
149 | 152 | default='strict', |
|
150 | 153 | ) |
|
151 | 154 | coreconfigitem('patch', 'fuzz', |
|
152 | 155 | default=2, |
|
153 | 156 | ) |
|
154 | 157 | coreconfigitem('progress', 'assume-tty', |
|
155 | 158 | default=False, |
|
156 | 159 | ) |
|
157 | 160 | coreconfigitem('progress', 'clear-complete', |
|
158 | 161 | default=True, |
|
159 | 162 | ) |
|
160 | 163 | coreconfigitem('progress', 'estimate', |
|
161 | 164 | default=2, |
|
162 | 165 | ) |
|
163 | 166 | coreconfigitem('server', 'bundle1', |
|
164 | 167 | default=True, |
|
165 | 168 | ) |
|
166 | 169 | coreconfigitem('server', 'bundle1gd', |
|
167 | 170 | default=None, |
|
168 | 171 | ) |
|
169 | 172 | coreconfigitem('server', 'compressionengines', |
|
170 | 173 | default=list, |
|
171 | 174 | ) |
|
172 | 175 | coreconfigitem('server', 'concurrent-push-mode', |
|
173 | 176 | default='strict', |
|
174 | 177 | ) |
|
175 | 178 | coreconfigitem('server', 'disablefullbundle', |
|
176 | 179 | default=False, |
|
177 | 180 | ) |
|
178 | 181 | coreconfigitem('server', 'maxhttpheaderlen', |
|
179 | 182 | default=1024, |
|
180 | 183 | ) |
|
181 | 184 | coreconfigitem('server', 'preferuncompressed', |
|
182 | 185 | default=False, |
|
183 | 186 | ) |
|
184 | 187 | coreconfigitem('server', 'uncompressedallowsecret', |
|
185 | 188 | default=False, |
|
186 | 189 | ) |
|
187 | 190 | coreconfigitem('server', 'validate', |
|
188 | 191 | default=False, |
|
189 | 192 | ) |
|
190 | 193 | coreconfigitem('server', 'zliblevel', |
|
191 | 194 | default=-1, |
|
192 | 195 | ) |
|
193 | 196 | coreconfigitem('ui', 'clonebundleprefers', |
|
194 | 197 | default=list, |
|
195 | 198 | ) |
|
196 | 199 | coreconfigitem('ui', 'interactive', |
|
197 | 200 | default=None, |
|
198 | 201 | ) |
|
199 | 202 | coreconfigitem('ui', 'quiet', |
|
200 | 203 | default=False, |
|
201 | 204 | ) |
|
202 | 205 | coreconfigitem('ui', 'username', |
|
203 | 206 | alias=[('ui', 'user')] |
|
204 | 207 | ) |
|
205 | 208 | # Windows defaults to a limit of 512 open files. A buffer of 128 |
|
206 | 209 | # should give us enough headway. |
|
207 | 210 | coreconfigitem('worker', 'backgroundclosemaxqueue', |
|
208 | 211 | default=384, |
|
209 | 212 | ) |
|
210 | 213 | coreconfigitem('worker', 'backgroundcloseminfilecount', |
|
211 | 214 | default=2048, |
|
212 | 215 | ) |
|
213 | 216 | coreconfigitem('worker', 'backgroundclosethreadcount', |
|
214 | 217 | default=4, |
|
215 | 218 | ) |
|
216 | 219 | coreconfigitem('worker', 'numcpus', |
|
217 | 220 | default=None, |
|
218 | 221 | ) |
General Comments 0
You need to be logged in to leave comments.
Login now