Mercurial > public > mercurial-scm > hg
comparison mercurial/exthelper.py @ 42316:c07dcf7a0247
exthelper: add some semi-useful trace logs
It'd be nice to make the trace functions a little better-named in the output,
but I'm not sure how much better we can do without overhead. This at least
lets you see if a single reposetup function is eating all the time or if it's
spread over all of them. I needed this because Google's uber-extension has a
long load time and I wasn't sure where the problem was.
Differential Revision: https://phab.mercurial-scm.org/D6381
author | Augie Fackler <augie@google.com> |
---|---|
date | Wed, 15 May 2019 17:18:57 -0400 |
parents | c9e1104e6272 |
children | 2372284d9457 |
comparison
equal
deleted
inserted
replaced
42315:c77857693005 | 42316:c07dcf7a0247 |
---|---|
13 | 13 |
14 from . import ( | 14 from . import ( |
15 commands, | 15 commands, |
16 error, | 16 error, |
17 extensions, | 17 extensions, |
18 pycompat, | |
18 registrar, | 19 registrar, |
19 ) | 20 ) |
21 | |
22 from hgdemandimport import tracing | |
20 | 23 |
21 class exthelper(object): | 24 class exthelper(object): |
22 """Helper for modular extension setup | 25 """Helper for modular extension setup |
23 | 26 |
24 A single helper should be instantiated for each module of an | 27 A single helper should be instantiated for each module of an |
133 for opt in opts: | 136 for opt in opts: |
134 entry[1].append(opt) | 137 entry[1].append(opt) |
135 for cont, funcname, wrapper in self._functionwrappers: | 138 for cont, funcname, wrapper in self._functionwrappers: |
136 extensions.wrapfunction(cont, funcname, wrapper) | 139 extensions.wrapfunction(cont, funcname, wrapper) |
137 for c in self._uicallables: | 140 for c in self._uicallables: |
138 c(ui) | 141 with tracing.log(b'finaluisetup: %s', pycompat.sysbytes(repr(c))): |
142 c(ui) | |
139 | 143 |
140 def finaluipopulate(self, ui): | 144 def finaluipopulate(self, ui): |
141 """Method to be used as the extension uipopulate | 145 """Method to be used as the extension uipopulate |
142 | 146 |
143 This is called once per ui instance to: | 147 This is called once per ui instance to: |
173 if opts: | 177 if opts: |
174 for opt in opts: | 178 for opt in opts: |
175 entry[1].append(opt) | 179 entry[1].append(opt) |
176 | 180 |
177 for c in self._extcallables: | 181 for c in self._extcallables: |
178 c(ui) | 182 with tracing.log(b'finalextsetup: %s', pycompat.sysbytes(repr(c))): |
183 c(ui) | |
179 | 184 |
180 def finalreposetup(self, ui, repo): | 185 def finalreposetup(self, ui, repo): |
181 """Method to be used as the extension reposetup | 186 """Method to be used as the extension reposetup |
182 | 187 |
183 The following operations belong here: | 188 The following operations belong here: |
185 - All hooks but pre-* and post-* | 190 - All hooks but pre-* and post-* |
186 - Modify configuration variables | 191 - Modify configuration variables |
187 - Changes to repo.__class__, repo.dirstate.__class__ | 192 - Changes to repo.__class__, repo.dirstate.__class__ |
188 """ | 193 """ |
189 for c in self._repocallables: | 194 for c in self._repocallables: |
190 c(ui, repo) | 195 with tracing.log(b'finalreposetup: %s', pycompat.sysbytes(repr(c))): |
196 c(ui, repo) | |
191 | 197 |
192 def uisetup(self, call): | 198 def uisetup(self, call): |
193 """Decorated function will be executed during uisetup | 199 """Decorated function will be executed during uisetup |
194 | 200 |
195 example:: | 201 example:: |