diff mercurial/ui.py @ 13849:9f97de157aad

HGPLAIN: allow exceptions to plain mode, like i18n, via HGPLAINEXCEPT This makes it possible to gain the benefits of HGPLAIN for scripting while preserving different behaviors like internationalization.
author Brodie Rao <brodie@bitheap.org>
date Wed, 05 Jan 2011 00:18:36 +1100
parents f1823b9f073b
children af60153b5e3b
line wrap: on
line diff
--- a/mercurial/ui.py	Thu Mar 31 17:37:33 2011 -0700
+++ b/mercurial/ui.py	Wed Jan 05 00:18:36 2011 +1100
@@ -278,15 +278,22 @@
     def plain(self):
         '''is plain mode active?
 
-        Plain mode means that all configuration variables which affect the
-        behavior and output of Mercurial should be ignored. Additionally, the
-        output should be stable, reproducible and suitable for use in scripts or
-        applications.
+        Plain mode means that all configuration variables which affect
+        the behavior and output of Mercurial should be
+        ignored. Additionally, the output should be stable,
+        reproducible and suitable for use in scripts or applications.
+
+        The only way to trigger plain mode is by setting either the
+        `HGPLAIN' or `HGPLAINEXCEPT' environment variables.
 
-        The only way to trigger plain mode is by setting the `HGPLAIN'
-        environment variable.
+        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).
         '''
-        return 'HGPLAIN' in os.environ
+        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
 
     def username(self):
         """Return default username to be used in commits.