comparison mercurial/profiling.py @ 36683:e39953fdd924

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.
author Matt Harbison <matt_harbison@yahoo.com>
date Sat, 03 Mar 2018 00:35:59 -0500
parents 7b86aa31b004
children 15a1e37f80bd
comparison
equal deleted inserted replaced
36682:68328202f270 36683:e39953fdd924
12 from .i18n import _ 12 from .i18n import _
13 from . import ( 13 from . import (
14 encoding, 14 encoding,
15 error, 15 error,
16 extensions, 16 extensions,
17 pycompat,
17 util, 18 util,
18 ) 19 )
19 20
20 def _loadprofiler(ui, profiler): 21 def _loadprofiler(ui, profiler):
21 """load profiler extension. return profile method, or None on failure""" 22 """load profiler extension. return profile method, or None on failure"""
198 if self._output == 'blackbox': 199 if self._output == 'blackbox':
199 self._fp = util.stringio() 200 self._fp = util.stringio()
200 elif self._output: 201 elif self._output:
201 path = self._ui.expandpath(self._output) 202 path = self._ui.expandpath(self._output)
202 self._fp = open(path, 'wb') 203 self._fp = open(path, 'wb')
204 elif pycompat.iswindows:
205 # parse escape sequence by win32print()
206 class uifp(object):
207 def __init__(self, ui):
208 self._ui = ui
209 def write(self, data):
210 self._ui.write_err(data)
211 def flush(self):
212 self._ui.flush()
213 self._fpdoclose = False
214 self._fp = uifp(self._ui)
203 else: 215 else:
204 self._fpdoclose = False 216 self._fpdoclose = False
205 self._fp = self._ui.ferr 217 self._fp = self._ui.ferr
206 218
207 if proffn is not None: 219 if proffn is not None: