Mercurial > public > mercurial-scm > hg
comparison mercurial/extensions.py @ 34845:78d9a7b7cdb6
extensions: always include traceback when extension setup fails
I have spent a lot of time debugging extensions that failed to load
because we don't include a traceback and I didn't realize I could get
traceback for the extension failure with --traceback. Let's just turn
them on by default, since it should be rare that the user sees these
tracebacks anyway (and if they do, it's not so bad if the extra
traceback pushes them a little harder to report the problem).
Since we already had a test case with --traceback and one without, I
just removed the one with the flag.
Differential Revision: https://phab.mercurial-scm.org/D1164
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 17 Oct 2017 10:31:44 -0700 |
parents | 4c5730c21523 |
children | 646002338365 |
comparison
equal
deleted
inserted
replaced
34844:f0a62afd1e40 | 34845:78d9a7b7cdb6 |
---|---|
180 uisetup = getattr(_extensions[name], 'uisetup', None) | 180 uisetup = getattr(_extensions[name], 'uisetup', None) |
181 if uisetup: | 181 if uisetup: |
182 try: | 182 try: |
183 uisetup(ui) | 183 uisetup(ui) |
184 except Exception as inst: | 184 except Exception as inst: |
185 ui.traceback() | 185 ui.traceback(force=True) |
186 msg = util.forcebytestr(inst) | 186 msg = util.forcebytestr(inst) |
187 ui.warn(_("*** failed to set up extension %s: %s\n") % (name, msg)) | 187 ui.warn(_("*** failed to set up extension %s: %s\n") % (name, msg)) |
188 return False | 188 return False |
189 return True | 189 return True |
190 | 190 |
201 if getattr(inspect, 'getfullargspec', | 201 if getattr(inspect, 'getfullargspec', |
202 getattr(inspect, 'getargspec'))(extsetup).args: | 202 getattr(inspect, 'getargspec'))(extsetup).args: |
203 raise | 203 raise |
204 extsetup() # old extsetup with no ui argument | 204 extsetup() # old extsetup with no ui argument |
205 except Exception as inst: | 205 except Exception as inst: |
206 ui.traceback() | 206 ui.traceback(force=True) |
207 msg = util.forcebytestr(inst) | 207 msg = util.forcebytestr(inst) |
208 ui.warn(_("*** failed to set up extension %s: %s\n") % (name, msg)) | 208 ui.warn(_("*** failed to set up extension %s: %s\n") % (name, msg)) |
209 return False | 209 return False |
210 return True | 210 return True |
211 | 211 |