comparison mercurial/hg.py @ 39507:a5d6bf6032fb

extensions: add timing for extensions reposetup Differential Revision: https://phab.mercurial-scm.org/D4509
author Boris Feld <boris.feld@octobus.net>
date Mon, 10 Sep 2018 19:36:25 -0700
parents ddfd80029306
children 340170192874
comparison
equal deleted inserted replaced
39506:b66ea3fc3a86 39507:a5d6bf6032fb
7 # GNU General Public License version 2 or any later version. 7 # GNU General Public License version 2 or any later version.
8 8
9 from __future__ import absolute_import 9 from __future__ import absolute_import
10 10
11 import errno 11 import errno
12 import functools
13 import hashlib 12 import hashlib
14 import os 13 import os
15 import shutil 14 import shutil
16 import stat 15 import stat
17 16
162 intents=None): 161 intents=None):
163 """return a repository object for the specified path""" 162 """return a repository object for the specified path"""
164 obj = _peerlookup(path).instance(ui, path, create, intents=intents) 163 obj = _peerlookup(path).instance(ui, path, create, intents=intents)
165 ui = getattr(obj, "ui", ui) 164 ui = getattr(obj, "ui", ui)
166 if ui.configbool('devel', 'debug.extensions'): 165 if ui.configbool('devel', 'debug.extensions'):
167 log = functools.partial( 166 log = lambda msg, *values: ui.debug('debug.extensions: ',
168 ui.debug, 'debug.extensions: ', label='debug.extensions') 167 msg % values, label='debug.extensions')
169 else: 168 else:
170 log = lambda *a, **kw: None 169 log = lambda *a, **kw: None
171 for f in presetupfuncs or []: 170 for f in presetupfuncs or []:
172 f(ui, obj) 171 f(ui, obj)
173 log('- executing reposetup hooks\n') 172 log('- executing reposetup hooks\n')
174 for name, module in extensions.extensions(ui): 173 for name, module in extensions.extensions(ui):
175 log(' - running reposetup for %s\n' % (name,)) 174 log(' - running reposetup for %s\n' % (name,))
176 hook = getattr(module, 'reposetup', None) 175 hook = getattr(module, 'reposetup', None)
177 if hook: 176 if hook:
178 hook(ui, obj) 177 with util.timedcm('reposetup %r', name) as stats:
178 hook(ui, obj)
179 log(' > reposetup for %r took %s\n', name, stats)
179 if not obj.local(): 180 if not obj.local():
180 for f in wirepeersetupfuncs: 181 for f in wirepeersetupfuncs:
181 f(ui, obj) 182 f(ui, obj)
182 return obj 183 return obj
183 184