Mercurial > hg
changeset 11324:cdf6d861b207
ui: add ui.formatted configuration variable and accessor function.
This new configuration variable is similar in nature `ui.interactive',
but applying to output instead of input. This allows as to support
non-interactive sessions where formatted should be enabled, such as
when using the pager extension.
The variable itself is left undocumented; it is not intended for use
outside Mercurial and its extensions.
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Mon, 07 Jun 2010 14:59:52 +0200 |
parents | d65b74106113 |
children | 22a737306ba5 |
files | mercurial/ui.py |
diffstat | 1 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/ui.py Thu Jun 10 17:10:05 2010 +0200 +++ b/mercurial/ui.py Mon Jun 07 14:59:52 2010 +0200 @@ -380,6 +380,21 @@ return i + def formatted(self): + if self.plain(): + return False + + i = self.configbool("ui", "formatted", None) + if i is None: + try: + return sys.stdout.isatty() + except AttributeError: + # some environments replace stdout without implementing isatty + # usually those are non-interactive + return False + + return i + def _readline(self, prompt=''): if sys.stdin.isatty(): try: