@@ -46,10 +46,16 @@ class Abort(Exception):
"""Raised if a command needs to print an error and exit."""
def __init__(self, *args, **kw):
Exception.__init__(self, *args)
self.hint = kw.get('hint')
+class HookAbort(Abort):
+ """raised when a validation hook fails aborting an operation
+
+ Exists to allow more specialized catching."""
+ pass
+
class ConfigError(Abort):
"""Exception raised when parsing config files"""
class OutOfBandError(Exception):
"""Exception raised when a remote repo reports failure"""
@@ -5,11 +5,11 @@
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from i18n import _
import os, sys, time
-import extensions, util, demandimport
+import extensions, util, demandimport, error
def _pythonhook(ui, repo, name, hname, funcname, args, throw):
'''call python hook. hook is callable object, looked up as
name in python module. if callable returns "true", hook
fails, else passes. if hook raises exception, treated as
@@ -105,11 +105,11 @@ def _pythonhook(ui, repo, name, hname, f
duration = time.time() - starttime
ui.log('pythonhook', 'pythonhook-%s: %s finished in %0.2f seconds\n',
name, funcname, duration)
if r:
if throw:
- raise util.Abort(_('%s hook failed') % hname)
+ raise error.HookAbort(_('%s hook failed') % hname)
ui.warn(_('warning: %s hook failed\n') % hname)
return r
def _exthook(ui, repo, name, cmd, args, throw):
ui.note(_("running hook %s: %s\n") % (name, cmd))
@@ -140,11 +140,11 @@ def _exthook(ui, repo, name, cmd, args,
ui.log('exthook', 'exthook-%s: %s finished in %0.2f seconds\n',
name, cmd, duration)
if r:
desc, r = util.explainexit(r)
if throw:
- raise util.Abort(_('%s hook %s') % (name, desc))
+ raise error.HookAbort(_('%s hook %s') % (name, desc))
ui.warn(_('warning: %s hook %s\n') % (name, desc))
return r
def _allhooks(ui):
hooks = []