Mercurial > hg
changeset 14372:be0daa0eeb3e
ui: test plain mode against exceptions
Let ui.plain() accept an optional parameter in the form of a feature
name (as a string) to exclude from plain mode.
The result of ui.plain is now:
- False if HGPLAIN is not set or the requested feature is in HGPLAINEXCEPT
- True otherwise
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
author | "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr> |
---|---|
date | Tue, 17 May 2011 00:08:51 +0200 |
parents | ec2aae8b375d |
children | a599431b0ab6 |
files | mercurial/ui.py tests/test-hgrc.t |
diffstat | 2 files changed, 10 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/ui.py Wed May 18 17:05:30 2011 -0500 +++ b/mercurial/ui.py Tue May 17 00:08:51 2011 +0200 @@ -330,7 +330,7 @@ for name, value in self.configitems(section, untrusted): yield section, name, value - def plain(self): + def plain(self, feature=None): '''is plain mode active? Plain mode means that all configuration variables which affect @@ -341,14 +341,16 @@ The only way to trigger plain mode is by setting either the `HGPLAIN' or `HGPLAINEXCEPT' environment variables. - The return value can either be False, True, or a list of - features that plain mode should not apply to (e.g., i18n, - progress, etc). + The return value can either be + - False if HGPLAIN is not set, or feature is in HGPLAINEXCEPT + - True otherwise ''' if 'HGPLAIN' not in os.environ and 'HGPLAINEXCEPT' not in os.environ: return False exceptions = os.environ.get('HGPLAINEXCEPT', '').strip().split(',') - return exceptions or True + if feature and exceptions: + return feature not in exceptions + return True def username(self): """Return default username to be used in commits.
--- a/tests/test-hgrc.t Wed May 18 17:05:30 2011 -0500 +++ b/tests/test-hgrc.t Tue May 17 00:08:51 2011 +0200 @@ -144,7 +144,7 @@ $ echo "plain=./plain.py" >> $HGRCPATH $ HGPLAINEXCEPT=; export HGPLAINEXCEPT $ hg showconfig --config ui.traceback=True --debug - plain: [''] + plain: True read config from: $TESTTMP/hgrc $TESTTMP/hgrc:15: extensions.plain=./plain.py none: ui.traceback=True @@ -153,7 +153,7 @@ none: ui.quiet=False $ unset HGPLAIN $ hg showconfig --config ui.traceback=True --debug - plain: [''] + plain: True read config from: $TESTTMP/hgrc $TESTTMP/hgrc:15: extensions.plain=./plain.py none: ui.traceback=True @@ -162,7 +162,7 @@ none: ui.quiet=False $ HGPLAINEXCEPT=i18n; export HGPLAINEXCEPT $ hg showconfig --config ui.traceback=True --debug - plain: ['i18n'] + plain: True read config from: $TESTTMP/hgrc $TESTTMP/hgrc:15: extensions.plain=./plain.py none: ui.traceback=True