comparison mercurial/hook.py @ 28079:0c9e914029be

hook: fewer parentheses for hook load errors This matches 'hook failed' warnings. We're also going to add hints to some of the hook load errors. Without this change we'd have two pairs of parens for a single error message, which looks really cluttered.
author Siddharth Agarwal <sid0@fb.com>
date Thu, 11 Feb 2016 22:41:20 -0800
parents 2058e1a894f2
children 37b818cad146
comparison
equal deleted inserted replaced
28078:2058e1a894f2 28079:0c9e914029be
63 if ui.tracebackflag: 63 if ui.tracebackflag:
64 ui.warn(_('exception from second failed import ' 64 ui.warn(_('exception from second failed import '
65 'attempt:\n')) 65 'attempt:\n'))
66 ui.traceback(e2) 66 ui.traceback(e2)
67 raise error.HookLoadError( 67 raise error.HookLoadError(
68 _('%s hook is invalid (import of "%s" failed)') % 68 _('%s hook is invalid: import of "%s" failed') %
69 (hname, modname)) 69 (hname, modname))
70 sys.path = oldpaths 70 sys.path = oldpaths
71 try: 71 try:
72 for p in funcname.split('.')[1:]: 72 for p in funcname.split('.')[1:]:
73 obj = getattr(obj, p) 73 obj = getattr(obj, p)
74 except AttributeError: 74 except AttributeError:
75 raise error.HookLoadError( 75 raise error.HookLoadError(
76 _('%s hook is invalid ("%s" is not defined)') 76 _('%s hook is invalid: "%s" is not defined')
77 % (hname, funcname)) 77 % (hname, funcname))
78 if not callable(obj): 78 if not callable(obj):
79 raise error.HookLoadError( 79 raise error.HookLoadError(
80 _('%s hook is invalid ("%s" is not callable)') 80 _('%s hook is invalid: "%s" is not callable')
81 % (hname, funcname)) 81 % (hname, funcname))
82 82
83 ui.note(_("calling hook %s: %s\n") % (hname, funcname)) 83 ui.note(_("calling hook %s: %s\n") % (hname, funcname))
84 starttime = time.time() 84 starttime = time.time()
85 85