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