# HG changeset patch # User Matt Mackall # Date 2009-01-12 17:48:05 # Node ID 182b7114d35a4ca96f15d9ed2e503c51572da5a3 # Parent 9a1ea6587557e9972f29d428df730aff000a937a error: move SignalInterrupt now derived from KeyboardInterrupt to simplify catches diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -26,7 +26,7 @@ def dispatch(args): def _runcatch(ui, args): def catchterm(*args): - raise util.SignalInterrupt + raise error.SignalInterrupt for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM': num = getattr(signal, name, None) @@ -74,7 +74,7 @@ def _runcatch(ui, args): (inst.desc or inst.filename, inst.strerror)) except error.RevlogError, inst: ui.warn(_("abort: %s!\n") % inst) - except util.SignalInterrupt: + except error.SignalInterrupt: ui.warn(_("killed!\n")) except KeyboardInterrupt: try: diff --git a/mercurial/error.py b/mercurial/error.py --- a/mercurial/error.py +++ b/mercurial/error.py @@ -56,3 +56,6 @@ class UnknownCommand(Exception): class AmbiguousCommand(Exception): """Exception raised if command shortcut matches more than one command.""" +# derived from KeyboardInterrupt to simplify some breakout code +class SignalInterrupt(KeyboardInterrupt): + """Exception raised on SIGTERM and SIGHUP.""" diff --git a/mercurial/extensions.py b/mercurial/extensions.py --- a/mercurial/extensions.py +++ b/mercurial/extensions.py @@ -75,7 +75,7 @@ def loadall(ui): path = os.path.expanduser(path) try: load(ui, name, path) - except (util.SignalInterrupt, KeyboardInterrupt): + except KeyboardInterrupt: raise except Exception, inst: if path: diff --git a/mercurial/hook.py b/mercurial/hook.py --- a/mercurial/hook.py +++ b/mercurial/hook.py @@ -49,7 +49,7 @@ def _pythonhook(ui, repo, name, hname, f (hname, funcname)) try: r = obj(ui=ui, repo=repo, hooktype=name, **args) - except (KeyboardInterrupt, util.SignalInterrupt): + except KeyboardInterrupt: raise except Exception, exc: if isinstance(exc, util.Abort): diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -412,7 +412,7 @@ class localrepository(repo.repository): if not l: continue node, label = l.split(" ", 1) partial[label.strip()] = bin(node) - except (KeyboardInterrupt, util.SignalInterrupt): + except KeyboardInterrupt: raise except Exception, inst: if self.ui.debugflag: diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -185,9 +185,6 @@ extendeddateformats = defaultdateformats "%b %Y", ) -class SignalInterrupt(Exception): - """Exception raised on SIGTERM and SIGHUP.""" - # differences from SafeConfigParser: # - case-sensitive keys # - allows values that are not strings (this means that you may not