[PATCH 1 of 2] run-tests: add color to output if pygments is available
Yuya Nishihara
yuya at tcha.org
Fri Jul 14 08:51:56 EDT 2017
On Sun, 09 Jul 2017 10:31:40 +0900, mlaneuville at gmail.com wrote:
> # HG changeset patch
> # User Matthieu Laneuville <matthieu.laneuville at octobus.net>
> # Date 1498736712 -32400
> # Thu Jun 29 20:45:12 2017 +0900
> # Node ID 87d1921ae32f56511ea26e8054796bd7b54daf46
> # Parent 4672db164c986da4442bd864cd044512d975c3f2
> run-tests: add color to output if pygments is available
Seems fine. Queued, thanks.
> +if not sys.stderr.isatty(): # check if the terminal is capable
> + with_color = False
Strictly speaking, we should test self.stream.isatty(), and maybe need some
tweaks for Windows?
> + global with_color
> + if options.color != 'auto':
> + if options.color == 'never':
> + with_color = False
> + else: # 'always', for testing purposes
> + with_color = True
If pygments isn't available, --color always should be disabled.
> @@ -1625,6 +1647,11 @@
> else:
> self.stream.write('\n')
> for line in lines:
> + if with_color:
> + line = pygments.highlight(
> + line,
> + lexers.DiffLexer(),
> + formatters.Terminal256Formatter())
Not sure if 256color is necessary. I think old ANSI mode is good enough.
More information about the Mercurial-devel
mailing list