PageRenderTime 55ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/mercurial/error.py

https://bitbucket.org/magao/mercurial-hgweb-issue3626
Python | 90 lines | 48 code | 22 blank | 20 comment | 2 complexity | 58b2017cea7bc76923b702e56a1ca2e5 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 CommandError(Exception):
  24. """Exception raised on errors in parsing the command line."""
  25. class Abort(Exception):
  26. """Raised if a command needs to print an error and exit."""
  27. def __init__(self, *args, **kw):
  28. Exception.__init__(self, *args)
  29. self.hint = kw.get('hint')
  30. class ConfigError(Abort):
  31. 'Exception raised when parsing config files'
  32. class OutOfBandError(Exception):
  33. 'Exception raised when a remote repo reports failure'
  34. class ParseError(Exception):
  35. 'Exception raised when parsing config files (msg[, pos])'
  36. class RepoError(Exception):
  37. def __init__(self, *args, **kw):
  38. Exception.__init__(self, *args)
  39. self.hint = kw.get('hint')
  40. class RepoLookupError(RepoError):
  41. pass
  42. class CapabilityError(RepoError):
  43. pass
  44. class RequirementError(RepoError):
  45. """Exception raised if .hg/requires has an unknown entry."""
  46. pass
  47. class LockError(IOError):
  48. def __init__(self, errno, strerror, filename, desc):
  49. IOError.__init__(self, errno, strerror, filename)
  50. self.desc = desc
  51. class LockHeld(LockError):
  52. def __init__(self, errno, filename, desc, locker):
  53. LockError.__init__(self, errno, 'Lock held', filename, desc)
  54. self.locker = locker
  55. class LockUnavailable(LockError):
  56. pass
  57. class ResponseError(Exception):
  58. """Raised to print an error with part of output and exit."""
  59. class UnknownCommand(Exception):
  60. """Exception raised if command is not in the command table."""
  61. class AmbiguousCommand(Exception):
  62. """Exception raised if command shortcut matches more than one command."""
  63. # derived from KeyboardInterrupt to simplify some breakout code
  64. class SignalInterrupt(KeyboardInterrupt):
  65. """Exception raised on SIGTERM and SIGHUP."""
  66. class SignatureError(Exception):
  67. pass