[Updated] D12158: color: don't infer vt status from TERM on Windows

mitchhentgesmozilla (Mitchell Hentges) phabricator at mercurial-scm.org
Mon Feb 14 10:46:58 UTC 2022


Closed by commit rHGfd2cf9e0c64e: color: don't infer vt status from TERM on Windows (authored by mitchhentgesmozilla).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D12158?vs=32110&id=32162

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D12158/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D12158

AFFECTED FILES
  mercurial/color.py

CHANGE DETAILS

diff --git a/mercurial/color.py b/mercurial/color.py
--- a/mercurial/color.py
+++ b/mercurial/color.py
@@ -248,28 +248,19 @@
     if pycompat.iswindows:
         from . import win32
 
-        term = encoding.environ.get(b'TERM')
-        # TERM won't be defined in a vanilla cmd.exe environment.
-
-        # UNIX-like environments on Windows such as Cygwin and MSYS will
-        # set TERM. They appear to make a best effort attempt at setting it
-        # to something appropriate. However, not all environments with TERM
-        # defined support ANSI.
-        ansienviron = term and b'xterm' in term
-
         if mode == b'auto':
             # Since "ansi" could result in terminal gibberish, we error on the
             # side of selecting "win32". However, if w32effects is not defined,
             # we almost certainly don't support "win32", so don't even try.
             # w32effects is not populated when stdout is redirected, so checking
             # it first avoids win32 calls in a state known to error out.
-            if ansienviron or not w32effects or win32.enablevtmode():
+            if not w32effects or win32.enablevtmode():
                 realmode = b'ansi'
             else:
                 realmode = b'win32'
         # An empty w32effects is a clue that stdout is redirected, and thus
         # cannot enable VT mode.
-        elif mode == b'ansi' and w32effects and not ansienviron:
+        elif mode == b'ansi' and w32effects:
             win32.enablevtmode()
     elif mode == b'auto':
         realmode = b'ansi'



To: mitchhentgesmozilla, #hg-reviewers, spectral, Alphare
Cc: spectral, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20220214/d349ca2c/attachment-0002.html>


More information about the Mercurial-patches mailing list