Show More
@@ -57,6 +57,12 b' class Abort(HintException):' | |||||
57 | """Raised if a command needs to print an error and exit.""" |
|
57 | """Raised if a command needs to print an error and exit.""" | |
58 | pass |
|
58 | pass | |
59 |
|
59 | |||
|
60 | class HookLoadError(Abort): | |||
|
61 | """raised when loading a hook fails, aborting an operation | |||
|
62 | ||||
|
63 | Exists to allow more specialized catching.""" | |||
|
64 | pass | |||
|
65 | ||||
60 | class HookAbort(Abort): |
|
66 | class HookAbort(Abort): | |
61 | """raised when a validation hook fails, aborting an operation |
|
67 | """raised when a validation hook fails, aborting an operation | |
62 |
|
68 |
@@ -35,8 +35,9 b' def _pythonhook(ui, repo, name, hname, f' | |||||
35 | else: |
|
35 | else: | |
36 | d = funcname.rfind('.') |
|
36 | d = funcname.rfind('.') | |
37 | if d == -1: |
|
37 | if d == -1: | |
38 | raise error.Abort(_('%s hook is invalid ("%s" not in ' |
|
38 | raise error.HookLoadError( | |
39 | 'a module)') % (hname, funcname)) |
|
39 | _('%s hook is invalid ("%s" not in a module)') | |
|
40 | % (hname, funcname)) | |||
40 | modname = funcname[:d] |
|
41 | modname = funcname[:d] | |
41 | oldpaths = sys.path |
|
42 | oldpaths = sys.path | |
42 | if util.mainfrozen(): |
|
43 | if util.mainfrozen(): | |
@@ -63,21 +64,21 b' def _pythonhook(ui, repo, name, hname, f' | |||||
63 | ui.warn(_('exception from second failed import ' |
|
64 | ui.warn(_('exception from second failed import ' | |
64 | 'attempt:\n')) |
|
65 | 'attempt:\n')) | |
65 | ui.traceback(e2) |
|
66 | ui.traceback(e2) | |
66 |
raise error. |
|
67 | raise error.HookLoadError( | |
67 |
|
|
68 | _('%s hook is invalid (import of "%s" failed)') % | |
68 |
|
|
69 | (hname, modname)) | |
69 | sys.path = oldpaths |
|
70 | sys.path = oldpaths | |
70 | try: |
|
71 | try: | |
71 | for p in funcname.split('.')[1:]: |
|
72 | for p in funcname.split('.')[1:]: | |
72 | obj = getattr(obj, p) |
|
73 | obj = getattr(obj, p) | |
73 | except AttributeError: |
|
74 | except AttributeError: | |
74 |
raise error. |
|
75 | raise error.HookLoadError( | |
75 |
|
|
76 | _('%s hook is invalid ("%s" is not defined)') | |
76 |
|
|
77 | % (hname, funcname)) | |
77 | if not callable(obj): |
|
78 | if not callable(obj): | |
78 |
raise error. |
|
79 | raise error.HookLoadError( | |
79 |
|
|
80 | _('%s hook is invalid ("%s" is not callable)') | |
80 |
|
|
81 | % (hname, funcname)) | |
81 |
|
82 | |||
82 | ui.note(_("calling hook %s: %s\n") % (hname, funcname)) |
|
83 | ui.note(_("calling hook %s: %s\n") % (hname, funcname)) | |
83 | starttime = time.time() |
|
84 | starttime = time.time() |
@@ -628,7 +628,7 b' make sure --traceback works on hook impo' | |||||
628 | Traceback (most recent call last): |
|
628 | Traceback (most recent call last): | |
629 | ImportError: No module named hgext_importfail |
|
629 | ImportError: No module named hgext_importfail | |
630 | Traceback (most recent call last): |
|
630 | Traceback (most recent call last): | |
631 |
|
|
631 | HookLoadError: precommit.importfail hook is invalid (import of "importfail" failed) | |
632 | abort: precommit.importfail hook is invalid (import of "importfail" failed) |
|
632 | abort: precommit.importfail hook is invalid (import of "importfail" failed) | |
633 |
|
633 | |||
634 | Issue1827: Hooks Update & Commit not completely post operation |
|
634 | Issue1827: Hooks Update & Commit not completely post operation |
General Comments 0
You need to be logged in to leave comments.
Login now