Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHGe00123f63410: util: make timedcm require the label (API)
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
| hg-reviewers |
| Lint Skipped |
| Unit Tests Skipped |
| import socket | import socket | ||||
| import stat | import stat | ||||
| import sys | import sys | ||||
| import time | import time | ||||
| import traceback | import traceback | ||||
| import warnings | import warnings | ||||
| import zlib | import zlib | ||||
| from hgdemandimport import tracing | |||||
| from .thirdparty import ( | from .thirdparty import ( | ||||
| attr, | attr, | ||||
| ) | ) | ||||
| from hgdemandimport import tracing | |||||
| from . import ( | from . import ( | ||||
| encoding, | encoding, | ||||
| error, | error, | ||||
| i18n, | i18n, | ||||
| node as nodemod, | node as nodemod, | ||||
| policy, | policy, | ||||
| pycompat, | pycompat, | ||||
| urllibcompat, | urllibcompat, | ||||
| level = attr.ib(default=1) | level = attr.ib(default=1) | ||||
| def __bytes__(self): | def __bytes__(self): | ||||
| return timecount(self.elapsed) if self.elapsed else '<unknown>' | return timecount(self.elapsed) if self.elapsed else '<unknown>' | ||||
| __str__ = encoding.strmethod(__bytes__) | __str__ = encoding.strmethod(__bytes__) | ||||
| @contextlib.contextmanager | @contextlib.contextmanager | ||||
| def timedcm(whencefmt='unknown timedcm', *whenceargs): | def timedcm(whencefmt, *whenceargs): | ||||
| """A context manager that produces timing information for a given context. | """A context manager that produces timing information for a given context. | ||||
| On entering a timedcmstats instance is produced. | On entering a timedcmstats instance is produced. | ||||
| This context manager is reentrant. | This context manager is reentrant. | ||||
| """ | """ | ||||
| # track nested context managers | # track nested context managers | ||||