##// END OF EJS Templates
error: derive RevlogError from HintException instead of Exception...
Jordi Gutiérrez Hermoso -
r25249:4311e78a default
parent child Browse files
Show More
@@ -1,171 +1,171 b''
1 1 # error.py - Mercurial exceptions
2 2 #
3 3 # Copyright 2005-2008 Matt Mackall <mpm@selenic.com>
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 """Mercurial exceptions.
9 9
10 10 This allows us to catch exceptions at higher levels without forcing
11 11 imports.
12 12 """
13 13
14 14 # Do not import anything here, please
15 15
16 16 class HintException(Exception):
17 17 def __init__(self, *args, **kw):
18 18 Exception.__init__(self, *args)
19 19 self.hint = kw.get('hint')
20 20
21 class RevlogError(Exception):
21 class RevlogError(HintException):
22 22 pass
23 23
24 24 class FilteredIndexError(IndexError):
25 25 pass
26 26
27 27 class LookupError(RevlogError, KeyError):
28 28 def __init__(self, name, index, message):
29 29 self.name = name
30 30 self.index = index
31 31 # this can't be called 'message' because at least some installs of
32 32 # Python 2.6+ complain about the 'message' property being deprecated
33 33 self.lookupmessage = message
34 34 if isinstance(name, str) and len(name) == 20:
35 35 from node import short
36 36 name = short(name)
37 37 RevlogError.__init__(self, '%s@%s: %s' % (index, name, message))
38 38
39 39 def __str__(self):
40 40 return RevlogError.__str__(self)
41 41
42 42 class FilteredLookupError(LookupError):
43 43 pass
44 44
45 45 class ManifestLookupError(LookupError):
46 46 pass
47 47
48 48 class CommandError(Exception):
49 49 """Exception raised on errors in parsing the command line."""
50 50
51 51 class InterventionRequired(Exception):
52 52 """Exception raised when a command requires human intervention."""
53 53
54 54 class Abort(HintException):
55 55 """Raised if a command needs to print an error and exit."""
56 56 pass
57 57
58 58 class HookAbort(Abort):
59 59 """raised when a validation hook fails, aborting an operation
60 60
61 61 Exists to allow more specialized catching."""
62 62 pass
63 63
64 64 class ConfigError(Abort):
65 65 """Exception raised when parsing config files"""
66 66
67 67 class OutOfBandError(Exception):
68 68 """Exception raised when a remote repo reports failure"""
69 69
70 70 def __init__(self, *args, **kw):
71 71 Exception.__init__(self, *args)
72 72 self.hint = kw.get('hint')
73 73
74 74 class ParseError(Exception):
75 75 """Raised when parsing config files and {rev,file}sets (msg[, pos])"""
76 76
77 77 class UnknownIdentifier(ParseError):
78 78 """Exception raised when a {rev,file}set references an unknown identifier"""
79 79
80 80 def __init__(self, function, symbols):
81 81 from i18n import _
82 82 ParseError.__init__(self, _("unknown identifier: %s") % function)
83 83 self.function = function
84 84 self.symbols = symbols
85 85
86 86 class RepoError(HintException):
87 87 pass
88 88
89 89 class RepoLookupError(RepoError):
90 90 pass
91 91
92 92 class FilteredRepoLookupError(RepoLookupError):
93 93 pass
94 94
95 95 class CapabilityError(RepoError):
96 96 pass
97 97
98 98 class RequirementError(RepoError):
99 99 """Exception raised if .hg/requires has an unknown entry."""
100 100 pass
101 101
102 102 class LockError(IOError):
103 103 def __init__(self, errno, strerror, filename, desc):
104 104 IOError.__init__(self, errno, strerror, filename)
105 105 self.desc = desc
106 106
107 107 class LockHeld(LockError):
108 108 def __init__(self, errno, filename, desc, locker):
109 109 LockError.__init__(self, errno, 'Lock held', filename, desc)
110 110 self.locker = locker
111 111
112 112 class LockUnavailable(LockError):
113 113 pass
114 114
115 115 class ResponseError(Exception):
116 116 """Raised to print an error with part of output and exit."""
117 117
118 118 class UnknownCommand(Exception):
119 119 """Exception raised if command is not in the command table."""
120 120
121 121 class AmbiguousCommand(Exception):
122 122 """Exception raised if command shortcut matches more than one command."""
123 123
124 124 # derived from KeyboardInterrupt to simplify some breakout code
125 125 class SignalInterrupt(KeyboardInterrupt):
126 126 """Exception raised on SIGTERM and SIGHUP."""
127 127
128 128 class SignatureError(Exception):
129 129 pass
130 130
131 131 class PushRaced(RuntimeError):
132 132 """An exception raised during unbundling that indicate a push race"""
133 133
134 134 # bundle2 related errors
135 135 class BundleValueError(ValueError):
136 136 """error raised when bundle2 cannot be processed"""
137 137
138 138 class UnsupportedPartError(BundleValueError):
139 139 def __init__(self, parttype=None, params=()):
140 140 self.parttype = parttype
141 141 self.params = params
142 142 if self.parttype is None:
143 143 msg = 'Stream Parameter'
144 144 else:
145 145 msg = parttype
146 146 if self.params:
147 147 msg = '%s - %s' % (msg, ', '.join(self.params))
148 148 ValueError.__init__(self, msg)
149 149
150 150 class ReadOnlyPartError(RuntimeError):
151 151 """error raised when code tries to alter a part being generated"""
152 152 pass
153 153
154 154 class CensoredNodeError(RevlogError):
155 155 """error raised when content verification fails on a censored node
156 156
157 157 Also contains the tombstone data substituted for the uncensored data.
158 158 """
159 159
160 160 def __init__(self, filename, node, tombstone):
161 161 from node import short
162 162 RevlogError.__init__(self, '%s:%s' % (filename, short(node)))
163 163 self.tombstone = tombstone
164 164
165 165 class CensoredBaseError(RevlogError):
166 166 """error raised when a delta is rejected because its base is censored
167 167
168 168 A delta based on a censored revision must be formed as single patch
169 169 operation which replaces the entire base with new content. This ensures
170 170 the delta may be applied by clones which have not censored the base.
171 171 """
General Comments 0
You need to be logged in to leave comments. Login now