comparison mercurial/util.py @ 39259:e00123f63410

util: make timedcm require the label (API) Differential Revision: https://phab.mercurial-scm.org/D4350
author Augie Fackler <augie@google.com>
date Fri, 24 Aug 2018 10:13:27 -0700
parents 331ab85e910b
children b31b01f93b11
comparison
equal deleted inserted replaced
39258:331ab85e910b 39259:e00123f63410
34 import time 34 import time
35 import traceback 35 import traceback
36 import warnings 36 import warnings
37 import zlib 37 import zlib
38 38
39 from hgdemandimport import tracing
40 from .thirdparty import ( 39 from .thirdparty import (
41 attr, 40 attr,
42 ) 41 )
42 from hgdemandimport import tracing
43 from . import ( 43 from . import (
44 encoding, 44 encoding,
45 error, 45 error,
46 i18n, 46 i18n,
47 node as nodemod, 47 node as nodemod,
2895 return timecount(self.elapsed) if self.elapsed else '<unknown>' 2895 return timecount(self.elapsed) if self.elapsed else '<unknown>'
2896 2896
2897 __str__ = encoding.strmethod(__bytes__) 2897 __str__ = encoding.strmethod(__bytes__)
2898 2898
2899 @contextlib.contextmanager 2899 @contextlib.contextmanager
2900 def timedcm(whencefmt='unknown timedcm', *whenceargs): 2900 def timedcm(whencefmt, *whenceargs):
2901 """A context manager that produces timing information for a given context. 2901 """A context manager that produces timing information for a given context.
2902 2902
2903 On entering a timedcmstats instance is produced. 2903 On entering a timedcmstats instance is produced.
2904 2904
2905 This context manager is reentrant. 2905 This context manager is reentrant.