Show More
@@ -59,6 +59,14 b' HGPLAIN' | |||||
59 | Equivalent options set via command line flags or environment |
|
59 | Equivalent options set via command line flags or environment | |
60 | variables are not overridden. |
|
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 | HGUSER |
|
70 | HGUSER | |
63 | This is the string used as the author of a commit. If not set, |
|
71 | This is the string used as the author of a commit. If not set, | |
64 | available values will be considered in this order: |
|
72 | available values will be considered in this order: |
@@ -51,7 +51,13 b' def gettext(message):' | |||||
51 | # An unknown encoding results in a LookupError. |
|
51 | # An unknown encoding results in a LookupError. | |
52 | return message |
|
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 | _ = lambda message: message |
|
61 | _ = lambda message: message | |
56 | else: |
|
62 | else: | |
57 | _ = gettext |
|
63 | _ = gettext |
@@ -278,15 +278,22 b' class ui(object):' | |||||
278 | def plain(self): |
|
278 | def plain(self): | |
279 | '''is plain mode active? |
|
279 | '''is plain mode active? | |
280 |
|
280 | |||
281 |
Plain mode means that all configuration variables which affect |
|
281 | Plain mode means that all configuration variables which affect | |
282 |
behavior and output of Mercurial should be |
|
282 | the behavior and output of Mercurial should be | |
283 | output should be stable, reproducible and suitable for use in scripts or |
|
283 | ignored. Additionally, the output should be stable, | |
284 | applications. |
|
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' |
|
289 | The return value can either be False, True, or a list of | |
287 | environment variable. |
|
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 | def username(self): |
|
298 | def username(self): | |
292 | """Return default username to be used in commits. |
|
299 | """Return default username to be used in commits. |
@@ -133,3 +133,39 b' plain hgrc' | |||||
133 | none: ui.verbose=False |
|
133 | none: ui.verbose=False | |
134 | none: ui.debug=True |
|
134 | none: ui.debug=True | |
135 | none: ui.quiet=False |
|
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