[Updated] D10760: run-tests: enable color on Windows
mharbison72 (Matt Harbison)
phabricator at mercurial-scm.org
Sun May 23 22:06:58 UTC 2021
Closed by commit rHGbb4606f35d37: run-tests: enable color on Windows (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D10760?vs=28163&id=28185
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D10760/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D10760
AFFECTED FILES
tests/run-tests.py
CHANGE DETAILS
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -87,21 +87,31 @@
processlock = threading.Lock()
pygmentspresent = False
-# ANSI color is unsupported prior to Windows 10
-if os.name != 'nt':
- try: # is pygments installed
- import pygments
- import pygments.lexers as lexers
- import pygments.lexer as lexer
- import pygments.formatters as formatters
- import pygments.token as token
- import pygments.style as style
-
- pygmentspresent = True
- difflexer = lexers.DiffLexer()
- terminal256formatter = formatters.Terminal256Formatter()
- except ImportError:
- pass
+try: # is pygments installed
+ import pygments
+ import pygments.lexers as lexers
+ import pygments.lexer as lexer
+ import pygments.formatters as formatters
+ import pygments.token as token
+ import pygments.style as style
+
+ if os.name == 'nt':
+ hgpath = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+ sys.path.append(hgpath)
+ try:
+ from mercurial import win32 # pytype: disable=import-error
+
+ # Don't check the result code because it fails on heptapod, but
+ # something is able to convert to color anyway.
+ win32.enablevtmode()
+ finally:
+ sys.path = sys.path[:-1]
+
+ pygmentspresent = True
+ difflexer = lexers.DiffLexer()
+ terminal256formatter = formatters.Terminal256Formatter()
+except ImportError:
+ pass
if pygmentspresent:
To: mharbison72, #hg-reviewers, pulkit
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210523/dc8157a2/attachment-0002.html>
More information about the Mercurial-patches
mailing list