Comments
Patch
@@ -256,6 +256,49 @@
\x1b[30m\x1b[88mC \x1b[30m\x1b[30m\x1b[88m.hgignore\x1b[30m (esc)
\x1b[30m\x1b[88mC \x1b[30m\x1b[30m\x1b[88mmodified\x1b[30m (esc)
+color.autoterminfo chooses terminfo if it's viable:
+
+ $ TERM=hgterm TERMINFO="$TESTTMP/terminfo" hg status --config color.mode=auto --config color.autoterminfo=1 --config color.status.clean=dim -A
+ \x1b[30m\x1b[32m\x1b[2mA \x1b[30m\x1b[30m\x1b[32m\x1b[2madded\x1b[30m (esc)
+ \x1b[30m\x1b[32m\x1b[2mA \x1b[30m\x1b[30m\x1b[32m\x1b[2mcopied\x1b[30m (esc)
+ \x1b[30m\x1b[30m modified\x1b[30m (esc)
+ \x1b[30m\x1b[31m\x1b[2mR \x1b[30m\x1b[30m\x1b[31m\x1b[2mremoved\x1b[30m (esc)
+ \x1b[30m\x1b[36m\x1b[2m\x1b[4m! \x1b[30m\x1b[30m\x1b[36m\x1b[2m\x1b[4mdeleted\x1b[30m (esc)
+ \x1b[30m\x1b[35m\x1b[2m\x1b[4m? \x1b[30m\x1b[30m\x1b[35m\x1b[2m\x1b[4munknown\x1b[30m (esc)
+ \x1b[30m\x1b[30m\x1b[2mI \x1b[30m\x1b[30m\x1b[30m\x1b[2mignored\x1b[30m (esc)
+ \x1b[30m\x1b[88mC \x1b[30m\x1b[30m\x1b[88m.hgignore\x1b[30m (esc)
+ \x1b[30m\x1b[88mC \x1b[30m\x1b[30m\x1b[88mmodified\x1b[30m (esc)
+
+ECMA fallback warning with mode=terminfo explicit:
+
+ $ TERMINFO="$TESTTMP/terminfo" tic "$TESTDIR/hgterm-dumb.ti"
+ $ TERM=hgterm-dumb TERMINFO="$TESTTMP/terminfo" hg status --config color.mode=terminfo -A
+ no terminfo entry for setab/setaf: reverting to ECMA-48 color
+ no terminfo entry for setab/setaf: reverting to ECMA-48 color
+ no terminfo entry for setab/setaf: reverting to ECMA-48 color
+ \x1b[0;32;1mA \x1b[0m\x1b[0;32;1madded\x1b[0m (esc)
+ \x1b[0;32;1mA \x1b[0m\x1b[0;32;1mcopied\x1b[0m (esc)
+ \x1b[0;0m modified\x1b[0m (esc)
+ \x1b[0;31;1mR \x1b[0m\x1b[0;31;1mremoved\x1b[0m (esc)
+ \x1b[0;36;1;4m! \x1b[0m\x1b[0;36;1;4mdeleted\x1b[0m (esc)
+ \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4munknown\x1b[0m (esc)
+ \x1b[0;30;1mI \x1b[0m\x1b[0;30;1mignored\x1b[0m (esc)
+ \x1b[0;0mC \x1b[0m\x1b[0;0m.hgignore\x1b[0m (esc)
+ \x1b[0;0mC \x1b[0m\x1b[0;0mmodified\x1b[0m (esc)
+
+No fallback warning with autoterminfo:
+
+ $ TERM=hgterm-dumb TERMINFO="$TESTTMP/terminfo" hg status --config color.mode=auto --config color.autoterminfo=1 -A
+ \x1b[0;32;1mA \x1b[0m\x1b[0;32;1madded\x1b[0m (esc)
+ \x1b[0;32;1mA \x1b[0m\x1b[0;32;1mcopied\x1b[0m (esc)
+ \x1b[0;0m modified\x1b[0m (esc)
+ \x1b[0;31;1mR \x1b[0m\x1b[0;31;1mremoved\x1b[0m (esc)
+ \x1b[0;36;1;4m! \x1b[0m\x1b[0;36;1;4mdeleted\x1b[0m (esc)
+ \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4munknown\x1b[0m (esc)
+ \x1b[0;30;1mI \x1b[0m\x1b[0;30;1mignored\x1b[0m (esc)
+ \x1b[0;0mC \x1b[0m\x1b[0;0m.hgignore\x1b[0m (esc)
+ \x1b[0;0mC \x1b[0m\x1b[0;0mmodified\x1b[0m (esc)
+
#endif
new file mode 100644
@@ -0,0 +1,4 @@
+hgterm-dumb,
+ am,
+ cols#80,
+ bel=^G, cr=^M, cud1=^J, ind=^J,
@@ -412,22 +412,26 @@
Configure the Mercurial color mode. For details about how to define your custom
effect and style see :hg:`help color`.
+``autoterminfo``
+ Make ``color.mode=auto`` attempt ``terminfo`` before falling back to
+ ``ansi``. Does not have an effect on Windows systems. (default: False)
+
``mode``
String: control the method used to output color. One of ``auto``, ``ansi``,
- ``win32``, ``terminfo`` or ``debug``. In auto mode, Mercurial will
- use ANSI mode by default (or win32 mode prior to Windows 10) if it detects a
- terminal. Any invalid value will disable color.
+ ``win32``, ``terminfo`` or ``debug``. In auto mode, Mercurial will change
+ its behavior depending on the OS and the value of autoterminfo, by default
+ it uses ANSI mode (win32 mode prior to Windows 10) if it detects a terminal.
+ Any invalid value will disable color.
``pagermode``
String: optional override of ``color.mode`` used with pager.
On some systems, terminfo mode may cause problems when using
color with ``less -R`` as a pager program. less with the -R option
will only display ECMA-48 color codes, and terminfo mode may sometimes
emit codes that less doesn't understand. You can work around this by
- either using ansi mode (or auto mode), or by using less -r (which will
- pass through all terminal control codes, not just color control
- codes).
+ specifying ``ansi`` here, or by using less -r (which will pass through all
+ terminal control codes, not just color control codes).
On some systems (such as MSYS in Windows), the terminal may support
a different color mode than the pager program.
@@ -237,7 +237,11 @@
elif mode == 'ansi' and w32effects and not ansienviron:
win32.enablevtmode()
elif mode == 'auto':
- realmode = 'ansi'
+ if ui.configbool('color', 'autoterminfo', False):
+ # If terminfo setup fails, we will still fallback to ansi, below.
+ realmode = 'terminfo'
+ else:
+ realmode = 'ansi'
def modewarn():
# only warn if color.mode was explicitly set and we're in