diff mercurial/hg.py @ 38838:d58958676b3c

extensions: add detailed loading information This lets you track down what exactly is happening during extension loading, and how long various steps took.
author Martijn Pieters <mj@zopatista.com>
date Wed, 01 Aug 2018 16:06:53 +0200
parents e06a10d3b926
children 143efea71c2a
line wrap: on
line diff
--- a/mercurial/hg.py	Wed Aug 01 16:05:41 2018 +0200
+++ b/mercurial/hg.py	Wed Aug 01 16:06:53 2018 +0200
@@ -9,6 +9,7 @@
 from __future__ import absolute_import
 
 import errno
+import functools
 import hashlib
 import os
 import shutil
@@ -162,9 +163,16 @@
     """return a repository object for the specified path"""
     obj = _peerlookup(path).instance(ui, path, create, intents=intents)
     ui = getattr(obj, "ui", ui)
+    if ui.configbool('devel', 'debug.extensions'):
+        log = functools.partial(
+            ui.debug, 'debug.extensions: ', label='debug.extensions')
+    else:
+        log = lambda *a, **kw: None
     for f in presetupfuncs or []:
         f(ui, obj)
+    log('- executing reposetup hooks\n')
     for name, module in extensions.extensions(ui):
+        log('  - running reposetup for %s\n' % (name,))
         hook = getattr(module, 'reposetup', None)
         if hook:
             hook(ui, obj)