This is an archive of the discontinued Mercurial Phabricator instance.

color: honor NO_COLOR
Needs RevisionPublic

Authored by indygreg on Feb 7 2018, 12:17 PM.

Details

Reviewers
lothiraldan
yuja
Group Reviewers
hg-reviewers
Summary

The http://no-color.org/ initiative is trying to get programs that
emit color by default to honor a NO_COLOR environment variable to
disable color.

I think that's a good idea. So this commit implements support for
NO_COLOR.

I'm not sure if the precedence of settings is proper here. Right now,
NO_COLOR overrides config settings set by hgrc or --config. But it
doesn't override --color. I can see an argument for honoring
--config as well. Same for hgrc (since color is enabled by default
these days). But the existing logic/precedence is unclear to me. So
I went with an easy implementation.

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

indygreg created this revision.Feb 7 2018, 12:17 PM
lothiraldan accepted this revision.Feb 7 2018, 12:35 PM
lothiraldan added a subscriber: lothiraldan.

๐Ÿ‘ Hurrah for standards!

quark added a subscriber: quark.Feb 7 2018, 3:41 PM

You might want to let run-tests.py drop NO_COLOR for tests.

yuja added a subscriber: yuja.Feb 10 2018, 7:23 AM

I'm not sure if the precedence of settings is proper here.

Perhaps it should be placed at the same level as $EDITOR (i.e. envrcitems)?

And can you update help/color and environment?

In D2079#35154, @yuja wrote:

I'm not sure if the precedence of settings is proper here.

Perhaps it should be placed at the same level as $EDITOR (i.e. envrcitems)?

I haven't bothered checking what that means for precedence, but I have an argument for giving NO_COLOR higher precedence than at least the system config: we set the system config for all our users at Google and some may want to override with NO_COLOR. I know someone (Jun? Yuya?) did some work related to precedence of EDITOR a while ago, but I don't remember what the goal of that was.

quark added a subscriber: durin42.Feb 10 2018, 2:13 PM

The goal was to allow users to override system default using environment variables. So a separate [systemdefaults] (proposed by @durin42) becomes unnecessary.

yuja requested changes to this revision.Feb 15 2018, 7:22 AM

(just clarify the current state of this patch)

This revision now requires changes to proceed.Feb 15 2018, 7:22 AM