sapling/tests/extralog.py
Mark Thomas de804dc6c0 undo: use extralog in tests rather than timing
Summary:
The undo tests use timing to detect when the lock is being taken.  This is
flaky.  Instead add extra logging to detect when the lock is taken.

Reviewed By: quark-zju

Differential Revision: D13504643

fbshipit-source-id: 07b80e416047d11b4ba3e1631c2385e5f12fa36f
2018-12-19 04:02:42 -08:00

22 lines
643 B
Python

"""enable ui.log output in tests
Wraps the ``ui.log`` method, printing out events which are enabled.
To enable events add them to the ``extralog.events`` config list.
"""
def uisetup(ui):
class extralogui(ui.__class__):
def log(self, event, *msg, **opts):
items = self.configlist("extralog", "events")
if event in items:
if msg:
ui.write("%s: " % event)
ui.write(msg[0] % msg[1:])
else:
ui.write("%s\n" % event)
return super(extralogui, self).log(event, *msg, **opts)
ui.__class__ = extralogui