PageRenderTime 50ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/mercurial/error.py

https://bitbucket.org/mirror/mercurial/
Python | 119 lines | 65 code | 29 blank | 25 comment | 5 complexity | dece83d35b8693267a7e637d17c08b8a MD5 | raw file
Possible License(s): GPL-2.0
  1. # error.py - Mercurial exceptions
  2. #
  3. # Copyright 2005-2008 Matt Mackall <mpm@selenic.com>
  4. #
  5. # This software may be used and distributed according to the terms of the
  6. # GNU General Public License version 2 or any later version.
  7. """Mercurial exceptions.
  8. This allows us to catch exceptions at higher levels without forcing
  9. imports.
  10. """
  11. # Do not import anything here, please
  12. class RevlogError(Exception):
  13. pass
  14. class LookupError(RevlogError, KeyError):
  15. def __init__(self, name, index, message):
  16. self.name = name
  17. if isinstance(name, str) and len(name) == 20:
  18. from node import short
  19. name = short(name)
  20. RevlogError.__init__(self, '%s@%s: %s' % (index, name, message))
  21. def __str__(self):
  22. return RevlogError.__str__(self)
  23. class ManifestLookupError(LookupError):
  24. pass
  25. class CommandError(Exception):
  26. """Exception raised on errors in parsing the command line."""
  27. class InterventionRequired(Exception):
  28. """Exception raised when a command requires human intervention."""
  29. class Abort(Exception):
  30. """Raised if a command needs to print an error and exit."""
  31. def __init__(self, *args, **kw):
  32. Exception.__init__(self, *args)
  33. self.hint = kw.get('hint')
  34. class ConfigError(Abort):
  35. 'Exception raised when parsing config files'
  36. class OutOfBandError(Exception):
  37. 'Exception raised when a remote repo reports failure'
  38. class ParseError(Exception):
  39. 'Exception raised when parsing config files (msg[, pos])'
  40. class RepoError(Exception):
  41. def __init__(self, *args, **kw):
  42. Exception.__init__(self, *args)
  43. self.hint = kw.get('hint')
  44. class RepoLookupError(RepoError):
  45. pass
  46. class CapabilityError(RepoError):
  47. pass
  48. class RequirementError(RepoError):
  49. """Exception raised if .hg/requires has an unknown entry."""
  50. pass
  51. class LockError(IOError):
  52. def __init__(self, errno, strerror, filename, desc):
  53. IOError.__init__(self, errno, strerror, filename)
  54. self.desc = desc
  55. class LockHeld(LockError):
  56. def __init__(self, errno, filename, desc, locker):
  57. LockError.__init__(self, errno, 'Lock held', filename, desc)
  58. self.locker = locker
  59. class LockUnavailable(LockError):
  60. pass
  61. class ResponseError(Exception):
  62. """Raised to print an error with part of output and exit."""
  63. class UnknownCommand(Exception):
  64. """Exception raised if command is not in the command table."""
  65. class AmbiguousCommand(Exception):
  66. """Exception raised if command shortcut matches more than one command."""
  67. # derived from KeyboardInterrupt to simplify some breakout code
  68. class SignalInterrupt(KeyboardInterrupt):
  69. """Exception raised on SIGTERM and SIGHUP."""
  70. class SignatureError(Exception):
  71. pass
  72. class PushRaced(RuntimeError):
  73. """An exception raised during unbundling that indicate a push race"""
  74. # bundle2 related errors
  75. class BundleValueError(ValueError):
  76. """error raised when bundle2 cannot be processed"""
  77. def __init__(self, parttype=None, params=()):
  78. self.parttype = parttype
  79. self.params = params
  80. if self.parttype is None:
  81. msg = 'Stream Parameter'
  82. else:
  83. msg = parttype
  84. if self.params:
  85. msg = '%s - %s' % (msg, ', '.join(self.params))
  86. ValueError.__init__(self, msg)
  87. class ReadOnlyPartError(RuntimeError):
  88. """error raised when code tries to alter a part being generated"""
  89. pass