Mercurial > public > mercurial-scm > hg-stable
diff mercurial/util.py @ 38852:9d49bb117dde
util: make new timedcmstats class Python 3 compatible
author | Martijn Pieters <mj@zopatista.com> |
---|---|
date | Thu, 02 Aug 2018 20:53:03 +0100 |
parents | 8751d1e2a7ff |
children | ed8160e4fea0 |
line wrap: on
line diff
--- a/mercurial/util.py Wed Aug 01 16:03:32 2018 -0700 +++ b/mercurial/util.py Thu Aug 02 20:53:03 2018 +0100 @@ -2890,9 +2890,11 @@ # the number of nested timedcm context managers. level = attr.ib(default=1) - def __str__(self): + def __bytes__(self): return timecount(self.elapsed) if self.elapsed else '<unknown>' + __str__ = encoding.strmethod(__bytes__) + @contextlib.contextmanager def timedcm(): """A context manager that produces timing information for a given context. @@ -2929,7 +2931,8 @@ result = func(*args, **kwargs) stderr = procutil.stderr stderr.write('%s%s: %s\n' % ( - ' ' * time_stats.level * 2, func.__name__, time_stats)) + ' ' * time_stats.level * 2, pycompat.bytestr(func.__name__), + time_stats)) return result return wrapper