##// END OF EJS Templates
HGPLAIN: allow exceptions to plain mode, like i18n, via HGPLAINEXCEPT...
Brodie Rao -
r13849:9f97de15 default
parent child Browse files
Show More
@@ -59,6 +59,14 HGPLAIN
59 59 Equivalent options set via command line flags or environment
60 60 variables are not overridden.
61 61
62 HGPLAINEXCEPT
63 This is a comma-separated list of features to preserve when
64 HGPLAIN is enabled. Currently the only value supported is "i18n",
65 which preserves internationalization in plain mode.
66
67 Setting HGPLAINEXCEPT to anything (even an empty string) will
68 enable plain mode.
69
62 70 HGUSER
63 71 This is the string used as the author of a commit. If not set,
64 72 available values will be considered in this order:
@@ -51,7 +51,13 def gettext(message):
51 51 # An unknown encoding results in a LookupError.
52 52 return message
53 53
54 if 'HGPLAIN' in os.environ:
54 def _plain():
55 if 'HGPLAIN' not in os.environ and 'HGPLAINEXCEPT' not in os.environ:
56 return False
57 exceptions = os.environ.get('HGPLAINEXCEPT', '').strip().split(',')
58 return 'i18n' not in exceptions
59
60 if _plain():
55 61 _ = lambda message: message
56 62 else:
57 63 _ = gettext
@@ -278,15 +278,22 class ui(object):
278 278 def plain(self):
279 279 '''is plain mode active?
280 280
281 Plain mode means that all configuration variables which affect the
282 behavior and output of Mercurial should be ignored. Additionally, the
283 output should be stable, reproducible and suitable for use in scripts or
284 applications.
281 Plain mode means that all configuration variables which affect
282 the behavior and output of Mercurial should be
283 ignored. Additionally, the output should be stable,
284 reproducible and suitable for use in scripts or applications.
285
286 The only way to trigger plain mode is by setting either the
287 `HGPLAIN' or `HGPLAINEXCEPT' environment variables.
285 288
286 The only way to trigger plain mode is by setting the `HGPLAIN'
287 environment variable.
289 The return value can either be False, True, or a list of
290 features that plain mode should not apply to (e.g., i18n,
291 progress, etc).
288 292 '''
289 return 'HGPLAIN' in os.environ
293 if 'HGPLAIN' not in os.environ and 'HGPLAINEXCEPT' not in os.environ:
294 return False
295 exceptions = os.environ.get('HGPLAINEXCEPT', '').strip().split(',')
296 return exceptions or True
290 297
291 298 def username(self):
292 299 """Return default username to be used in commits.
@@ -133,3 +133,39 plain hgrc
133 133 none: ui.verbose=False
134 134 none: ui.debug=True
135 135 none: ui.quiet=False
136
137 plain mode with exceptions
138
139 $ cat > plain.py <<EOF
140 > def uisetup(ui):
141 > ui.write('plain: %r\n' % ui.plain())
142 > EOF
143 $ echo "[extensions]" >> $HGRCPATH
144 $ echo "plain=./plain.py" >> $HGRCPATH
145 $ HGPLAINEXCEPT=; export HGPLAINEXCEPT
146 $ hg showconfig --config ui.traceback=True --debug
147 plain: ['']
148 read config from: $TESTTMP/hgrc
149 $TESTTMP/hgrc:15: extensions.plain=./plain.py
150 none: ui.traceback=True
151 none: ui.verbose=False
152 none: ui.debug=True
153 none: ui.quiet=False
154 $ unset HGPLAIN
155 $ hg showconfig --config ui.traceback=True --debug
156 plain: ['']
157 read config from: $TESTTMP/hgrc
158 $TESTTMP/hgrc:15: extensions.plain=./plain.py
159 none: ui.traceback=True
160 none: ui.verbose=False
161 none: ui.debug=True
162 none: ui.quiet=False
163 $ HGPLAINEXCEPT=i18n; export HGPLAINEXCEPT
164 $ hg showconfig --config ui.traceback=True --debug
165 plain: ['i18n']
166 read config from: $TESTTMP/hgrc
167 $TESTTMP/hgrc:15: extensions.plain=./plain.py
168 none: ui.traceback=True
169 none: ui.verbose=False
170 none: ui.debug=True
171 none: ui.quiet=False
General Comments 0
You need to be logged in to leave comments. Login now