comparison mercurial/ui.py @ 30999:fd598149112b

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.
author Simon Farnsworth <simonfar@fb.com>
date Wed, 15 Feb 2017 13:29:12 -0800
parents fdecd24ca4dc
children 60b5db2ab586
comparison
equal deleted inserted replaced
30998:fdecd24ca4dc 30999:fd598149112b
32 scmutil, 32 scmutil,
33 util, 33 util,
34 ) 34 )
35 35
36 urlreq = util.urlreq 36 urlreq = util.urlreq
37
38 # for use with str.translate(None, _keepalnum), to keep just alphanumerics
39 _keepalnum = ''.join(c for c in map(chr, range(256)) if not c.isalnum())
37 40
38 samplehgrcs = { 41 samplehgrcs = {
39 'user': 42 'user':
40 """# example user config (see 'hg help config' for more info) 43 """# example user config (see 'hg help config' for more info)
41 [ui] 44 [ui]
1144 finally: 1147 finally:
1145 os.unlink(name) 1148 os.unlink(name)
1146 1149
1147 return t 1150 return t
1148 1151
1149 def system(self, cmd, environ=None, cwd=None, onerr=None, errprefix=None): 1152 def system(self, cmd, environ=None, cwd=None, onerr=None, errprefix=None,
1153 blockedtag=None):
1150 '''execute shell command with appropriate output stream. command 1154 '''execute shell command with appropriate output stream. command
1151 output will be redirected if fout is not stdout. 1155 output will be redirected if fout is not stdout.
1152 ''' 1156 '''
1157 if blockedtag is None:
1158 blockedtag = 'unknown_system_' + cmd.translate(None, _keepalnum)
1153 out = self.fout 1159 out = self.fout
1154 if any(s[1] for s in self._bufferstates): 1160 if any(s[1] for s in self._bufferstates):
1155 out = self 1161 out = self
1156 return util.system(cmd, environ=environ, cwd=cwd, onerr=onerr, 1162 with self.timeblockedsection(blockedtag):
1157 errprefix=errprefix, out=out) 1163 return util.system(cmd, environ=environ, cwd=cwd, onerr=onerr,
1164 errprefix=errprefix, out=out)
1158 1165
1159 def traceback(self, exc=None, force=False): 1166 def traceback(self, exc=None, force=False):
1160 '''print exception traceback if traceback printing enabled or forced. 1167 '''print exception traceback if traceback printing enabled or forced.
1161 only to call in exception handler. returns true if traceback 1168 only to call in exception handler. returns true if traceback
1162 printed.''' 1169 printed.'''