Show More
@@ -20,7 +20,13 b' from . import pycompat' | |||
|
20 | 20 | |
|
21 | 21 | if pycompat.TYPE_CHECKING: |
|
22 | 22 | from typing import ( |
|
23 | Any, | |
|
24 | AnyStr, | |
|
25 | Iterable, | |
|
26 | List, | |
|
23 | 27 | Optional, |
|
28 | Sequence, | |
|
29 | Union, | |
|
24 | 30 | ) |
|
25 | 31 | |
|
26 | 32 | |
@@ -109,6 +115,7 b' class CommandError(Exception):' | |||
|
109 | 115 | """Exception raised on errors in parsing the command line.""" |
|
110 | 116 | |
|
111 | 117 | def __init__(self, command, message): |
|
118 | # type: (bytes, bytes) -> None | |
|
112 | 119 | self.command = command |
|
113 | 120 | self.message = message |
|
114 | 121 | super(CommandError, self).__init__() |
@@ -120,6 +127,7 b' class UnknownCommand(Exception):' | |||
|
120 | 127 | """Exception raised if command is not in the command table.""" |
|
121 | 128 | |
|
122 | 129 | def __init__(self, command, all_commands=None): |
|
130 | # type: (bytes, Optional[List[bytes]]) -> None | |
|
123 | 131 | self.command = command |
|
124 | 132 | self.all_commands = all_commands |
|
125 | 133 | super(UnknownCommand, self).__init__() |
@@ -131,6 +139,7 b' class AmbiguousCommand(Exception):' | |||
|
131 | 139 | """Exception raised if command shortcut matches more than one command.""" |
|
132 | 140 | |
|
133 | 141 | def __init__(self, prefix, matches): |
|
142 | # type: (bytes, List[bytes]) -> None | |
|
134 | 143 | self.prefix = prefix |
|
135 | 144 | self.matches = matches |
|
136 | 145 | super(AmbiguousCommand, self).__init__() |
@@ -142,6 +151,7 b' class WorkerError(Exception):' | |||
|
142 | 151 | """Exception raised when a worker process dies.""" |
|
143 | 152 | |
|
144 | 153 | def __init__(self, status_code): |
|
154 | # type: (int) -> None | |
|
145 | 155 | self.status_code = status_code |
|
146 | 156 | # Pass status code to superclass just so it becomes part of __bytes__ |
|
147 | 157 | super(WorkerError, self).__init__(status_code) |
@@ -159,6 +169,7 b' class ConflictResolutionRequired(Interve' | |||
|
159 | 169 | """Exception raised when a continuable command required merge conflict resolution.""" |
|
160 | 170 | |
|
161 | 171 | def __init__(self, opname): |
|
172 | # type: (bytes) -> None | |
|
162 | 173 | from .i18n import _ |
|
163 | 174 | |
|
164 | 175 | self.opname = opname |
@@ -194,6 +205,7 b' class Abort(Hint, Exception):' | |||
|
194 | 205 | return pycompat.sysstr(self.__bytes__()) |
|
195 | 206 | |
|
196 | 207 | def format(self): |
|
208 | # type: () -> bytes | |
|
197 | 209 | from .i18n import _ |
|
198 | 210 | |
|
199 | 211 | message = _(b"abort: %s\n") % self.message |
@@ -247,10 +259,12 b' class ConfigError(Abort):' | |||
|
247 | 259 | """Exception raised when parsing config files""" |
|
248 | 260 | |
|
249 | 261 | def __init__(self, message, location=None, hint=None): |
|
262 | # type: (bytes, Optional[bytes], Optional[bytes]) -> None | |
|
250 | 263 | super(ConfigError, self).__init__(message, hint=hint) |
|
251 | 264 | self.location = location |
|
252 | 265 | |
|
253 | 266 | def format(self): |
|
267 | # type: () -> bytes | |
|
254 | 268 | from .i18n import _ |
|
255 | 269 | |
|
256 | 270 | if self.location is not None: |
@@ -300,10 +314,12 b' class ParseError(Abort):' | |||
|
300 | 314 | """Raised when parsing config files and {rev,file}sets (msg[, pos])""" |
|
301 | 315 | |
|
302 | 316 | def __init__(self, message, location=None, hint=None): |
|
317 | # type: (bytes, Optional[Union[bytes, int]], Optional[bytes]) -> None | |
|
303 | 318 | super(ParseError, self).__init__(message, hint=hint) |
|
304 | 319 | self.location = location |
|
305 | 320 | |
|
306 | 321 | def format(self): |
|
322 | # type: () -> bytes | |
|
307 | 323 | from .i18n import _ |
|
308 | 324 | |
|
309 | 325 | if self.location is not None: |
@@ -323,6 +339,7 b' class PatchError(Exception):' | |||
|
323 | 339 | |
|
324 | 340 | |
|
325 | 341 | def getsimilar(symbols, value): |
|
342 | # type: (Iterable[bytes], bytes) -> List[bytes] | |
|
326 | 343 | sim = lambda x: difflib.SequenceMatcher(None, value, x).ratio() |
|
327 | 344 | # The cutoff for similarity here is pretty arbitrary. It should |
|
328 | 345 | # probably be investigated and tweaked. |
@@ -330,6 +347,7 b' def getsimilar(symbols, value):' | |||
|
330 | 347 | |
|
331 | 348 | |
|
332 | 349 | def similarity_hint(similar): |
|
350 | # type: (List[bytes]) -> Optional[bytes] | |
|
333 | 351 | from .i18n import _ |
|
334 | 352 | |
|
335 | 353 | if len(similar) == 1: |
@@ -345,6 +363,7 b' class UnknownIdentifier(ParseError):' | |||
|
345 | 363 | """Exception raised when a {rev,file}set references an unknown identifier""" |
|
346 | 364 | |
|
347 | 365 | def __init__(self, function, symbols): |
|
366 | # type: (bytes, Iterable[bytes]) -> None | |
|
348 | 367 | from .i18n import _ |
|
349 | 368 | |
|
350 | 369 | similar = getsimilar(symbols, function) |
@@ -379,6 +398,7 b' class StdioError(IOError):' | |||
|
379 | 398 | """Raised if I/O to stdout or stderr fails""" |
|
380 | 399 | |
|
381 | 400 | def __init__(self, err): |
|
401 | # type: (IOError) -> None | |
|
382 | 402 | IOError.__init__(self, err.errno, err.strerror) |
|
383 | 403 | |
|
384 | 404 | # no __bytes__() because error message is derived from the standard IOError |
@@ -386,6 +406,7 b' class StdioError(IOError):' | |||
|
386 | 406 | |
|
387 | 407 | class UnsupportedMergeRecords(Abort): |
|
388 | 408 | def __init__(self, recordtypes): |
|
409 | # type: (Iterable[bytes]) -> None | |
|
389 | 410 | from .i18n import _ |
|
390 | 411 | |
|
391 | 412 | self.recordtypes = sorted(recordtypes) |
@@ -404,12 +425,15 b' class UnknownVersion(Abort):' | |||
|
404 | 425 | """generic exception for aborting from an encounter with an unknown version""" |
|
405 | 426 | |
|
406 | 427 | def __init__(self, msg, hint=None, version=None): |
|
428 | # type: (bytes, Optional[bytes], Optional[bytes]) -> None | |
|
407 | 429 | self.version = version |
|
408 | 430 | super(UnknownVersion, self).__init__(msg, hint=hint) |
|
409 | 431 | |
|
410 | 432 | |
|
411 | 433 | class LockError(IOError): |
|
412 | 434 | def __init__(self, errno, strerror, filename, desc): |
|
435 | # TODO: figure out if this should be bytes or str | |
|
436 | # _type: (int, str, str, bytes) -> None | |
|
413 | 437 | IOError.__init__(self, errno, strerror, filename) |
|
414 | 438 | self.desc = desc |
|
415 | 439 | |
@@ -456,6 +480,7 b' class ProgrammingError(Hint, RuntimeErro' | |||
|
456 | 480 | """Raised if a mercurial (core or extension) developer made a mistake""" |
|
457 | 481 | |
|
458 | 482 | def __init__(self, msg, *args, **kwargs): |
|
483 | # type: (AnyStr, Any, Any) -> None | |
|
459 | 484 | # On Python 3, turn the message back into a string since this is |
|
460 | 485 | # an internal-only error that won't be printed except in a |
|
461 | 486 | # stack traces. |
@@ -499,7 +524,7 b' class BundleUnknownFeatureError(BundleVa' | |||
|
499 | 524 | entries.append(b"%s=%r" % (par, pycompat.maybebytestr(val))) |
|
500 | 525 | if entries: |
|
501 | 526 | msg = b'%s - %s' % (msg, b', '.join(entries)) |
|
502 | ValueError.__init__(self, msg) | |
|
527 | ValueError.__init__(self, msg) # TODO: convert to str? | |
|
503 | 528 | |
|
504 | 529 | |
|
505 | 530 | class ReadOnlyPartError(RuntimeError): |
@@ -533,6 +558,7 b' class CensoredNodeError(StorageError):' | |||
|
533 | 558 | """ |
|
534 | 559 | |
|
535 | 560 | def __init__(self, filename, node, tombstone): |
|
561 | # type: (bytes, bytes, bytes) -> None | |
|
536 | 562 | from .node import short |
|
537 | 563 | |
|
538 | 564 | StorageError.__init__(self, b'%s:%s' % (filename, short(node))) |
@@ -588,5 +614,6 b' class WireprotoCommandError(Exception):' | |||
|
588 | 614 | """ |
|
589 | 615 | |
|
590 | 616 | def __init__(self, message, args=None): |
|
617 | # type: (bytes, Optional[Sequence[bytes]]) -> None | |
|
591 | 618 | self.message = message |
|
592 | 619 | self.messageargs = args |
General Comments 0
You need to be logged in to leave comments.
Login now