Show More
@@ -162,6 +162,9 b' ignore = [' | |||||
162 | 'mimetools', |
|
162 | 'mimetools', | |
163 | ] |
|
163 | ] | |
164 |
|
164 | |||
|
165 | def isenabled(): | |||
|
166 | return __builtin__.__import__ == _demandimport | |||
|
167 | ||||
165 | def enable(): |
|
168 | def enable(): | |
166 | "enable global demand-loading of modules" |
|
169 | "enable global demand-loading of modules" | |
167 | __builtin__.__import__ = _demandimport |
|
170 | __builtin__.__import__ = _demandimport |
@@ -36,28 +36,33 b' def _pythonhook(ui, repo, name, hname, f' | |||||
36 | if modpath and modfile: |
|
36 | if modpath and modfile: | |
37 | sys.path = sys.path[:] + [modpath] |
|
37 | sys.path = sys.path[:] + [modpath] | |
38 | modname = modfile |
|
38 | modname = modfile | |
39 | try: |
|
39 | demandimportenabled = demandimport.isenabled() | |
|
40 | if demandimportenabled: | |||
40 | demandimport.disable() |
|
41 | demandimport.disable() | |
41 | obj = __import__(modname) |
|
42 | try: | |
42 | demandimport.enable() |
|
|||
43 | except ImportError: |
|
|||
44 | e1 = sys.exc_type, sys.exc_value, sys.exc_traceback |
|
|||
45 | try: |
|
43 | try: | |
46 | # extensions are loaded with hgext_ prefix |
|
44 | obj = __import__(modname) | |
47 | obj = __import__("hgext_%s" % modname) |
|
|||
48 | demandimport.enable() |
|
|||
49 | except ImportError: |
|
45 | except ImportError: | |
|
46 | e1 = sys.exc_type, sys.exc_value, sys.exc_traceback | |||
|
47 | try: | |||
|
48 | # extensions are loaded with hgext_ prefix | |||
|
49 | obj = __import__("hgext_%s" % modname) | |||
|
50 | except ImportError: | |||
|
51 | e2 = sys.exc_type, sys.exc_value, sys.exc_traceback | |||
|
52 | if ui.tracebackflag: | |||
|
53 | ui.warn(_('exception from first failed import ' | |||
|
54 | 'attempt:\n')) | |||
|
55 | ui.traceback(e1) | |||
|
56 | if ui.tracebackflag: | |||
|
57 | ui.warn(_('exception from second failed import ' | |||
|
58 | 'attempt:\n')) | |||
|
59 | ui.traceback(e2) | |||
|
60 | raise util.Abort(_('%s hook is invalid ' | |||
|
61 | '(import of "%s" failed)') % | |||
|
62 | (hname, modname)) | |||
|
63 | finally: | |||
|
64 | if demandimportenabled: | |||
50 | demandimport.enable() |
|
65 | demandimport.enable() | |
51 | e2 = sys.exc_type, sys.exc_value, sys.exc_traceback |
|
|||
52 | if ui.tracebackflag: |
|
|||
53 | ui.warn(_('exception from first failed import attempt:\n')) |
|
|||
54 | ui.traceback(e1) |
|
|||
55 | if ui.tracebackflag: |
|
|||
56 | ui.warn(_('exception from second failed import attempt:\n')) |
|
|||
57 | ui.traceback(e2) |
|
|||
58 | raise util.Abort(_('%s hook is invalid ' |
|
|||
59 | '(import of "%s" failed)') % |
|
|||
60 | (hname, modname)) |
|
|||
61 | sys.path = oldpaths |
|
66 | sys.path = oldpaths | |
62 | try: |
|
67 | try: | |
63 | for p in funcname.split('.')[1:]: |
|
68 | for p in funcname.split('.')[1:]: |
General Comments 0
You need to be logged in to leave comments.
Login now