mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
color: accept usual boolean values as synonyms for always and never
This commit is contained in:
parent
d89ff49a61
commit
2ad9623e97
@ -79,7 +79,7 @@ Any value other than 'ansi', 'win32', or 'auto' will disable color.
|
||||
|
||||
import os
|
||||
|
||||
from mercurial import commands, dispatch, extensions, ui as uimod
|
||||
from mercurial import commands, dispatch, extensions, ui as uimod, util
|
||||
from mercurial.i18n import _
|
||||
|
||||
# start and stop parameters for effects
|
||||
@ -209,9 +209,12 @@ def uisetup(ui):
|
||||
elif mode != 'ansi':
|
||||
return
|
||||
def colorcmd(orig, ui_, opts, cmd, cmdfunc):
|
||||
if (opts['color'] == 'always' or
|
||||
(opts['color'] == 'auto' and (os.environ.get('TERM') != 'dumb'
|
||||
and ui_.formatted()))):
|
||||
coloropt = opts['color']
|
||||
auto = coloropt == 'auto'
|
||||
always = util.parsebool(coloropt)
|
||||
if (always or
|
||||
(always is None and
|
||||
(auto and (os.environ.get('TERM') != 'dumb' and ui_.formatted())))):
|
||||
colorui._colormode = mode
|
||||
colorui.__bases__ = (ui_.__class__,)
|
||||
ui_.__class__ = colorui
|
||||
@ -220,9 +223,10 @@ def uisetup(ui):
|
||||
return orig(ui_, opts, cmd, cmdfunc)
|
||||
extensions.wrapfunction(dispatch, '_runcommand', colorcmd)
|
||||
|
||||
commands.globalopts.append(('', 'color', 'auto',
|
||||
_("when to colorize (always, auto, or never)"),
|
||||
_('TYPE')))
|
||||
commands.globalopts.append(
|
||||
('', 'color', 'auto',
|
||||
_("when to colorize (boolean, always, auto, or never)"),
|
||||
_('TYPE')))
|
||||
|
||||
try:
|
||||
import re, pywintypes, win32console as win32c
|
||||
|
Loading…
Reference in New Issue
Block a user