D1721: debug: customizable timestamp when printing ui.debug text
spectral (Kyle Lippincott)
phabricator at mercurial-scm.org
Tue Dec 19 01:48:48 UTC 2017
spectral created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
Sometimes users report "X is slow", where X is usually something that has
some debug output, like `hg push`. Having timestamps as part of the ui.debug()
output will help identify what they're seeing. The timestamp is customizable
using [ui]debugtimestampfmt, which accepts any timestamp that
datetime.strftime() can handle. I'm using datetime.strftime() since it provides
the %f format, at least on some platforms, and time.strftime() does not; having
sub-second precision is pretty useful for these messages.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D1721
AFFECTED FILES
mercurial/configitems.py
mercurial/ui.py
CHANGE DETAILS
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -9,6 +9,7 @@
import collections
import contextlib
+import datetime
import errno
import getpass
import inspect
@@ -440,6 +441,8 @@
"report_untrusted")
self.tracebackflag = self.configbool('ui', 'traceback')
self.logblockedtimes = self.configbool('ui', 'logblockedtimes')
+ self.debugtimestampfmt = self.config('ui', 'debugtimestampfmt',
+ None)
if section in (None, 'trusted'):
# update trust information
@@ -1394,6 +1397,9 @@
'''
if self.debugflag:
opts[r'label'] = opts.get(r'label', '') + ' ui.debug'
+ if self.debugtimestampfmt:
+ now = datetime.datetime.now()
+ self.write(now.strftime(self.debugtimestampfmt), ' ', **opts)
self.write(*msg, **opts)
def edit(self, text, user, extra=None, editform=None, pending=None,
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -971,6 +971,9 @@
coreconfigitem('ui', 'debugger',
default=None,
)
+coreconfigitem('ui', 'debugtimestampfmt',
+ default=None,
+)
coreconfigitem('ui', 'editor',
default=dynamicdefault,
)
To: spectral, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list