Mercurial > public > mercurial-scm > hg
comparison mercurial/extensions.py @ 39258:331ab85e910b
cleanup: make all uses of timedcm specify what they're timing
It's not used in the timing itself, but it's valuable for the trace
events we emit.
Differential Revision: https://phab.mercurial-scm.org/D4349
author | Augie Fackler <augie@google.com> |
---|---|
date | Tue, 21 Aug 2018 17:15:51 -0400 |
parents | d58958676b3c |
children | 1a2bfc4d756a |
comparison
equal
deleted
inserted
replaced
39257:497effb0a04a | 39258:331ab85e910b |
---|---|
175 return None | 175 return None |
176 if shortname in _extensions: | 176 if shortname in _extensions: |
177 return _extensions[shortname] | 177 return _extensions[shortname] |
178 log(' - loading extension: %r\n', shortname) | 178 log(' - loading extension: %r\n', shortname) |
179 _extensions[shortname] = None | 179 _extensions[shortname] = None |
180 with util.timedcm() as stats: | 180 with util.timedcm('load extension %r', shortname) as stats: |
181 mod = _importext(name, path, bind(_reportimporterror, ui)) | 181 mod = _importext(name, path, bind(_reportimporterror, ui)) |
182 log(' > %r extension loaded in %s\n', shortname, stats) | 182 log(' > %r extension loaded in %s\n', shortname, stats) |
183 | 183 |
184 # Before we do anything with the extension, check against minimum stated | 184 # Before we do anything with the extension, check against minimum stated |
185 # compatibility. This gives extension authors a mechanism to have their | 185 # compatibility. This gives extension authors a mechanism to have their |
194 _validatetables(ui, mod) | 194 _validatetables(ui, mod) |
195 | 195 |
196 _extensions[shortname] = mod | 196 _extensions[shortname] = mod |
197 _order.append(shortname) | 197 _order.append(shortname) |
198 log(' - invoking registered callbacks: %r\n', shortname) | 198 log(' - invoking registered callbacks: %r\n', shortname) |
199 with util.timedcm() as stats: | 199 with util.timedcm('callbacks extension %r', shortname) as stats: |
200 for fn in _aftercallbacks.get(shortname, []): | 200 for fn in _aftercallbacks.get(shortname, []): |
201 fn(loaded=True) | 201 fn(loaded=True) |
202 log(' > callbacks completed in %s\n', stats) | 202 log(' > callbacks completed in %s\n', stats) |
203 return mod | 203 return mod |
204 | 204 |
241 if whitelist is not None: | 241 if whitelist is not None: |
242 result = [(k, v) for (k, v) in result if k in whitelist] | 242 result = [(k, v) for (k, v) in result if k in whitelist] |
243 newindex = len(_order) | 243 newindex = len(_order) |
244 log('loading %sextensions\n', 'additional ' if newindex else '') | 244 log('loading %sextensions\n', 'additional ' if newindex else '') |
245 log('- processing %d entries\n', len(result)) | 245 log('- processing %d entries\n', len(result)) |
246 with util.timedcm() as stats: | 246 with util.timedcm('load all extensions') as stats: |
247 for (name, path) in result: | 247 for (name, path) in result: |
248 if path: | 248 if path: |
249 if path[0:1] == '!': | 249 if path[0:1] == '!': |
250 if name not in _disabledextensions: | 250 if name not in _disabledextensions: |
251 log(' - skipping disabled extension: %r\n', name) | 251 log(' - skipping disabled extension: %r\n', name) |
284 | 284 |
285 broken = set() | 285 broken = set() |
286 log('- executing uisetup hooks\n') | 286 log('- executing uisetup hooks\n') |
287 for name in _order[newindex:]: | 287 for name in _order[newindex:]: |
288 log(' - running uisetup for %r\n', name) | 288 log(' - running uisetup for %r\n', name) |
289 with util.timedcm() as stats: | 289 with util.timedcm('uisetup %r', name) as stats: |
290 if not _runuisetup(name, ui): | 290 if not _runuisetup(name, ui): |
291 log(' - the %r extension uisetup failed\n', name) | 291 log(' - the %r extension uisetup failed\n', name) |
292 broken.add(name) | 292 broken.add(name) |
293 log(' > uisetup for %r took %s\n', name, stats) | 293 log(' > uisetup for %r took %s\n', name, stats) |
294 | 294 |
295 log('- executing extsetup hooks\n') | 295 log('- executing extsetup hooks\n') |
296 for name in _order[newindex:]: | 296 for name in _order[newindex:]: |
297 if name in broken: | 297 if name in broken: |
298 continue | 298 continue |
299 log(' - running extsetup for %r\n', name) | 299 log(' - running extsetup for %r\n', name) |
300 with util.timedcm() as stats: | 300 with util.timedcm('extsetup %r', name) as stats: |
301 if not _runextsetup(name, ui): | 301 if not _runextsetup(name, ui): |
302 log(' - the %r extension extsetup failed\n', name) | 302 log(' - the %r extension extsetup failed\n', name) |
303 broken.add(name) | 303 broken.add(name) |
304 log(' > extsetup for %r took %s\n', name, stats) | 304 log(' > extsetup for %r took %s\n', name, stats) |
305 | 305 |
307 log(' - disabling broken %r extension\n', name) | 307 log(' - disabling broken %r extension\n', name) |
308 _extensions[name] = None | 308 _extensions[name] = None |
309 | 309 |
310 # Call aftercallbacks that were never met. | 310 # Call aftercallbacks that were never met. |
311 log('- executing remaining aftercallbacks\n') | 311 log('- executing remaining aftercallbacks\n') |
312 with util.timedcm() as stats: | 312 with util.timedcm('aftercallbacks') as stats: |
313 for shortname in _aftercallbacks: | 313 for shortname in _aftercallbacks: |
314 if shortname in _extensions: | 314 if shortname in _extensions: |
315 continue | 315 continue |
316 | 316 |
317 for fn in _aftercallbacks[shortname]: | 317 for fn in _aftercallbacks[shortname]: |
351 ('revsetpredicate', revset, 'loadpredicate'), | 351 ('revsetpredicate', revset, 'loadpredicate'), |
352 ('templatefilter', templatefilters, 'loadfilter'), | 352 ('templatefilter', templatefilters, 'loadfilter'), |
353 ('templatefunc', templatefuncs, 'loadfunction'), | 353 ('templatefunc', templatefuncs, 'loadfunction'), |
354 ('templatekeyword', templatekw, 'loadkeyword'), | 354 ('templatekeyword', templatekw, 'loadkeyword'), |
355 ] | 355 ] |
356 with util.timedcm() as stats: | 356 with util.timedcm('load registration objects') as stats: |
357 _loadextra(ui, newindex, extraloaders) | 357 _loadextra(ui, newindex, extraloaders) |
358 log('> extension registration object loading took %s\n', stats) | 358 log('> extension registration object loading took %s\n', stats) |
359 log('extension loading complete\n') | 359 log('extension loading complete\n') |
360 | 360 |
361 def _loadextra(ui, newindex, extraloaders): | 361 def _loadextra(ui, newindex, extraloaders): |