# HG changeset patch # User Matt Harbison # Date 2018-03-03 05:35:59 # Node ID e39953fdd924c8e3a99c8f9f0bef4c118f16365e # Parent 68328202f270c17413d10b2c0adf0b8c6208de49 profile: colorize output on Windows Previously, the ANSI codes were printed to the screen, throwing off the alignment. We could probably do this unconditionally, but it's kind of a hack, so I figured I'd limit the scope. diff --git a/mercurial/profiling.py b/mercurial/profiling.py --- a/mercurial/profiling.py +++ b/mercurial/profiling.py @@ -14,6 +14,7 @@ from . import ( encoding, error, extensions, + pycompat, util, ) @@ -200,6 +201,17 @@ class profile(object): elif self._output: path = self._ui.expandpath(self._output) self._fp = open(path, 'wb') + elif pycompat.iswindows: + # parse escape sequence by win32print() + class uifp(object): + def __init__(self, ui): + self._ui = ui + def write(self, data): + self._ui.write_err(data) + def flush(self): + self._ui.flush() + self._fpdoclose = False + self._fp = uifp(self._ui) else: self._fpdoclose = False self._fp = self._ui.ferr