ui: time calls to ui.system
We want to know when we're blocked on ui.system, and why. Allow the user to
supply a tag - otherwise we record on an unspecific tag derived from cmd.
--- a/mercurial/ui.py Wed Feb 15 13:50:06 2017 -0800
+++ b/mercurial/ui.py Wed Feb 15 13:29:12 2017 -0800
@@ -35,6 +35,9 @@
urlreq = util.urlreq
+# for use with str.translate(None, _keepalnum), to keep just alphanumerics
+_keepalnum = ''.join(c for c in map(chr, range(256)) if not c.isalnum())
+
samplehgrcs = {
'user':
"""# example user config (see 'hg help config' for more info)
@@ -1146,15 +1149,19 @@
return t
- def system(self, cmd, environ=None, cwd=None, onerr=None, errprefix=None):
+ def system(self, cmd, environ=None, cwd=None, onerr=None, errprefix=None,
+ blockedtag=None):
'''execute shell command with appropriate output stream. command
output will be redirected if fout is not stdout.
'''
+ if blockedtag is None:
+ blockedtag = 'unknown_system_' + cmd.translate(None, _keepalnum)
out = self.fout
if any(s[1] for s in self._bufferstates):
out = self
- return util.system(cmd, environ=environ, cwd=cwd, onerr=onerr,
- errprefix=errprefix, out=out)
+ with self.timeblockedsection(blockedtag):
+ return util.system(cmd, environ=environ, cwd=cwd, onerr=onerr,
+ errprefix=errprefix, out=out)
def traceback(self, exc=None, force=False):
'''print exception traceback if traceback printing enabled or forced.