2009-04-26 03:13:08 +04:00
|
|
|
# error.py - Mercurial exceptions
|
|
|
|
#
|
|
|
|
# Copyright 2005-2008 Matt Mackall <mpm@selenic.com>
|
|
|
|
#
|
|
|
|
# This software may be used and distributed according to the terms of the
|
2010-01-20 07:20:08 +03:00
|
|
|
# GNU General Public License version 2 or any later version.
|
2009-01-12 07:48:28 +03:00
|
|
|
|
2009-04-26 03:24:49 +04:00
|
|
|
"""Mercurial exceptions.
|
|
|
|
|
|
|
|
This allows us to catch exceptions at higher levels without forcing
|
|
|
|
imports.
|
|
|
|
"""
|
|
|
|
|
2009-01-12 07:48:28 +03:00
|
|
|
# Do not import anything here, please
|
|
|
|
|
|
|
|
class RevlogError(Exception):
|
|
|
|
pass
|
|
|
|
|
2014-10-16 04:02:44 +04:00
|
|
|
class FilteredIndexError(IndexError):
|
|
|
|
pass
|
|
|
|
|
2009-01-12 07:48:28 +03:00
|
|
|
class LookupError(RevlogError, KeyError):
|
|
|
|
def __init__(self, name, index, message):
|
|
|
|
self.name = name
|
|
|
|
if isinstance(name, str) and len(name) == 20:
|
|
|
|
from node import short
|
|
|
|
name = short(name)
|
|
|
|
RevlogError.__init__(self, '%s@%s: %s' % (index, name, message))
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return RevlogError.__str__(self)
|
2009-01-12 08:04:24 +03:00
|
|
|
|
2014-10-16 13:05:06 +04:00
|
|
|
class FilteredLookupError(LookupError):
|
|
|
|
pass
|
|
|
|
|
2013-02-15 13:07:14 +04:00
|
|
|
class ManifestLookupError(LookupError):
|
|
|
|
pass
|
|
|
|
|
2010-06-05 05:19:53 +04:00
|
|
|
class CommandError(Exception):
|
2009-01-12 08:04:24 +03:00
|
|
|
"""Exception raised on errors in parsing the command line."""
|
2009-01-12 19:42:31 +03:00
|
|
|
|
2013-02-09 00:26:03 +04:00
|
|
|
class InterventionRequired(Exception):
|
|
|
|
"""Exception raised when a command requires human intervention."""
|
|
|
|
|
2010-06-05 05:57:26 +04:00
|
|
|
class Abort(Exception):
|
|
|
|
"""Raised if a command needs to print an error and exit."""
|
2010-07-15 16:41:22 +04:00
|
|
|
def __init__(self, *args, **kw):
|
|
|
|
Exception.__init__(self, *args)
|
|
|
|
self.hint = kw.get('hint')
|
2010-06-05 05:57:26 +04:00
|
|
|
|
2014-11-30 06:13:35 +03:00
|
|
|
class HookAbort(Abort):
|
|
|
|
"""raised when a validation hook fails, aborting an operation
|
|
|
|
|
|
|
|
Exists to allow more specialized catching."""
|
|
|
|
pass
|
|
|
|
|
2010-06-05 05:57:26 +04:00
|
|
|
class ConfigError(Abort):
|
2014-08-30 14:22:20 +04:00
|
|
|
"""Exception raised when parsing config files"""
|
2009-04-24 00:40:10 +04:00
|
|
|
|
2011-08-02 23:21:10 +04:00
|
|
|
class OutOfBandError(Exception):
|
2014-08-30 14:22:20 +04:00
|
|
|
"""Exception raised when a remote repo reports failure"""
|
2011-08-02 23:21:10 +04:00
|
|
|
|
2010-06-05 08:04:31 +04:00
|
|
|
class ParseError(Exception):
|
2014-08-30 14:22:20 +04:00
|
|
|
"""Exception raised when parsing config files (msg[, pos])"""
|
2010-06-05 05:57:26 +04:00
|
|
|
|
2009-01-12 19:42:31 +03:00
|
|
|
class RepoError(Exception):
|
2011-06-25 04:30:17 +04:00
|
|
|
def __init__(self, *args, **kw):
|
|
|
|
Exception.__init__(self, *args)
|
|
|
|
self.hint = kw.get('hint')
|
2009-01-12 19:42:31 +03:00
|
|
|
|
2009-08-31 19:58:33 +04:00
|
|
|
class RepoLookupError(RepoError):
|
|
|
|
pass
|
|
|
|
|
2014-10-16 13:06:12 +04:00
|
|
|
class FilteredRepoLookupError(RepoLookupError):
|
|
|
|
pass
|
|
|
|
|
2009-01-12 19:42:31 +03:00
|
|
|
class CapabilityError(RepoError):
|
|
|
|
pass
|
2009-01-12 20:09:14 +03:00
|
|
|
|
2011-02-18 22:25:25 +03:00
|
|
|
class RequirementError(RepoError):
|
|
|
|
"""Exception raised if .hg/requires has an unknown entry."""
|
|
|
|
pass
|
|
|
|
|
2009-01-12 20:09:14 +03:00
|
|
|
class LockError(IOError):
|
|
|
|
def __init__(self, errno, strerror, filename, desc):
|
|
|
|
IOError.__init__(self, errno, strerror, filename)
|
|
|
|
self.desc = desc
|
|
|
|
|
|
|
|
class LockHeld(LockError):
|
|
|
|
def __init__(self, errno, filename, desc, locker):
|
|
|
|
LockError.__init__(self, errno, 'Lock held', filename, desc)
|
|
|
|
self.locker = locker
|
|
|
|
|
|
|
|
class LockUnavailable(LockError):
|
|
|
|
pass
|
2009-01-12 20:28:28 +03:00
|
|
|
|
|
|
|
class ResponseError(Exception):
|
|
|
|
"""Raised to print an error with part of output and exit."""
|
|
|
|
|
2009-01-12 20:39:38 +03:00
|
|
|
class UnknownCommand(Exception):
|
|
|
|
"""Exception raised if command is not in the command table."""
|
|
|
|
|
|
|
|
class AmbiguousCommand(Exception):
|
|
|
|
"""Exception raised if command shortcut matches more than one command."""
|
|
|
|
|
2009-01-12 20:48:05 +03:00
|
|
|
# derived from KeyboardInterrupt to simplify some breakout code
|
|
|
|
class SignalInterrupt(KeyboardInterrupt):
|
|
|
|
"""Exception raised on SIGTERM and SIGHUP."""
|
2009-01-12 22:51:43 +03:00
|
|
|
|
|
|
|
class SignatureError(Exception):
|
|
|
|
pass
|
2014-04-22 05:59:09 +04:00
|
|
|
|
|
|
|
class PushRaced(RuntimeError):
|
|
|
|
"""An exception raised during unbundling that indicate a push race"""
|
|
|
|
|
2014-05-29 02:31:05 +04:00
|
|
|
# bundle2 related errors
|
|
|
|
class BundleValueError(ValueError):
|
2014-05-29 02:53:34 +04:00
|
|
|
"""error raised when bundle2 cannot be processed"""
|
2014-05-29 02:31:05 +04:00
|
|
|
|
2014-10-15 14:22:47 +04:00
|
|
|
class UnsupportedPartError(BundleValueError):
|
2014-05-29 03:46:58 +04:00
|
|
|
def __init__(self, parttype=None, params=()):
|
2014-05-29 02:51:19 +04:00
|
|
|
self.parttype = parttype
|
2014-05-29 02:53:34 +04:00
|
|
|
self.params = params
|
2014-05-29 03:46:58 +04:00
|
|
|
if self.parttype is None:
|
|
|
|
msg = 'Stream Parameter'
|
|
|
|
else:
|
|
|
|
msg = parttype
|
2014-05-29 02:53:34 +04:00
|
|
|
if self.params:
|
|
|
|
msg = '%s - %s' % (msg, ', '.join(self.params))
|
2014-06-11 04:00:31 +04:00
|
|
|
ValueError.__init__(self, msg)
|
2014-05-29 02:31:05 +04:00
|
|
|
|
|
|
|
class ReadOnlyPartError(RuntimeError):
|
|
|
|
"""error raised when code tries to alter a part being generated"""
|
|
|
|
pass
|
|
|
|
|
2014-09-03 23:59:03 +04:00
|
|
|
class CensoredNodeError(RevlogError):
|
|
|
|
"""error raised when content verification fails on a censored node"""
|
|
|
|
|
|
|
|
def __init__(self, filename, node):
|
|
|
|
from node import short
|
|
|
|
RevlogError.__init__(self, '%s:%s' % (filename, short(node)))
|