[PATCH 1 of 3] ui: test plain mode against exceptions
Yann E. MORIN
yann.morin.1998 at anciens.enib.fr
Mon May 16 17:54:07 CDT 2011
# HG changeset patch
# User "Yann E. MORIN" <yann.morin.1998 at anciens.enib.fr>
# Date 1305583731 -7200
# Node ID 2e0bfc555cc8395dfbc5e59c8e036266655dc77f
# Parent abaacdab38f64e3f7f27d8bc6ec251c76dfcc30e
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 at anciens.enib.fr>
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -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 exceptions:
+ return feature not in exceptions
+ return True
def username(self):
"""Return default username to be used in commits.
More information about the Mercurial-devel
mailing list