sapling/tests/extralog.py
Mark Thomas fc9106e076 dirstate: add checkoutidentifier to identify and correlate checkouts
Summary:
When the user checks out a new commit (either by updating to it, by
creating a new commit, or by amending or rebasing the current commit), create a
unique identifier for that checkout.

Log this identifier at the start and end of command processing, and allow other
tools to also query and log the identifier.

This allows both Mercurial commands and other commands that log the identifier
to be correlated with a particular checkout.

Reviewed By: quark-zju

Differential Revision: D14648523

fbshipit-source-id: 2fad79c3010f5fad1a0e180e3d3d6d9c0a7f8e85
2019-04-04 11:29:49 -07:00

29 lines
950 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:
keywords = ""
if opts and self.configbool("extralog", "keywords"):
keywords = " (%s)\n" % " ".join(
"%s=%s" % (n, v) for n, v in sorted(opts.items())
)
if msg:
ui.write("%s: " % event)
ui.write(msg[0] % msg[1:])
ui.write("%s" % keywords)
else:
ui.write("%s%s" % (event, keywords))
return super(extralogui, self).log(event, *msg, **opts)
ui.__class__ = extralogui