##// END OF EJS Templates
configitems: register the 'ui.color' config
Boris Feld -
r33522:62b29ca7 default
parent child Browse files
Show More
@@ -1,518 +1,518 b''
1 # utility for color output for Mercurial commands
1 # utility for color output for Mercurial commands
2 #
2 #
3 # Copyright (C) 2007 Kevin Christen <kevin.christen@gmail.com> and other
3 # Copyright (C) 2007 Kevin Christen <kevin.christen@gmail.com> and other
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 re
10 import re
11
11
12 from .i18n import _
12 from .i18n import _
13
13
14 from . import (
14 from . import (
15 encoding,
15 encoding,
16 pycompat,
16 pycompat,
17 util
17 util
18 )
18 )
19
19
20 try:
20 try:
21 import curses
21 import curses
22 # Mapping from effect name to terminfo attribute name (or raw code) or
22 # Mapping from effect name to terminfo attribute name (or raw code) or
23 # color number. This will also force-load the curses module.
23 # color number. This will also force-load the curses module.
24 _baseterminfoparams = {
24 _baseterminfoparams = {
25 'none': (True, 'sgr0', ''),
25 'none': (True, 'sgr0', ''),
26 'standout': (True, 'smso', ''),
26 'standout': (True, 'smso', ''),
27 'underline': (True, 'smul', ''),
27 'underline': (True, 'smul', ''),
28 'reverse': (True, 'rev', ''),
28 'reverse': (True, 'rev', ''),
29 'inverse': (True, 'rev', ''),
29 'inverse': (True, 'rev', ''),
30 'blink': (True, 'blink', ''),
30 'blink': (True, 'blink', ''),
31 'dim': (True, 'dim', ''),
31 'dim': (True, 'dim', ''),
32 'bold': (True, 'bold', ''),
32 'bold': (True, 'bold', ''),
33 'invisible': (True, 'invis', ''),
33 'invisible': (True, 'invis', ''),
34 'italic': (True, 'sitm', ''),
34 'italic': (True, 'sitm', ''),
35 'black': (False, curses.COLOR_BLACK, ''),
35 'black': (False, curses.COLOR_BLACK, ''),
36 'red': (False, curses.COLOR_RED, ''),
36 'red': (False, curses.COLOR_RED, ''),
37 'green': (False, curses.COLOR_GREEN, ''),
37 'green': (False, curses.COLOR_GREEN, ''),
38 'yellow': (False, curses.COLOR_YELLOW, ''),
38 'yellow': (False, curses.COLOR_YELLOW, ''),
39 'blue': (False, curses.COLOR_BLUE, ''),
39 'blue': (False, curses.COLOR_BLUE, ''),
40 'magenta': (False, curses.COLOR_MAGENTA, ''),
40 'magenta': (False, curses.COLOR_MAGENTA, ''),
41 'cyan': (False, curses.COLOR_CYAN, ''),
41 'cyan': (False, curses.COLOR_CYAN, ''),
42 'white': (False, curses.COLOR_WHITE, ''),
42 'white': (False, curses.COLOR_WHITE, ''),
43 }
43 }
44 except ImportError:
44 except ImportError:
45 curses = None
45 curses = None
46 _baseterminfoparams = {}
46 _baseterminfoparams = {}
47
47
48 # start and stop parameters for effects
48 # start and stop parameters for effects
49 _effects = {
49 _effects = {
50 'none': 0,
50 'none': 0,
51 'black': 30,
51 'black': 30,
52 'red': 31,
52 'red': 31,
53 'green': 32,
53 'green': 32,
54 'yellow': 33,
54 'yellow': 33,
55 'blue': 34,
55 'blue': 34,
56 'magenta': 35,
56 'magenta': 35,
57 'cyan': 36,
57 'cyan': 36,
58 'white': 37,
58 'white': 37,
59 'bold': 1,
59 'bold': 1,
60 'italic': 3,
60 'italic': 3,
61 'underline': 4,
61 'underline': 4,
62 'inverse': 7,
62 'inverse': 7,
63 'dim': 2,
63 'dim': 2,
64 'black_background': 40,
64 'black_background': 40,
65 'red_background': 41,
65 'red_background': 41,
66 'green_background': 42,
66 'green_background': 42,
67 'yellow_background': 43,
67 'yellow_background': 43,
68 'blue_background': 44,
68 'blue_background': 44,
69 'purple_background': 45,
69 'purple_background': 45,
70 'cyan_background': 46,
70 'cyan_background': 46,
71 'white_background': 47,
71 'white_background': 47,
72 }
72 }
73
73
74 _defaultstyles = {
74 _defaultstyles = {
75 'grep.match': 'red bold',
75 'grep.match': 'red bold',
76 'grep.linenumber': 'green',
76 'grep.linenumber': 'green',
77 'grep.rev': 'green',
77 'grep.rev': 'green',
78 'grep.change': 'green',
78 'grep.change': 'green',
79 'grep.sep': 'cyan',
79 'grep.sep': 'cyan',
80 'grep.filename': 'magenta',
80 'grep.filename': 'magenta',
81 'grep.user': 'magenta',
81 'grep.user': 'magenta',
82 'grep.date': 'magenta',
82 'grep.date': 'magenta',
83 'bookmarks.active': 'green',
83 'bookmarks.active': 'green',
84 'branches.active': 'none',
84 'branches.active': 'none',
85 'branches.closed': 'black bold',
85 'branches.closed': 'black bold',
86 'branches.current': 'green',
86 'branches.current': 'green',
87 'branches.inactive': 'none',
87 'branches.inactive': 'none',
88 'diff.changed': 'white',
88 'diff.changed': 'white',
89 'diff.deleted': 'red',
89 'diff.deleted': 'red',
90 'diff.diffline': 'bold',
90 'diff.diffline': 'bold',
91 'diff.extended': 'cyan bold',
91 'diff.extended': 'cyan bold',
92 'diff.file_a': 'red bold',
92 'diff.file_a': 'red bold',
93 'diff.file_b': 'green bold',
93 'diff.file_b': 'green bold',
94 'diff.hunk': 'magenta',
94 'diff.hunk': 'magenta',
95 'diff.inserted': 'green',
95 'diff.inserted': 'green',
96 'diff.tab': '',
96 'diff.tab': '',
97 'diff.trailingwhitespace': 'bold red_background',
97 'diff.trailingwhitespace': 'bold red_background',
98 'changeset.public' : '',
98 'changeset.public' : '',
99 'changeset.draft' : '',
99 'changeset.draft' : '',
100 'changeset.secret' : '',
100 'changeset.secret' : '',
101 'diffstat.deleted': 'red',
101 'diffstat.deleted': 'red',
102 'diffstat.inserted': 'green',
102 'diffstat.inserted': 'green',
103 'histedit.remaining': 'red bold',
103 'histedit.remaining': 'red bold',
104 'ui.prompt': 'yellow',
104 'ui.prompt': 'yellow',
105 'log.changeset': 'yellow',
105 'log.changeset': 'yellow',
106 'patchbomb.finalsummary': '',
106 'patchbomb.finalsummary': '',
107 'patchbomb.from': 'magenta',
107 'patchbomb.from': 'magenta',
108 'patchbomb.to': 'cyan',
108 'patchbomb.to': 'cyan',
109 'patchbomb.subject': 'green',
109 'patchbomb.subject': 'green',
110 'patchbomb.diffstats': '',
110 'patchbomb.diffstats': '',
111 'rebase.rebased': 'blue',
111 'rebase.rebased': 'blue',
112 'rebase.remaining': 'red bold',
112 'rebase.remaining': 'red bold',
113 'resolve.resolved': 'green bold',
113 'resolve.resolved': 'green bold',
114 'resolve.unresolved': 'red bold',
114 'resolve.unresolved': 'red bold',
115 'shelve.age': 'cyan',
115 'shelve.age': 'cyan',
116 'shelve.newest': 'green bold',
116 'shelve.newest': 'green bold',
117 'shelve.name': 'blue bold',
117 'shelve.name': 'blue bold',
118 'status.added': 'green bold',
118 'status.added': 'green bold',
119 'status.clean': 'none',
119 'status.clean': 'none',
120 'status.copied': 'none',
120 'status.copied': 'none',
121 'status.deleted': 'cyan bold underline',
121 'status.deleted': 'cyan bold underline',
122 'status.ignored': 'black bold',
122 'status.ignored': 'black bold',
123 'status.modified': 'blue bold',
123 'status.modified': 'blue bold',
124 'status.removed': 'red bold',
124 'status.removed': 'red bold',
125 'status.unknown': 'magenta bold underline',
125 'status.unknown': 'magenta bold underline',
126 'tags.normal': 'green',
126 'tags.normal': 'green',
127 'tags.local': 'black bold',
127 'tags.local': 'black bold',
128 }
128 }
129
129
130 def loadcolortable(ui, extname, colortable):
130 def loadcolortable(ui, extname, colortable):
131 _defaultstyles.update(colortable)
131 _defaultstyles.update(colortable)
132
132
133 def _terminfosetup(ui, mode):
133 def _terminfosetup(ui, mode):
134 '''Initialize terminfo data and the terminal if we're in terminfo mode.'''
134 '''Initialize terminfo data and the terminal if we're in terminfo mode.'''
135
135
136 # If we failed to load curses, we go ahead and return.
136 # If we failed to load curses, we go ahead and return.
137 if curses is None:
137 if curses is None:
138 return
138 return
139 # Otherwise, see what the config file says.
139 # Otherwise, see what the config file says.
140 if mode not in ('auto', 'terminfo'):
140 if mode not in ('auto', 'terminfo'):
141 return
141 return
142 ui._terminfoparams.update(_baseterminfoparams)
142 ui._terminfoparams.update(_baseterminfoparams)
143
143
144 for key, val in ui.configitems('color'):
144 for key, val in ui.configitems('color'):
145 if key.startswith('color.'):
145 if key.startswith('color.'):
146 newval = (False, int(val), '')
146 newval = (False, int(val), '')
147 ui._terminfoparams[key[6:]] = newval
147 ui._terminfoparams[key[6:]] = newval
148 elif key.startswith('terminfo.'):
148 elif key.startswith('terminfo.'):
149 newval = (True, '', val.replace('\\E', '\x1b'))
149 newval = (True, '', val.replace('\\E', '\x1b'))
150 ui._terminfoparams[key[9:]] = newval
150 ui._terminfoparams[key[9:]] = newval
151 try:
151 try:
152 curses.setupterm()
152 curses.setupterm()
153 except curses.error as e:
153 except curses.error as e:
154 ui._terminfoparams.clear()
154 ui._terminfoparams.clear()
155 return
155 return
156
156
157 for key, (b, e, c) in ui._terminfoparams.items():
157 for key, (b, e, c) in ui._terminfoparams.items():
158 if not b:
158 if not b:
159 continue
159 continue
160 if not c and not curses.tigetstr(e):
160 if not c and not curses.tigetstr(e):
161 # Most terminals don't support dim, invis, etc, so don't be
161 # Most terminals don't support dim, invis, etc, so don't be
162 # noisy and use ui.debug().
162 # noisy and use ui.debug().
163 ui.debug("no terminfo entry for %s\n" % e)
163 ui.debug("no terminfo entry for %s\n" % e)
164 del ui._terminfoparams[key]
164 del ui._terminfoparams[key]
165 if not curses.tigetstr('setaf') or not curses.tigetstr('setab'):
165 if not curses.tigetstr('setaf') or not curses.tigetstr('setab'):
166 # Only warn about missing terminfo entries if we explicitly asked for
166 # Only warn about missing terminfo entries if we explicitly asked for
167 # terminfo mode.
167 # terminfo mode.
168 if mode == "terminfo":
168 if mode == "terminfo":
169 ui.warn(_("no terminfo entry for setab/setaf: reverting to "
169 ui.warn(_("no terminfo entry for setab/setaf: reverting to "
170 "ECMA-48 color\n"))
170 "ECMA-48 color\n"))
171 ui._terminfoparams.clear()
171 ui._terminfoparams.clear()
172
172
173 def setup(ui):
173 def setup(ui):
174 """configure color on a ui
174 """configure color on a ui
175
175
176 That function both set the colormode for the ui object and read
176 That function both set the colormode for the ui object and read
177 the configuration looking for custom colors and effect definitions."""
177 the configuration looking for custom colors and effect definitions."""
178 mode = _modesetup(ui)
178 mode = _modesetup(ui)
179 ui._colormode = mode
179 ui._colormode = mode
180 if mode and mode != 'debug':
180 if mode and mode != 'debug':
181 configstyles(ui)
181 configstyles(ui)
182
182
183 def _modesetup(ui):
183 def _modesetup(ui):
184 if ui.plain():
184 if ui.plain():
185 return None
185 return None
186 config = ui.config('ui', 'color', 'auto')
186 config = ui.config('ui', 'color')
187 if config == 'debug':
187 if config == 'debug':
188 return 'debug'
188 return 'debug'
189
189
190 auto = (config == 'auto')
190 auto = (config == 'auto')
191 always = False
191 always = False
192 if not auto and util.parsebool(config):
192 if not auto and util.parsebool(config):
193 # We want the config to behave like a boolean, "on" is actually auto,
193 # We want the config to behave like a boolean, "on" is actually auto,
194 # but "always" value is treated as a special case to reduce confusion.
194 # but "always" value is treated as a special case to reduce confusion.
195 if ui.configsource('ui', 'color') == '--color' or config == 'always':
195 if ui.configsource('ui', 'color') == '--color' or config == 'always':
196 always = True
196 always = True
197 else:
197 else:
198 auto = True
198 auto = True
199
199
200 if not always and not auto:
200 if not always and not auto:
201 return None
201 return None
202
202
203 formatted = (always or (encoding.environ.get('TERM') != 'dumb'
203 formatted = (always or (encoding.environ.get('TERM') != 'dumb'
204 and ui.formatted()))
204 and ui.formatted()))
205
205
206 mode = ui.config('color', 'mode')
206 mode = ui.config('color', 'mode')
207
207
208 # If pager is active, color.pagermode overrides color.mode.
208 # If pager is active, color.pagermode overrides color.mode.
209 if getattr(ui, 'pageractive', False):
209 if getattr(ui, 'pageractive', False):
210 mode = ui.config('color', 'pagermode', mode)
210 mode = ui.config('color', 'pagermode', mode)
211
211
212 realmode = mode
212 realmode = mode
213 if pycompat.osname == 'nt':
213 if pycompat.osname == 'nt':
214 from . import win32
214 from . import win32
215
215
216 term = encoding.environ.get('TERM')
216 term = encoding.environ.get('TERM')
217 # TERM won't be defined in a vanilla cmd.exe environment.
217 # TERM won't be defined in a vanilla cmd.exe environment.
218
218
219 # UNIX-like environments on Windows such as Cygwin and MSYS will
219 # UNIX-like environments on Windows such as Cygwin and MSYS will
220 # set TERM. They appear to make a best effort attempt at setting it
220 # set TERM. They appear to make a best effort attempt at setting it
221 # to something appropriate. However, not all environments with TERM
221 # to something appropriate. However, not all environments with TERM
222 # defined support ANSI.
222 # defined support ANSI.
223 ansienviron = term and 'xterm' in term
223 ansienviron = term and 'xterm' in term
224
224
225 if mode == 'auto':
225 if mode == 'auto':
226 # Since "ansi" could result in terminal gibberish, we error on the
226 # Since "ansi" could result in terminal gibberish, we error on the
227 # side of selecting "win32". However, if w32effects is not defined,
227 # side of selecting "win32". However, if w32effects is not defined,
228 # we almost certainly don't support "win32", so don't even try.
228 # we almost certainly don't support "win32", so don't even try.
229 # w32ffects is not populated when stdout is redirected, so checking
229 # w32ffects is not populated when stdout is redirected, so checking
230 # it first avoids win32 calls in a state known to error out.
230 # it first avoids win32 calls in a state known to error out.
231 if ansienviron or not w32effects or win32.enablevtmode():
231 if ansienviron or not w32effects or win32.enablevtmode():
232 realmode = 'ansi'
232 realmode = 'ansi'
233 else:
233 else:
234 realmode = 'win32'
234 realmode = 'win32'
235 # An empty w32effects is a clue that stdout is redirected, and thus
235 # An empty w32effects is a clue that stdout is redirected, and thus
236 # cannot enable VT mode.
236 # cannot enable VT mode.
237 elif mode == 'ansi' and w32effects and not ansienviron:
237 elif mode == 'ansi' and w32effects and not ansienviron:
238 win32.enablevtmode()
238 win32.enablevtmode()
239 elif mode == 'auto':
239 elif mode == 'auto':
240 realmode = 'ansi'
240 realmode = 'ansi'
241
241
242 def modewarn():
242 def modewarn():
243 # only warn if color.mode was explicitly set and we're in
243 # only warn if color.mode was explicitly set and we're in
244 # a formatted terminal
244 # a formatted terminal
245 if mode == realmode and ui.formatted():
245 if mode == realmode and ui.formatted():
246 ui.warn(_('warning: failed to set color mode to %s\n') % mode)
246 ui.warn(_('warning: failed to set color mode to %s\n') % mode)
247
247
248 if realmode == 'win32':
248 if realmode == 'win32':
249 ui._terminfoparams.clear()
249 ui._terminfoparams.clear()
250 if not w32effects:
250 if not w32effects:
251 modewarn()
251 modewarn()
252 return None
252 return None
253 elif realmode == 'ansi':
253 elif realmode == 'ansi':
254 ui._terminfoparams.clear()
254 ui._terminfoparams.clear()
255 elif realmode == 'terminfo':
255 elif realmode == 'terminfo':
256 _terminfosetup(ui, mode)
256 _terminfosetup(ui, mode)
257 if not ui._terminfoparams:
257 if not ui._terminfoparams:
258 ## FIXME Shouldn't we return None in this case too?
258 ## FIXME Shouldn't we return None in this case too?
259 modewarn()
259 modewarn()
260 realmode = 'ansi'
260 realmode = 'ansi'
261 else:
261 else:
262 return None
262 return None
263
263
264 if always or (auto and formatted):
264 if always or (auto and formatted):
265 return realmode
265 return realmode
266 return None
266 return None
267
267
268 def configstyles(ui):
268 def configstyles(ui):
269 ui._styles.update(_defaultstyles)
269 ui._styles.update(_defaultstyles)
270 for status, cfgeffects in ui.configitems('color'):
270 for status, cfgeffects in ui.configitems('color'):
271 if '.' not in status or status.startswith(('color.', 'terminfo.')):
271 if '.' not in status or status.startswith(('color.', 'terminfo.')):
272 continue
272 continue
273 cfgeffects = ui.configlist('color', status)
273 cfgeffects = ui.configlist('color', status)
274 if cfgeffects:
274 if cfgeffects:
275 good = []
275 good = []
276 for e in cfgeffects:
276 for e in cfgeffects:
277 if valideffect(ui, e):
277 if valideffect(ui, e):
278 good.append(e)
278 good.append(e)
279 else:
279 else:
280 ui.warn(_("ignoring unknown color/effect %r "
280 ui.warn(_("ignoring unknown color/effect %r "
281 "(configured in color.%s)\n")
281 "(configured in color.%s)\n")
282 % (e, status))
282 % (e, status))
283 ui._styles[status] = ' '.join(good)
283 ui._styles[status] = ' '.join(good)
284
284
285 def _activeeffects(ui):
285 def _activeeffects(ui):
286 '''Return the effects map for the color mode set on the ui.'''
286 '''Return the effects map for the color mode set on the ui.'''
287 if ui._colormode == 'win32':
287 if ui._colormode == 'win32':
288 return w32effects
288 return w32effects
289 elif ui._colormode is not None:
289 elif ui._colormode is not None:
290 return _effects
290 return _effects
291 return {}
291 return {}
292
292
293 def valideffect(ui, effect):
293 def valideffect(ui, effect):
294 'Determine if the effect is valid or not.'
294 'Determine if the effect is valid or not.'
295 return ((not ui._terminfoparams and effect in _activeeffects(ui))
295 return ((not ui._terminfoparams and effect in _activeeffects(ui))
296 or (effect in ui._terminfoparams
296 or (effect in ui._terminfoparams
297 or effect[:-11] in ui._terminfoparams))
297 or effect[:-11] in ui._terminfoparams))
298
298
299 def _effect_str(ui, effect):
299 def _effect_str(ui, effect):
300 '''Helper function for render_effects().'''
300 '''Helper function for render_effects().'''
301
301
302 bg = False
302 bg = False
303 if effect.endswith('_background'):
303 if effect.endswith('_background'):
304 bg = True
304 bg = True
305 effect = effect[:-11]
305 effect = effect[:-11]
306 try:
306 try:
307 attr, val, termcode = ui._terminfoparams[effect]
307 attr, val, termcode = ui._terminfoparams[effect]
308 except KeyError:
308 except KeyError:
309 return ''
309 return ''
310 if attr:
310 if attr:
311 if termcode:
311 if termcode:
312 return termcode
312 return termcode
313 else:
313 else:
314 return curses.tigetstr(val)
314 return curses.tigetstr(val)
315 elif bg:
315 elif bg:
316 return curses.tparm(curses.tigetstr('setab'), val)
316 return curses.tparm(curses.tigetstr('setab'), val)
317 else:
317 else:
318 return curses.tparm(curses.tigetstr('setaf'), val)
318 return curses.tparm(curses.tigetstr('setaf'), val)
319
319
320 def _mergeeffects(text, start, stop):
320 def _mergeeffects(text, start, stop):
321 """Insert start sequence at every occurrence of stop sequence
321 """Insert start sequence at every occurrence of stop sequence
322
322
323 >>> s = _mergeeffects('cyan', '[C]', '|')
323 >>> s = _mergeeffects('cyan', '[C]', '|')
324 >>> s = _mergeeffects(s + 'yellow', '[Y]', '|')
324 >>> s = _mergeeffects(s + 'yellow', '[Y]', '|')
325 >>> s = _mergeeffects('ma' + s + 'genta', '[M]', '|')
325 >>> s = _mergeeffects('ma' + s + 'genta', '[M]', '|')
326 >>> s = _mergeeffects('red' + s, '[R]', '|')
326 >>> s = _mergeeffects('red' + s, '[R]', '|')
327 >>> s
327 >>> s
328 '[R]red[M]ma[Y][C]cyan|[R][M][Y]yellow|[R][M]genta|'
328 '[R]red[M]ma[Y][C]cyan|[R][M][Y]yellow|[R][M]genta|'
329 """
329 """
330 parts = []
330 parts = []
331 for t in text.split(stop):
331 for t in text.split(stop):
332 if not t:
332 if not t:
333 continue
333 continue
334 parts.extend([start, t, stop])
334 parts.extend([start, t, stop])
335 return ''.join(parts)
335 return ''.join(parts)
336
336
337 def _render_effects(ui, text, effects):
337 def _render_effects(ui, text, effects):
338 'Wrap text in commands to turn on each effect.'
338 'Wrap text in commands to turn on each effect.'
339 if not text:
339 if not text:
340 return text
340 return text
341 if ui._terminfoparams:
341 if ui._terminfoparams:
342 start = ''.join(_effect_str(ui, effect)
342 start = ''.join(_effect_str(ui, effect)
343 for effect in ['none'] + effects.split())
343 for effect in ['none'] + effects.split())
344 stop = _effect_str(ui, 'none')
344 stop = _effect_str(ui, 'none')
345 else:
345 else:
346 activeeffects = _activeeffects(ui)
346 activeeffects = _activeeffects(ui)
347 start = [pycompat.bytestr(activeeffects[e])
347 start = [pycompat.bytestr(activeeffects[e])
348 for e in ['none'] + effects.split()]
348 for e in ['none'] + effects.split()]
349 start = '\033[' + ';'.join(start) + 'm'
349 start = '\033[' + ';'.join(start) + 'm'
350 stop = '\033[' + pycompat.bytestr(activeeffects['none']) + 'm'
350 stop = '\033[' + pycompat.bytestr(activeeffects['none']) + 'm'
351 return _mergeeffects(text, start, stop)
351 return _mergeeffects(text, start, stop)
352
352
353 _ansieffectre = re.compile(br'\x1b\[[0-9;]*m')
353 _ansieffectre = re.compile(br'\x1b\[[0-9;]*m')
354
354
355 def stripeffects(text):
355 def stripeffects(text):
356 """Strip ANSI control codes which could be inserted by colorlabel()"""
356 """Strip ANSI control codes which could be inserted by colorlabel()"""
357 return _ansieffectre.sub('', text)
357 return _ansieffectre.sub('', text)
358
358
359 def colorlabel(ui, msg, label):
359 def colorlabel(ui, msg, label):
360 """add color control code according to the mode"""
360 """add color control code according to the mode"""
361 if ui._colormode == 'debug':
361 if ui._colormode == 'debug':
362 if label and msg:
362 if label and msg:
363 if msg[-1] == '\n':
363 if msg[-1] == '\n':
364 msg = "[%s|%s]\n" % (label, msg[:-1])
364 msg = "[%s|%s]\n" % (label, msg[:-1])
365 else:
365 else:
366 msg = "[%s|%s]" % (label, msg)
366 msg = "[%s|%s]" % (label, msg)
367 elif ui._colormode is not None:
367 elif ui._colormode is not None:
368 effects = []
368 effects = []
369 for l in label.split():
369 for l in label.split():
370 s = ui._styles.get(l, '')
370 s = ui._styles.get(l, '')
371 if s:
371 if s:
372 effects.append(s)
372 effects.append(s)
373 elif valideffect(ui, l):
373 elif valideffect(ui, l):
374 effects.append(l)
374 effects.append(l)
375 effects = ' '.join(effects)
375 effects = ' '.join(effects)
376 if effects:
376 if effects:
377 msg = '\n'.join([_render_effects(ui, line, effects)
377 msg = '\n'.join([_render_effects(ui, line, effects)
378 for line in msg.split('\n')])
378 for line in msg.split('\n')])
379 return msg
379 return msg
380
380
381 w32effects = None
381 w32effects = None
382 if pycompat.osname == 'nt':
382 if pycompat.osname == 'nt':
383 import ctypes
383 import ctypes
384
384
385 _kernel32 = ctypes.windll.kernel32
385 _kernel32 = ctypes.windll.kernel32
386
386
387 _WORD = ctypes.c_ushort
387 _WORD = ctypes.c_ushort
388
388
389 _INVALID_HANDLE_VALUE = -1
389 _INVALID_HANDLE_VALUE = -1
390
390
391 class _COORD(ctypes.Structure):
391 class _COORD(ctypes.Structure):
392 _fields_ = [('X', ctypes.c_short),
392 _fields_ = [('X', ctypes.c_short),
393 ('Y', ctypes.c_short)]
393 ('Y', ctypes.c_short)]
394
394
395 class _SMALL_RECT(ctypes.Structure):
395 class _SMALL_RECT(ctypes.Structure):
396 _fields_ = [('Left', ctypes.c_short),
396 _fields_ = [('Left', ctypes.c_short),
397 ('Top', ctypes.c_short),
397 ('Top', ctypes.c_short),
398 ('Right', ctypes.c_short),
398 ('Right', ctypes.c_short),
399 ('Bottom', ctypes.c_short)]
399 ('Bottom', ctypes.c_short)]
400
400
401 class _CONSOLE_SCREEN_BUFFER_INFO(ctypes.Structure):
401 class _CONSOLE_SCREEN_BUFFER_INFO(ctypes.Structure):
402 _fields_ = [('dwSize', _COORD),
402 _fields_ = [('dwSize', _COORD),
403 ('dwCursorPosition', _COORD),
403 ('dwCursorPosition', _COORD),
404 ('wAttributes', _WORD),
404 ('wAttributes', _WORD),
405 ('srWindow', _SMALL_RECT),
405 ('srWindow', _SMALL_RECT),
406 ('dwMaximumWindowSize', _COORD)]
406 ('dwMaximumWindowSize', _COORD)]
407
407
408 _STD_OUTPUT_HANDLE = 0xfffffff5 # (DWORD)-11
408 _STD_OUTPUT_HANDLE = 0xfffffff5 # (DWORD)-11
409 _STD_ERROR_HANDLE = 0xfffffff4 # (DWORD)-12
409 _STD_ERROR_HANDLE = 0xfffffff4 # (DWORD)-12
410
410
411 _FOREGROUND_BLUE = 0x0001
411 _FOREGROUND_BLUE = 0x0001
412 _FOREGROUND_GREEN = 0x0002
412 _FOREGROUND_GREEN = 0x0002
413 _FOREGROUND_RED = 0x0004
413 _FOREGROUND_RED = 0x0004
414 _FOREGROUND_INTENSITY = 0x0008
414 _FOREGROUND_INTENSITY = 0x0008
415
415
416 _BACKGROUND_BLUE = 0x0010
416 _BACKGROUND_BLUE = 0x0010
417 _BACKGROUND_GREEN = 0x0020
417 _BACKGROUND_GREEN = 0x0020
418 _BACKGROUND_RED = 0x0040
418 _BACKGROUND_RED = 0x0040
419 _BACKGROUND_INTENSITY = 0x0080
419 _BACKGROUND_INTENSITY = 0x0080
420
420
421 _COMMON_LVB_REVERSE_VIDEO = 0x4000
421 _COMMON_LVB_REVERSE_VIDEO = 0x4000
422 _COMMON_LVB_UNDERSCORE = 0x8000
422 _COMMON_LVB_UNDERSCORE = 0x8000
423
423
424 # http://msdn.microsoft.com/en-us/library/ms682088%28VS.85%29.aspx
424 # http://msdn.microsoft.com/en-us/library/ms682088%28VS.85%29.aspx
425 w32effects = {
425 w32effects = {
426 'none': -1,
426 'none': -1,
427 'black': 0,
427 'black': 0,
428 'red': _FOREGROUND_RED,
428 'red': _FOREGROUND_RED,
429 'green': _FOREGROUND_GREEN,
429 'green': _FOREGROUND_GREEN,
430 'yellow': _FOREGROUND_RED | _FOREGROUND_GREEN,
430 'yellow': _FOREGROUND_RED | _FOREGROUND_GREEN,
431 'blue': _FOREGROUND_BLUE,
431 'blue': _FOREGROUND_BLUE,
432 'magenta': _FOREGROUND_BLUE | _FOREGROUND_RED,
432 'magenta': _FOREGROUND_BLUE | _FOREGROUND_RED,
433 'cyan': _FOREGROUND_BLUE | _FOREGROUND_GREEN,
433 'cyan': _FOREGROUND_BLUE | _FOREGROUND_GREEN,
434 'white': _FOREGROUND_RED | _FOREGROUND_GREEN | _FOREGROUND_BLUE,
434 'white': _FOREGROUND_RED | _FOREGROUND_GREEN | _FOREGROUND_BLUE,
435 'bold': _FOREGROUND_INTENSITY,
435 'bold': _FOREGROUND_INTENSITY,
436 'black_background': 0x100, # unused value > 0x0f
436 'black_background': 0x100, # unused value > 0x0f
437 'red_background': _BACKGROUND_RED,
437 'red_background': _BACKGROUND_RED,
438 'green_background': _BACKGROUND_GREEN,
438 'green_background': _BACKGROUND_GREEN,
439 'yellow_background': _BACKGROUND_RED | _BACKGROUND_GREEN,
439 'yellow_background': _BACKGROUND_RED | _BACKGROUND_GREEN,
440 'blue_background': _BACKGROUND_BLUE,
440 'blue_background': _BACKGROUND_BLUE,
441 'purple_background': _BACKGROUND_BLUE | _BACKGROUND_RED,
441 'purple_background': _BACKGROUND_BLUE | _BACKGROUND_RED,
442 'cyan_background': _BACKGROUND_BLUE | _BACKGROUND_GREEN,
442 'cyan_background': _BACKGROUND_BLUE | _BACKGROUND_GREEN,
443 'white_background': (_BACKGROUND_RED | _BACKGROUND_GREEN |
443 'white_background': (_BACKGROUND_RED | _BACKGROUND_GREEN |
444 _BACKGROUND_BLUE),
444 _BACKGROUND_BLUE),
445 'bold_background': _BACKGROUND_INTENSITY,
445 'bold_background': _BACKGROUND_INTENSITY,
446 'underline': _COMMON_LVB_UNDERSCORE, # double-byte charsets only
446 'underline': _COMMON_LVB_UNDERSCORE, # double-byte charsets only
447 'inverse': _COMMON_LVB_REVERSE_VIDEO, # double-byte charsets only
447 'inverse': _COMMON_LVB_REVERSE_VIDEO, # double-byte charsets only
448 }
448 }
449
449
450 passthrough = {_FOREGROUND_INTENSITY,
450 passthrough = {_FOREGROUND_INTENSITY,
451 _BACKGROUND_INTENSITY,
451 _BACKGROUND_INTENSITY,
452 _COMMON_LVB_UNDERSCORE,
452 _COMMON_LVB_UNDERSCORE,
453 _COMMON_LVB_REVERSE_VIDEO}
453 _COMMON_LVB_REVERSE_VIDEO}
454
454
455 stdout = _kernel32.GetStdHandle(
455 stdout = _kernel32.GetStdHandle(
456 _STD_OUTPUT_HANDLE) # don't close the handle returned
456 _STD_OUTPUT_HANDLE) # don't close the handle returned
457 if stdout is None or stdout == _INVALID_HANDLE_VALUE:
457 if stdout is None or stdout == _INVALID_HANDLE_VALUE:
458 w32effects = None
458 w32effects = None
459 else:
459 else:
460 csbi = _CONSOLE_SCREEN_BUFFER_INFO()
460 csbi = _CONSOLE_SCREEN_BUFFER_INFO()
461 if not _kernel32.GetConsoleScreenBufferInfo(
461 if not _kernel32.GetConsoleScreenBufferInfo(
462 stdout, ctypes.byref(csbi)):
462 stdout, ctypes.byref(csbi)):
463 # stdout may not support GetConsoleScreenBufferInfo()
463 # stdout may not support GetConsoleScreenBufferInfo()
464 # when called from subprocess or redirected
464 # when called from subprocess or redirected
465 w32effects = None
465 w32effects = None
466 else:
466 else:
467 origattr = csbi.wAttributes
467 origattr = csbi.wAttributes
468 ansire = re.compile('\033\[([^m]*)m([^\033]*)(.*)',
468 ansire = re.compile('\033\[([^m]*)m([^\033]*)(.*)',
469 re.MULTILINE | re.DOTALL)
469 re.MULTILINE | re.DOTALL)
470
470
471 def win32print(ui, writefunc, *msgs, **opts):
471 def win32print(ui, writefunc, *msgs, **opts):
472 for text in msgs:
472 for text in msgs:
473 _win32print(ui, text, writefunc, **opts)
473 _win32print(ui, text, writefunc, **opts)
474
474
475 def _win32print(ui, text, writefunc, **opts):
475 def _win32print(ui, text, writefunc, **opts):
476 label = opts.get('label', '')
476 label = opts.get('label', '')
477 attr = origattr
477 attr = origattr
478
478
479 def mapcolor(val, attr):
479 def mapcolor(val, attr):
480 if val == -1:
480 if val == -1:
481 return origattr
481 return origattr
482 elif val in passthrough:
482 elif val in passthrough:
483 return attr | val
483 return attr | val
484 elif val > 0x0f:
484 elif val > 0x0f:
485 return (val & 0x70) | (attr & 0x8f)
485 return (val & 0x70) | (attr & 0x8f)
486 else:
486 else:
487 return (val & 0x07) | (attr & 0xf8)
487 return (val & 0x07) | (attr & 0xf8)
488
488
489 # determine console attributes based on labels
489 # determine console attributes based on labels
490 for l in label.split():
490 for l in label.split():
491 style = ui._styles.get(l, '')
491 style = ui._styles.get(l, '')
492 for effect in style.split():
492 for effect in style.split():
493 try:
493 try:
494 attr = mapcolor(w32effects[effect], attr)
494 attr = mapcolor(w32effects[effect], attr)
495 except KeyError:
495 except KeyError:
496 # w32effects could not have certain attributes so we skip
496 # w32effects could not have certain attributes so we skip
497 # them if not found
497 # them if not found
498 pass
498 pass
499 # hack to ensure regexp finds data
499 # hack to ensure regexp finds data
500 if not text.startswith('\033['):
500 if not text.startswith('\033['):
501 text = '\033[m' + text
501 text = '\033[m' + text
502
502
503 # Look for ANSI-like codes embedded in text
503 # Look for ANSI-like codes embedded in text
504 m = re.match(ansire, text)
504 m = re.match(ansire, text)
505
505
506 try:
506 try:
507 while m:
507 while m:
508 for sattr in m.group(1).split(';'):
508 for sattr in m.group(1).split(';'):
509 if sattr:
509 if sattr:
510 attr = mapcolor(int(sattr), attr)
510 attr = mapcolor(int(sattr), attr)
511 ui.flush()
511 ui.flush()
512 _kernel32.SetConsoleTextAttribute(stdout, attr)
512 _kernel32.SetConsoleTextAttribute(stdout, attr)
513 writefunc(m.group(2), **opts)
513 writefunc(m.group(2), **opts)
514 m = re.match(ansire, m.group(3))
514 m = re.match(ansire, m.group(3))
515 finally:
515 finally:
516 # Explicitly reset original attributes
516 # Explicitly reset original attributes
517 ui.flush()
517 ui.flush()
518 _kernel32.SetConsoleTextAttribute(stdout, origattr)
518 _kernel32.SetConsoleTextAttribute(stdout, origattr)
@@ -1,575 +1,578 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('censor', 'policy',
79 coreconfigitem('censor', 'policy',
80 default='abort',
80 default='abort',
81 )
81 )
82 coreconfigitem('chgserver', 'idletimeout',
82 coreconfigitem('chgserver', 'idletimeout',
83 default=3600,
83 default=3600,
84 )
84 )
85 coreconfigitem('chgserver', 'skiphash',
85 coreconfigitem('chgserver', 'skiphash',
86 default=False,
86 default=False,
87 )
87 )
88 coreconfigitem('cmdserver', 'log',
88 coreconfigitem('cmdserver', 'log',
89 default=None,
89 default=None,
90 )
90 )
91 coreconfigitem('color', 'mode',
91 coreconfigitem('color', 'mode',
92 default='auto',
92 default='auto',
93 )
93 )
94 coreconfigitem('color', 'pagermode',
94 coreconfigitem('color', 'pagermode',
95 default=dynamicdefault,
95 default=dynamicdefault,
96 )
96 )
97 coreconfigitem('commands', 'status.relative',
97 coreconfigitem('commands', 'status.relative',
98 default=False,
98 default=False,
99 )
99 )
100 coreconfigitem('commands', 'update.requiredest',
100 coreconfigitem('commands', 'update.requiredest',
101 default=False,
101 default=False,
102 )
102 )
103 coreconfigitem('devel', 'all-warnings',
103 coreconfigitem('devel', 'all-warnings',
104 default=False,
104 default=False,
105 )
105 )
106 coreconfigitem('devel', 'bundle2.debug',
106 coreconfigitem('devel', 'bundle2.debug',
107 default=False,
107 default=False,
108 )
108 )
109 coreconfigitem('devel', 'check-locks',
109 coreconfigitem('devel', 'check-locks',
110 default=False,
110 default=False,
111 )
111 )
112 coreconfigitem('devel', 'check-relroot',
112 coreconfigitem('devel', 'check-relroot',
113 default=False,
113 default=False,
114 )
114 )
115 coreconfigitem('devel', 'default-date',
115 coreconfigitem('devel', 'default-date',
116 default=None,
116 default=None,
117 )
117 )
118 coreconfigitem('devel', 'deprec-warn',
118 coreconfigitem('devel', 'deprec-warn',
119 default=False,
119 default=False,
120 )
120 )
121 coreconfigitem('devel', 'disableloaddefaultcerts',
121 coreconfigitem('devel', 'disableloaddefaultcerts',
122 default=False,
122 default=False,
123 )
123 )
124 coreconfigitem('devel', 'legacy.exchange',
124 coreconfigitem('devel', 'legacy.exchange',
125 default=list,
125 default=list,
126 )
126 )
127 coreconfigitem('devel', 'servercafile',
127 coreconfigitem('devel', 'servercafile',
128 default='',
128 default='',
129 )
129 )
130 coreconfigitem('devel', 'serverexactprotocol',
130 coreconfigitem('devel', 'serverexactprotocol',
131 default='',
131 default='',
132 )
132 )
133 coreconfigitem('devel', 'serverrequirecert',
133 coreconfigitem('devel', 'serverrequirecert',
134 default=False,
134 default=False,
135 )
135 )
136 coreconfigitem('devel', 'strip-obsmarkers',
136 coreconfigitem('devel', 'strip-obsmarkers',
137 default=True,
137 default=True,
138 )
138 )
139 coreconfigitem('email', 'charsets',
139 coreconfigitem('email', 'charsets',
140 default=list,
140 default=list,
141 )
141 )
142 coreconfigitem('email', 'method',
142 coreconfigitem('email', 'method',
143 default='smtp',
143 default='smtp',
144 )
144 )
145 coreconfigitem('experimental', 'bundle-phases',
145 coreconfigitem('experimental', 'bundle-phases',
146 default=False,
146 default=False,
147 )
147 )
148 coreconfigitem('experimental', 'bundle2-advertise',
148 coreconfigitem('experimental', 'bundle2-advertise',
149 default=True,
149 default=True,
150 )
150 )
151 coreconfigitem('experimental', 'bundle2-output-capture',
151 coreconfigitem('experimental', 'bundle2-output-capture',
152 default=False,
152 default=False,
153 )
153 )
154 coreconfigitem('experimental', 'bundle2.pushback',
154 coreconfigitem('experimental', 'bundle2.pushback',
155 default=False,
155 default=False,
156 )
156 )
157 coreconfigitem('experimental', 'bundle2lazylocking',
157 coreconfigitem('experimental', 'bundle2lazylocking',
158 default=False,
158 default=False,
159 )
159 )
160 coreconfigitem('experimental', 'bundlecomplevel',
160 coreconfigitem('experimental', 'bundlecomplevel',
161 default=None,
161 default=None,
162 )
162 )
163 coreconfigitem('experimental', 'changegroup3',
163 coreconfigitem('experimental', 'changegroup3',
164 default=False,
164 default=False,
165 )
165 )
166 coreconfigitem('experimental', 'clientcompressionengines',
166 coreconfigitem('experimental', 'clientcompressionengines',
167 default=list,
167 default=list,
168 )
168 )
169 coreconfigitem('experimental', 'crecordtest',
169 coreconfigitem('experimental', 'crecordtest',
170 default=None,
170 default=None,
171 )
171 )
172 coreconfigitem('experimental', 'disablecopytrace',
172 coreconfigitem('experimental', 'disablecopytrace',
173 default=False,
173 default=False,
174 )
174 )
175 coreconfigitem('experimental', 'editortmpinhg',
175 coreconfigitem('experimental', 'editortmpinhg',
176 default=False,
176 default=False,
177 )
177 )
178 coreconfigitem('experimental', 'evolution',
178 coreconfigitem('experimental', 'evolution',
179 default=list,
179 default=list,
180 )
180 )
181 coreconfigitem('experimental', 'evolution.bundle-obsmarker',
181 coreconfigitem('experimental', 'evolution.bundle-obsmarker',
182 default=False,
182 default=False,
183 )
183 )
184 coreconfigitem('experimental', 'evolution.track-operation',
184 coreconfigitem('experimental', 'evolution.track-operation',
185 default=False,
185 default=False,
186 )
186 )
187 coreconfigitem('experimental', 'exportableenviron',
187 coreconfigitem('experimental', 'exportableenviron',
188 default=list,
188 default=list,
189 )
189 )
190 coreconfigitem('experimental', 'extendedheader.index',
190 coreconfigitem('experimental', 'extendedheader.index',
191 default=None,
191 default=None,
192 )
192 )
193 coreconfigitem('experimental', 'extendedheader.similarity',
193 coreconfigitem('experimental', 'extendedheader.similarity',
194 default=False,
194 default=False,
195 )
195 )
196 coreconfigitem('experimental', 'format.compression',
196 coreconfigitem('experimental', 'format.compression',
197 default='zlib',
197 default='zlib',
198 )
198 )
199 coreconfigitem('experimental', 'graphshorten',
199 coreconfigitem('experimental', 'graphshorten',
200 default=False,
200 default=False,
201 )
201 )
202 coreconfigitem('experimental', 'hook-track-tags',
202 coreconfigitem('experimental', 'hook-track-tags',
203 default=False,
203 default=False,
204 )
204 )
205 coreconfigitem('experimental', 'httppostargs',
205 coreconfigitem('experimental', 'httppostargs',
206 default=False,
206 default=False,
207 )
207 )
208 coreconfigitem('experimental', 'manifestv2',
208 coreconfigitem('experimental', 'manifestv2',
209 default=False,
209 default=False,
210 )
210 )
211 coreconfigitem('experimental', 'mergedriver',
211 coreconfigitem('experimental', 'mergedriver',
212 default=None,
212 default=None,
213 )
213 )
214 coreconfigitem('experimental', 'obsmarkers-exchange-debug',
214 coreconfigitem('experimental', 'obsmarkers-exchange-debug',
215 default=False,
215 default=False,
216 )
216 )
217 coreconfigitem('experimental', 'revertalternateinteractivemode',
217 coreconfigitem('experimental', 'revertalternateinteractivemode',
218 default=True,
218 default=True,
219 )
219 )
220 coreconfigitem('experimental', 'revlogv2',
220 coreconfigitem('experimental', 'revlogv2',
221 default=None,
221 default=None,
222 )
222 )
223 coreconfigitem('experimental', 'spacemovesdown',
223 coreconfigitem('experimental', 'spacemovesdown',
224 default=False,
224 default=False,
225 )
225 )
226 coreconfigitem('experimental', 'treemanifest',
226 coreconfigitem('experimental', 'treemanifest',
227 default=False,
227 default=False,
228 )
228 )
229 coreconfigitem('experimental', 'updatecheck',
229 coreconfigitem('experimental', 'updatecheck',
230 default=None,
230 default=None,
231 )
231 )
232 coreconfigitem('format', 'aggressivemergedeltas',
232 coreconfigitem('format', 'aggressivemergedeltas',
233 default=False,
233 default=False,
234 )
234 )
235 coreconfigitem('format', 'chunkcachesize',
235 coreconfigitem('format', 'chunkcachesize',
236 default=None,
236 default=None,
237 )
237 )
238 coreconfigitem('format', 'dotencode',
238 coreconfigitem('format', 'dotencode',
239 default=True,
239 default=True,
240 )
240 )
241 coreconfigitem('format', 'generaldelta',
241 coreconfigitem('format', 'generaldelta',
242 default=False,
242 default=False,
243 )
243 )
244 coreconfigitem('format', 'manifestcachesize',
244 coreconfigitem('format', 'manifestcachesize',
245 default=None,
245 default=None,
246 )
246 )
247 coreconfigitem('format', 'maxchainlen',
247 coreconfigitem('format', 'maxchainlen',
248 default=None,
248 default=None,
249 )
249 )
250 coreconfigitem('format', 'obsstore-version',
250 coreconfigitem('format', 'obsstore-version',
251 default=None,
251 default=None,
252 )
252 )
253 coreconfigitem('format', 'usefncache',
253 coreconfigitem('format', 'usefncache',
254 default=True,
254 default=True,
255 )
255 )
256 coreconfigitem('format', 'usegeneraldelta',
256 coreconfigitem('format', 'usegeneraldelta',
257 default=True,
257 default=True,
258 )
258 )
259 coreconfigitem('format', 'usestore',
259 coreconfigitem('format', 'usestore',
260 default=True,
260 default=True,
261 )
261 )
262 coreconfigitem('hostsecurity', 'ciphers',
262 coreconfigitem('hostsecurity', 'ciphers',
263 default=None,
263 default=None,
264 )
264 )
265 coreconfigitem('hostsecurity', 'disabletls10warning',
265 coreconfigitem('hostsecurity', 'disabletls10warning',
266 default=False,
266 default=False,
267 )
267 )
268 coreconfigitem('http_proxy', 'always',
268 coreconfigitem('http_proxy', 'always',
269 default=False,
269 default=False,
270 )
270 )
271 coreconfigitem('http_proxy', 'host',
271 coreconfigitem('http_proxy', 'host',
272 default=None,
272 default=None,
273 )
273 )
274 coreconfigitem('http_proxy', 'no',
274 coreconfigitem('http_proxy', 'no',
275 default=list,
275 default=list,
276 )
276 )
277 coreconfigitem('http_proxy', 'passwd',
277 coreconfigitem('http_proxy', 'passwd',
278 default=None,
278 default=None,
279 )
279 )
280 coreconfigitem('http_proxy', 'user',
280 coreconfigitem('http_proxy', 'user',
281 default=None,
281 default=None,
282 )
282 )
283 coreconfigitem('merge', 'followcopies',
283 coreconfigitem('merge', 'followcopies',
284 default=True,
284 default=True,
285 )
285 )
286 coreconfigitem('pager', 'ignore',
286 coreconfigitem('pager', 'ignore',
287 default=list,
287 default=list,
288 )
288 )
289 coreconfigitem('patch', 'eol',
289 coreconfigitem('patch', 'eol',
290 default='strict',
290 default='strict',
291 )
291 )
292 coreconfigitem('patch', 'fuzz',
292 coreconfigitem('patch', 'fuzz',
293 default=2,
293 default=2,
294 )
294 )
295 coreconfigitem('paths', 'default',
295 coreconfigitem('paths', 'default',
296 default=None,
296 default=None,
297 )
297 )
298 coreconfigitem('paths', 'default-push',
298 coreconfigitem('paths', 'default-push',
299 default=None,
299 default=None,
300 )
300 )
301 coreconfigitem('phases', 'checksubrepos',
301 coreconfigitem('phases', 'checksubrepos',
302 default='follow',
302 default='follow',
303 )
303 )
304 coreconfigitem('phases', 'publish',
304 coreconfigitem('phases', 'publish',
305 default=True,
305 default=True,
306 )
306 )
307 coreconfigitem('profiling', 'enabled',
307 coreconfigitem('profiling', 'enabled',
308 default=False,
308 default=False,
309 )
309 )
310 coreconfigitem('profiling', 'format',
310 coreconfigitem('profiling', 'format',
311 default='text',
311 default='text',
312 )
312 )
313 coreconfigitem('profiling', 'freq',
313 coreconfigitem('profiling', 'freq',
314 default=1000,
314 default=1000,
315 )
315 )
316 coreconfigitem('profiling', 'limit',
316 coreconfigitem('profiling', 'limit',
317 default=30,
317 default=30,
318 )
318 )
319 coreconfigitem('profiling', 'nested',
319 coreconfigitem('profiling', 'nested',
320 default=0,
320 default=0,
321 )
321 )
322 coreconfigitem('profiling', 'sort',
322 coreconfigitem('profiling', 'sort',
323 default='inlinetime',
323 default='inlinetime',
324 )
324 )
325 coreconfigitem('profiling', 'statformat',
325 coreconfigitem('profiling', 'statformat',
326 default='hotpath',
326 default='hotpath',
327 )
327 )
328 coreconfigitem('progress', 'assume-tty',
328 coreconfigitem('progress', 'assume-tty',
329 default=False,
329 default=False,
330 )
330 )
331 coreconfigitem('progress', 'changedelay',
331 coreconfigitem('progress', 'changedelay',
332 default=1,
332 default=1,
333 )
333 )
334 coreconfigitem('progress', 'clear-complete',
334 coreconfigitem('progress', 'clear-complete',
335 default=True,
335 default=True,
336 )
336 )
337 coreconfigitem('progress', 'debug',
337 coreconfigitem('progress', 'debug',
338 default=False,
338 default=False,
339 )
339 )
340 coreconfigitem('progress', 'delay',
340 coreconfigitem('progress', 'delay',
341 default=3,
341 default=3,
342 )
342 )
343 coreconfigitem('progress', 'disable',
343 coreconfigitem('progress', 'disable',
344 default=False,
344 default=False,
345 )
345 )
346 coreconfigitem('progress', 'estimate',
346 coreconfigitem('progress', 'estimate',
347 default=2,
347 default=2,
348 )
348 )
349 coreconfigitem('progress', 'refresh',
349 coreconfigitem('progress', 'refresh',
350 default=0.1,
350 default=0.1,
351 )
351 )
352 coreconfigitem('progress', 'width',
352 coreconfigitem('progress', 'width',
353 default=dynamicdefault,
353 default=dynamicdefault,
354 )
354 )
355 coreconfigitem('server', 'bundle1',
355 coreconfigitem('server', 'bundle1',
356 default=True,
356 default=True,
357 )
357 )
358 coreconfigitem('server', 'bundle1gd',
358 coreconfigitem('server', 'bundle1gd',
359 default=None,
359 default=None,
360 )
360 )
361 coreconfigitem('server', 'compressionengines',
361 coreconfigitem('server', 'compressionengines',
362 default=list,
362 default=list,
363 )
363 )
364 coreconfigitem('server', 'concurrent-push-mode',
364 coreconfigitem('server', 'concurrent-push-mode',
365 default='strict',
365 default='strict',
366 )
366 )
367 coreconfigitem('server', 'disablefullbundle',
367 coreconfigitem('server', 'disablefullbundle',
368 default=False,
368 default=False,
369 )
369 )
370 coreconfigitem('server', 'maxhttpheaderlen',
370 coreconfigitem('server', 'maxhttpheaderlen',
371 default=1024,
371 default=1024,
372 )
372 )
373 coreconfigitem('server', 'preferuncompressed',
373 coreconfigitem('server', 'preferuncompressed',
374 default=False,
374 default=False,
375 )
375 )
376 coreconfigitem('server', 'uncompressed',
376 coreconfigitem('server', 'uncompressed',
377 default=True,
377 default=True,
378 )
378 )
379 coreconfigitem('server', 'uncompressedallowsecret',
379 coreconfigitem('server', 'uncompressedallowsecret',
380 default=False,
380 default=False,
381 )
381 )
382 coreconfigitem('server', 'validate',
382 coreconfigitem('server', 'validate',
383 default=False,
383 default=False,
384 )
384 )
385 coreconfigitem('server', 'zliblevel',
385 coreconfigitem('server', 'zliblevel',
386 default=-1,
386 default=-1,
387 )
387 )
388 coreconfigitem('smtp', 'host',
388 coreconfigitem('smtp', 'host',
389 default=None,
389 default=None,
390 )
390 )
391 coreconfigitem('smtp', 'local_hostname',
391 coreconfigitem('smtp', 'local_hostname',
392 default=None,
392 default=None,
393 )
393 )
394 coreconfigitem('smtp', 'password',
394 coreconfigitem('smtp', 'password',
395 default=None,
395 default=None,
396 )
396 )
397 coreconfigitem('smtp', 'tls',
397 coreconfigitem('smtp', 'tls',
398 default='none',
398 default='none',
399 )
399 )
400 coreconfigitem('smtp', 'username',
400 coreconfigitem('smtp', 'username',
401 default=None,
401 default=None,
402 )
402 )
403 coreconfigitem('sparse', 'missingwarning',
403 coreconfigitem('sparse', 'missingwarning',
404 default=True,
404 default=True,
405 )
405 )
406 coreconfigitem('trusted', 'groups',
406 coreconfigitem('trusted', 'groups',
407 default=list,
407 default=list,
408 )
408 )
409 coreconfigitem('trusted', 'users',
409 coreconfigitem('trusted', 'users',
410 default=list,
410 default=list,
411 )
411 )
412 coreconfigitem('ui', '_usedassubrepo',
412 coreconfigitem('ui', '_usedassubrepo',
413 default=False,
413 default=False,
414 )
414 )
415 coreconfigitem('ui', 'allowemptycommit',
415 coreconfigitem('ui', 'allowemptycommit',
416 default=False,
416 default=False,
417 )
417 )
418 coreconfigitem('ui', 'archivemeta',
418 coreconfigitem('ui', 'archivemeta',
419 default=True,
419 default=True,
420 )
420 )
421 coreconfigitem('ui', 'askusername',
421 coreconfigitem('ui', 'askusername',
422 default=False,
422 default=False,
423 )
423 )
424 coreconfigitem('ui', 'clonebundlefallback',
424 coreconfigitem('ui', 'clonebundlefallback',
425 default=False,
425 default=False,
426 )
426 )
427 coreconfigitem('ui', 'clonebundleprefers',
427 coreconfigitem('ui', 'clonebundleprefers',
428 default=list,
428 default=list,
429 )
429 )
430 coreconfigitem('ui', 'clonebundles',
430 coreconfigitem('ui', 'clonebundles',
431 default=True,
431 default=True,
432 )
432 )
433 coreconfigitem('ui', 'color',
434 default='auto',
435 )
433 coreconfigitem('ui', 'commitsubrepos',
436 coreconfigitem('ui', 'commitsubrepos',
434 default=False,
437 default=False,
435 )
438 )
436 coreconfigitem('ui', 'debug',
439 coreconfigitem('ui', 'debug',
437 default=False,
440 default=False,
438 )
441 )
439 coreconfigitem('ui', 'debugger',
442 coreconfigitem('ui', 'debugger',
440 default=None,
443 default=None,
441 )
444 )
442 coreconfigitem('ui', 'fallbackencoding',
445 coreconfigitem('ui', 'fallbackencoding',
443 default=None,
446 default=None,
444 )
447 )
445 coreconfigitem('ui', 'forcecwd',
448 coreconfigitem('ui', 'forcecwd',
446 default=None,
449 default=None,
447 )
450 )
448 coreconfigitem('ui', 'forcemerge',
451 coreconfigitem('ui', 'forcemerge',
449 default=None,
452 default=None,
450 )
453 )
451 coreconfigitem('ui', 'formatdebug',
454 coreconfigitem('ui', 'formatdebug',
452 default=False,
455 default=False,
453 )
456 )
454 coreconfigitem('ui', 'formatjson',
457 coreconfigitem('ui', 'formatjson',
455 default=False,
458 default=False,
456 )
459 )
457 coreconfigitem('ui', 'formatted',
460 coreconfigitem('ui', 'formatted',
458 default=None,
461 default=None,
459 )
462 )
460 coreconfigitem('ui', 'graphnodetemplate',
463 coreconfigitem('ui', 'graphnodetemplate',
461 default=None,
464 default=None,
462 )
465 )
463 coreconfigitem('ui', 'http2debuglevel',
466 coreconfigitem('ui', 'http2debuglevel',
464 default=None,
467 default=None,
465 )
468 )
466 coreconfigitem('ui', 'interactive',
469 coreconfigitem('ui', 'interactive',
467 default=None,
470 default=None,
468 )
471 )
469 coreconfigitem('ui', 'interface',
472 coreconfigitem('ui', 'interface',
470 default=None,
473 default=None,
471 )
474 )
472 coreconfigitem('ui', 'logblockedtimes',
475 coreconfigitem('ui', 'logblockedtimes',
473 default=False,
476 default=False,
474 )
477 )
475 coreconfigitem('ui', 'logtemplate',
478 coreconfigitem('ui', 'logtemplate',
476 default=None,
479 default=None,
477 )
480 )
478 coreconfigitem('ui', 'merge',
481 coreconfigitem('ui', 'merge',
479 default=None,
482 default=None,
480 )
483 )
481 coreconfigitem('ui', 'mergemarkers',
484 coreconfigitem('ui', 'mergemarkers',
482 default='basic',
485 default='basic',
483 )
486 )
484 coreconfigitem('ui', 'nontty',
487 coreconfigitem('ui', 'nontty',
485 default=False,
488 default=False,
486 )
489 )
487 coreconfigitem('ui', 'origbackuppath',
490 coreconfigitem('ui', 'origbackuppath',
488 default=None,
491 default=None,
489 )
492 )
490 coreconfigitem('ui', 'paginate',
493 coreconfigitem('ui', 'paginate',
491 default=True,
494 default=True,
492 )
495 )
493 coreconfigitem('ui', 'patch',
496 coreconfigitem('ui', 'patch',
494 default=None,
497 default=None,
495 )
498 )
496 coreconfigitem('ui', 'portablefilenames',
499 coreconfigitem('ui', 'portablefilenames',
497 default='warn',
500 default='warn',
498 )
501 )
499 coreconfigitem('ui', 'promptecho',
502 coreconfigitem('ui', 'promptecho',
500 default=False,
503 default=False,
501 )
504 )
502 coreconfigitem('ui', 'quiet',
505 coreconfigitem('ui', 'quiet',
503 default=False,
506 default=False,
504 )
507 )
505 coreconfigitem('ui', 'quietbookmarkmove',
508 coreconfigitem('ui', 'quietbookmarkmove',
506 default=False,
509 default=False,
507 )
510 )
508 coreconfigitem('ui', 'remotecmd',
511 coreconfigitem('ui', 'remotecmd',
509 default='hg',
512 default='hg',
510 )
513 )
511 coreconfigitem('ui', 'report_untrusted',
514 coreconfigitem('ui', 'report_untrusted',
512 default=True,
515 default=True,
513 )
516 )
514 coreconfigitem('ui', 'rollback',
517 coreconfigitem('ui', 'rollback',
515 default=True,
518 default=True,
516 )
519 )
517 coreconfigitem('ui', 'slash',
520 coreconfigitem('ui', 'slash',
518 default=False,
521 default=False,
519 )
522 )
520 coreconfigitem('ui', 'ssh',
523 coreconfigitem('ui', 'ssh',
521 default='ssh',
524 default='ssh',
522 )
525 )
523 coreconfigitem('ui', 'statuscopies',
526 coreconfigitem('ui', 'statuscopies',
524 default=False,
527 default=False,
525 )
528 )
526 coreconfigitem('ui', 'strict',
529 coreconfigitem('ui', 'strict',
527 default=False,
530 default=False,
528 )
531 )
529 coreconfigitem('ui', 'style',
532 coreconfigitem('ui', 'style',
530 default='',
533 default='',
531 )
534 )
532 coreconfigitem('ui', 'supportcontact',
535 coreconfigitem('ui', 'supportcontact',
533 default=None,
536 default=None,
534 )
537 )
535 coreconfigitem('ui', 'textwidth',
538 coreconfigitem('ui', 'textwidth',
536 default=78,
539 default=78,
537 )
540 )
538 coreconfigitem('ui', 'timeout',
541 coreconfigitem('ui', 'timeout',
539 default='600',
542 default='600',
540 )
543 )
541 coreconfigitem('ui', 'traceback',
544 coreconfigitem('ui', 'traceback',
542 default=False,
545 default=False,
543 )
546 )
544 coreconfigitem('ui', 'tweakdefaults',
547 coreconfigitem('ui', 'tweakdefaults',
545 default=False,
548 default=False,
546 )
549 )
547 coreconfigitem('ui', 'usehttp2',
550 coreconfigitem('ui', 'usehttp2',
548 default=False,
551 default=False,
549 )
552 )
550 coreconfigitem('ui', 'username',
553 coreconfigitem('ui', 'username',
551 alias=[('ui', 'user')]
554 alias=[('ui', 'user')]
552 )
555 )
553 coreconfigitem('ui', 'verbose',
556 coreconfigitem('ui', 'verbose',
554 default=False,
557 default=False,
555 )
558 )
556 coreconfigitem('verify', 'skipflags',
559 coreconfigitem('verify', 'skipflags',
557 default=None,
560 default=None,
558 )
561 )
559 coreconfigitem('worker', 'backgroundclose',
562 coreconfigitem('worker', 'backgroundclose',
560 default=dynamicdefault,
563 default=dynamicdefault,
561 )
564 )
562 # Windows defaults to a limit of 512 open files. A buffer of 128
565 # Windows defaults to a limit of 512 open files. A buffer of 128
563 # should give us enough headway.
566 # should give us enough headway.
564 coreconfigitem('worker', 'backgroundclosemaxqueue',
567 coreconfigitem('worker', 'backgroundclosemaxqueue',
565 default=384,
568 default=384,
566 )
569 )
567 coreconfigitem('worker', 'backgroundcloseminfilecount',
570 coreconfigitem('worker', 'backgroundcloseminfilecount',
568 default=2048,
571 default=2048,
569 )
572 )
570 coreconfigitem('worker', 'backgroundclosethreadcount',
573 coreconfigitem('worker', 'backgroundclosethreadcount',
571 default=4,
574 default=4,
572 )
575 )
573 coreconfigitem('worker', 'numcpus',
576 coreconfigitem('worker', 'numcpus',
574 default=None,
577 default=None,
575 )
578 )
General Comments 0
You need to be logged in to leave comments. Login now