[PATCH 1 of 5] ui: add ui.formatted configuration variable and accessor function
Dan Villiom Podlaski Christiansen
danchr at gmail.com
Mon Jun 7 09:23:47 CDT 2010
# HG changeset patch
# User Dan Villiom Podlaski Christiansen <danchr at gmail.com>
# Date 1275915592 -7200
# Node ID 78cf0cf278357d06305b6aaef40c293b760c346a
# Parent 9938092903f44f0524547d34c11b08e533a5b6c6
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.
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -380,6 +380,21 @@ class ui(object):
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:
More information about the Mercurial-devel
mailing list