Mercurial > hg-stable
changeset 12089:70f4a0f4e9a3
color: accept usual boolean values as synonyms for always and never
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Sat, 28 Aug 2010 21:57:36 -0500 |
parents | 1f71dffabc53 |
children | 339bd18c772f |
files | hgext/color.py |
diffstat | 1 files changed, 11 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/color.py Mon Aug 30 10:28:25 2010 -0500 +++ b/hgext/color.py Sat Aug 28 21:57:36 2010 -0500 @@ -79,7 +79,7 @@ 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 @@ 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 @@ 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