[PATCH] RFC: ui.style only for tty, ui.ttystyle
Yuya Nishihara
yuya at tcha.org
Thu Feb 11 01:27:10 CST 2010
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1265873127 -32400
# Node ID 3a6e034ff3dd3308d55f7e8e791176a6b5d0a4fa
# Parent b59fba37e5e6ffd45cabfbfd8f70f9554f3dbee5
RFC: ui.style only for tty, ui.ttystyle
`ui.style' is great for customizing `hg log' output.
But once ui.style set, some third-party tools, e.g. emacs vc or dvc,
don't work correctly because they depend on the default log style.
This introduces `ui.ttystyle' to change the style only for tty output.
This is also good for specifying colorized styles like:
http://hgtip.com/tips/advanced/2010-01-15-styling-mercurials-cli/
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -884,7 +884,8 @@ def show_changeset(ui, repo, opts, buffe
1. option 'template'
2. option 'style'
3. [ui] setting 'logtemplate'
- 4. [ui] setting 'style'
+ 4. [ui] setting 'ttystyle' if stdout is a tty
+ 5. [ui] setting 'style'
If all of these values are either the unset or the empty string,
regular display via changeset_printer() is done.
"""
@@ -906,7 +907,11 @@ def show_changeset(ui, repo, opts, buffe
if tmpl:
tmpl = templater.parsestring(tmpl)
else:
- style = util.expandpath(ui.config('ui', 'style', ''))
+ # hgext.pager replaces sys.stdout by a pager process
+ if sys.__stdout__.isatty():
+ style = util.expandpath(ui.config('ui', 'ttystyle', ''))
+ if not style:
+ style = util.expandpath(ui.config('ui', 'style', ''))
if not (tmpl or style):
return changeset_printer(ui, repo, patch, opts, buffered)
More information about the Mercurial-devel
mailing list