##// END OF EJS Templates
error: add InMemoryMergeConflictsError...
Phil Cohen -
r35104:795bfa2a default
parent child Browse files
Show More
@@ -1,303 +1,307 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 from __future__ import absolute_import
15 15
16 16 # Do not import anything but pycompat here, please
17 17 from . import pycompat
18 18
19 19 def _tobytes(exc):
20 20 """Byte-stringify exception in the same way as BaseException_str()"""
21 21 if not exc.args:
22 22 return b''
23 23 if len(exc.args) == 1:
24 24 return pycompat.bytestr(exc.args[0])
25 25 return b'(%s)' % b', '.join(b"'%s'" % pycompat.bytestr(a) for a in exc.args)
26 26
27 27 class Hint(object):
28 28 """Mix-in to provide a hint of an error
29 29
30 30 This should come first in the inheritance list to consume a hint and
31 31 pass remaining arguments to the exception class.
32 32 """
33 33 def __init__(self, *args, **kw):
34 34 self.hint = kw.pop(r'hint', None)
35 35 super(Hint, self).__init__(*args, **kw)
36 36
37 37 class RevlogError(Hint, Exception):
38 38 __bytes__ = _tobytes
39 39
40 40 class FilteredIndexError(IndexError):
41 41 __bytes__ = _tobytes
42 42
43 43 class LookupError(RevlogError, KeyError):
44 44 def __init__(self, name, index, message):
45 45 self.name = name
46 46 self.index = index
47 47 # this can't be called 'message' because at least some installs of
48 48 # Python 2.6+ complain about the 'message' property being deprecated
49 49 self.lookupmessage = message
50 50 if isinstance(name, str) and len(name) == 20:
51 51 from .node import short
52 52 name = short(name)
53 53 RevlogError.__init__(self, '%s@%s: %s' % (index, name, message))
54 54
55 55 def __bytes__(self):
56 56 return RevlogError.__bytes__(self)
57 57
58 58 def __str__(self):
59 59 return RevlogError.__str__(self)
60 60
61 61 class FilteredLookupError(LookupError):
62 62 pass
63 63
64 64 class ManifestLookupError(LookupError):
65 65 pass
66 66
67 67 class CommandError(Exception):
68 68 """Exception raised on errors in parsing the command line."""
69 69 __bytes__ = _tobytes
70 70
71 71 class InterventionRequired(Hint, Exception):
72 72 """Exception raised when a command requires human intervention."""
73 73 __bytes__ = _tobytes
74 74
75 75 class Abort(Hint, Exception):
76 76 """Raised if a command needs to print an error and exit."""
77 77 __bytes__ = _tobytes
78 78
79 79 class HookLoadError(Abort):
80 80 """raised when loading a hook fails, aborting an operation
81 81
82 82 Exists to allow more specialized catching."""
83 83
84 84 class HookAbort(Abort):
85 85 """raised when a validation hook fails, aborting an operation
86 86
87 87 Exists to allow more specialized catching."""
88 88
89 89 class ConfigError(Abort):
90 90 """Exception raised when parsing config files"""
91 91
92 92 class UpdateAbort(Abort):
93 93 """Raised when an update is aborted for destination issue"""
94 94
95 95 class MergeDestAbort(Abort):
96 96 """Raised when an update is aborted for destination issues"""
97 97
98 98 class NoMergeDestAbort(MergeDestAbort):
99 99 """Raised when an update is aborted because there is nothing to merge"""
100 100
101 101 class ManyMergeDestAbort(MergeDestAbort):
102 102 """Raised when an update is aborted because destination is ambiguous"""
103 103
104 104 class ResponseExpected(Abort):
105 105 """Raised when an EOF is received for a prompt"""
106 106 def __init__(self):
107 107 from .i18n import _
108 108 Abort.__init__(self, _('response expected'))
109 109
110 110 class OutOfBandError(Hint, Exception):
111 111 """Exception raised when a remote repo reports failure"""
112 112 __bytes__ = _tobytes
113 113
114 114 class ParseError(Hint, Exception):
115 115 """Raised when parsing config files and {rev,file}sets (msg[, pos])"""
116 116 __bytes__ = _tobytes
117 117
118 118 class PatchError(Exception):
119 119 __bytes__ = _tobytes
120 120
121 121 class UnknownIdentifier(ParseError):
122 122 """Exception raised when a {rev,file}set references an unknown identifier"""
123 123
124 124 def __init__(self, function, symbols):
125 125 from .i18n import _
126 126 ParseError.__init__(self, _("unknown identifier: %s") % function)
127 127 self.function = function
128 128 self.symbols = symbols
129 129
130 130 class RepoError(Hint, Exception):
131 131 __bytes__ = _tobytes
132 132
133 133 class RepoLookupError(RepoError):
134 134 pass
135 135
136 136 class FilteredRepoLookupError(RepoLookupError):
137 137 pass
138 138
139 139 class CapabilityError(RepoError):
140 140 pass
141 141
142 142 class RequirementError(RepoError):
143 143 """Exception raised if .hg/requires has an unknown entry."""
144 144
145 145 class StdioError(IOError):
146 146 """Raised if I/O to stdout or stderr fails"""
147 147
148 148 def __init__(self, err):
149 149 IOError.__init__(self, err.errno, err.strerror)
150 150
151 151 # no __bytes__() because error message is derived from the standard IOError
152 152
153 153 class UnsupportedMergeRecords(Abort):
154 154 def __init__(self, recordtypes):
155 155 from .i18n import _
156 156 self.recordtypes = sorted(recordtypes)
157 157 s = ' '.join(self.recordtypes)
158 158 Abort.__init__(
159 159 self, _('unsupported merge state records: %s') % s,
160 160 hint=_('see https://mercurial-scm.org/wiki/MergeStateRecords for '
161 161 'more information'))
162 162
163 163 class UnknownVersion(Abort):
164 164 """generic exception for aborting from an encounter with an unknown version
165 165 """
166 166
167 167 def __init__(self, msg, hint=None, version=None):
168 168 self.version = version
169 169 super(UnknownVersion, self).__init__(msg, hint=hint)
170 170
171 171 class LockError(IOError):
172 172 def __init__(self, errno, strerror, filename, desc):
173 173 IOError.__init__(self, errno, strerror, filename)
174 174 self.desc = desc
175 175
176 176 # no __bytes__() because error message is derived from the standard IOError
177 177
178 178 class LockHeld(LockError):
179 179 def __init__(self, errno, filename, desc, locker):
180 180 LockError.__init__(self, errno, 'Lock held', filename, desc)
181 181 self.locker = locker
182 182
183 183 class LockUnavailable(LockError):
184 184 pass
185 185
186 186 # LockError is for errors while acquiring the lock -- this is unrelated
187 187 class LockInheritanceContractViolation(RuntimeError):
188 188 __bytes__ = _tobytes
189 189
190 190 class ResponseError(Exception):
191 191 """Raised to print an error with part of output and exit."""
192 192 __bytes__ = _tobytes
193 193
194 194 class UnknownCommand(Exception):
195 195 """Exception raised if command is not in the command table."""
196 196 __bytes__ = _tobytes
197 197
198 198 class AmbiguousCommand(Exception):
199 199 """Exception raised if command shortcut matches more than one command."""
200 200 __bytes__ = _tobytes
201 201
202 202 # derived from KeyboardInterrupt to simplify some breakout code
203 203 class SignalInterrupt(KeyboardInterrupt):
204 204 """Exception raised on SIGTERM and SIGHUP."""
205 205
206 206 class SignatureError(Exception):
207 207 __bytes__ = _tobytes
208 208
209 209 class PushRaced(RuntimeError):
210 210 """An exception raised during unbundling that indicate a push race"""
211 211 __bytes__ = _tobytes
212 212
213 213 class ProgrammingError(Hint, RuntimeError):
214 214 """Raised if a mercurial (core or extension) developer made a mistake"""
215 215 __bytes__ = _tobytes
216 216
217 217 class WdirUnsupported(Exception):
218 218 """An exception which is raised when 'wdir()' is not supported"""
219 219 __bytes__ = _tobytes
220 220
221 221 # bundle2 related errors
222 222 class BundleValueError(ValueError):
223 223 """error raised when bundle2 cannot be processed"""
224 224 __bytes__ = _tobytes
225 225
226 226 class BundleUnknownFeatureError(BundleValueError):
227 227 def __init__(self, parttype=None, params=(), values=()):
228 228 self.parttype = parttype
229 229 self.params = params
230 230 self.values = values
231 231 if self.parttype is None:
232 232 msg = 'Stream Parameter'
233 233 else:
234 234 msg = parttype
235 235 entries = self.params
236 236 if self.params and self.values:
237 237 assert len(self.params) == len(self.values)
238 238 entries = []
239 239 for idx, par in enumerate(self.params):
240 240 val = self.values[idx]
241 241 if val is None:
242 242 entries.append(val)
243 243 else:
244 244 entries.append("%s=%r" % (par, val))
245 245 if entries:
246 246 msg = '%s - %s' % (msg, ', '.join(entries))
247 247 ValueError.__init__(self, msg)
248 248
249 249 class ReadOnlyPartError(RuntimeError):
250 250 """error raised when code tries to alter a part being generated"""
251 251 __bytes__ = _tobytes
252 252
253 253 class PushkeyFailed(Abort):
254 254 """error raised when a pushkey part failed to update a value"""
255 255
256 256 def __init__(self, partid, namespace=None, key=None, new=None, old=None,
257 257 ret=None):
258 258 self.partid = partid
259 259 self.namespace = namespace
260 260 self.key = key
261 261 self.new = new
262 262 self.old = old
263 263 self.ret = ret
264 264 # no i18n expected to be processed into a better message
265 265 Abort.__init__(self, 'failed to update value for "%s/%s"'
266 266 % (namespace, key))
267 267
268 268 class CensoredNodeError(RevlogError):
269 269 """error raised when content verification fails on a censored node
270 270
271 271 Also contains the tombstone data substituted for the uncensored data.
272 272 """
273 273
274 274 def __init__(self, filename, node, tombstone):
275 275 from .node import short
276 276 RevlogError.__init__(self, '%s:%s' % (filename, short(node)))
277 277 self.tombstone = tombstone
278 278
279 279 class CensoredBaseError(RevlogError):
280 280 """error raised when a delta is rejected because its base is censored
281 281
282 282 A delta based on a censored revision must be formed as single patch
283 283 operation which replaces the entire base with new content. This ensures
284 284 the delta may be applied by clones which have not censored the base.
285 285 """
286 286
287 287 class InvalidBundleSpecification(Exception):
288 288 """error raised when a bundle specification is invalid.
289 289
290 290 This is used for syntax errors as opposed to support errors.
291 291 """
292 292 __bytes__ = _tobytes
293 293
294 294 class UnsupportedBundleSpecification(Exception):
295 295 """error raised when a bundle specification is not supported."""
296 296 __bytes__ = _tobytes
297 297
298 298 class CorruptedState(Exception):
299 299 """error raised when a command is not able to read its state from file"""
300 300 __bytes__ = _tobytes
301 301
302 302 class PeerTransportError(Abort):
303 303 """Transport-level I/O error when communicating with a peer repo."""
304
305 class InMemoryMergeConflictsError(Exception):
306 """Exception raised when merge conflicts arose during an in-memory merge."""
307 __bytes__ = _tobytes
General Comments 0
You need to be logged in to leave comments. Login now