# HG changeset patch # User Matt Harbison # Date 1520055359 18000 # 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 -r 68328202f270 -r e39953fdd924 mercurial/profiling.py --- a/mercurial/profiling.py Sat Mar 03 19:02:50 2018 -0500 +++ b/mercurial/profiling.py Sat Mar 03 00:35:59 2018 -0500 @@ -14,6 +14,7 @@ encoding, error, extensions, + pycompat, util, ) @@ -200,6 +201,17 @@ 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