diff mercurial/i18n.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 f7d7de6eccc8
children b64538363dbe
line wrap: on
line diff
--- a/mercurial/i18n.py	Thu Mar 31 17:37:33 2011 -0700
+++ b/mercurial/i18n.py	Wed Jan 05 00:18:36 2011 +1100
@@ -51,7 +51,13 @@
         # An unknown encoding results in a LookupError.
         return message
 
-if 'HGPLAIN' in os.environ:
+def _plain():
+    if 'HGPLAIN' not in os.environ and 'HGPLAINEXCEPT' not in os.environ:
+        return False
+    exceptions = os.environ.get('HGPLAINEXCEPT', '').strip().split(',')
+    return 'i18n' not in exceptions
+
+if _plain():
     _ = lambda message: message
 else:
     _ = gettext