Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/ui.py @ 14372:be0daa0eeb3e
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@anciens.enib.fr>
author | "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr> |
---|---|
date | Tue, 17 May 2011 00:08:51 +0200 |
parents | fa2b596db182 |
children | a599431b0ab6 |
comparison
equal
deleted
inserted
replaced
14371:ec2aae8b375d | 14372:be0daa0eeb3e |
---|---|
328 cfg = self._data(untrusted) | 328 cfg = self._data(untrusted) |
329 for section in cfg.sections(): | 329 for section in cfg.sections(): |
330 for name, value in self.configitems(section, untrusted): | 330 for name, value in self.configitems(section, untrusted): |
331 yield section, name, value | 331 yield section, name, value |
332 | 332 |
333 def plain(self): | 333 def plain(self, feature=None): |
334 '''is plain mode active? | 334 '''is plain mode active? |
335 | 335 |
336 Plain mode means that all configuration variables which affect | 336 Plain mode means that all configuration variables which affect |
337 the behavior and output of Mercurial should be | 337 the behavior and output of Mercurial should be |
338 ignored. Additionally, the output should be stable, | 338 ignored. Additionally, the output should be stable, |
339 reproducible and suitable for use in scripts or applications. | 339 reproducible and suitable for use in scripts or applications. |
340 | 340 |
341 The only way to trigger plain mode is by setting either the | 341 The only way to trigger plain mode is by setting either the |
342 `HGPLAIN' or `HGPLAINEXCEPT' environment variables. | 342 `HGPLAIN' or `HGPLAINEXCEPT' environment variables. |
343 | 343 |
344 The return value can either be False, True, or a list of | 344 The return value can either be |
345 features that plain mode should not apply to (e.g., i18n, | 345 - False if HGPLAIN is not set, or feature is in HGPLAINEXCEPT |
346 progress, etc). | 346 - True otherwise |
347 ''' | 347 ''' |
348 if 'HGPLAIN' not in os.environ and 'HGPLAINEXCEPT' not in os.environ: | 348 if 'HGPLAIN' not in os.environ and 'HGPLAINEXCEPT' not in os.environ: |
349 return False | 349 return False |
350 exceptions = os.environ.get('HGPLAINEXCEPT', '').strip().split(',') | 350 exceptions = os.environ.get('HGPLAINEXCEPT', '').strip().split(',') |
351 return exceptions or True | 351 if feature and exceptions: |
352 return feature not in exceptions | |
353 return True | |
352 | 354 |
353 def username(self): | 355 def username(self): |
354 """Return default username to be used in commits. | 356 """Return default username to be used in commits. |
355 | 357 |
356 Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL | 358 Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL |