Mercurial > hg
annotate mercurial/error.py @ 52095:3e7b9357bbb8
tests: add coverage to for `HGCB_BUNDLE_BASENAME` with special characters
Per request on IRC, to show the behavior of dropping the quoting of
`HGCB_BUNDLE_BASENAME` in the next commit. This current failure is basically
the same error and output that currently happens on Windows with any path (even
without the embedded quote). The only difference is Windows doesn't print the
`cp: cannot stat ...` line.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 21 Oct 2024 15:24:55 -0400 |
parents | f4733654f144 |
children |
rev | line source |
---|---|
8226
8b2cd04a6e97
put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
1 # error.py - Mercurial exceptions |
8b2cd04a6e97
put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
2 # |
46819
d4ba4d51f85f
contributor: change mentions of mpm to olivia
Raphaël Gomès <rgomes@octobus.net>
parents:
46794
diff
changeset
|
3 # Copyright 2005-2008 Olivia Mackall <olivia@selenic.com> |
8226
8b2cd04a6e97
put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
4 # |
8b2cd04a6e97
put license and copyright info into comment blocks
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
10263 | 6 # GNU General Public License version 2 or any later version. |
7633 | 7 |
8227
0a9542703300
turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents:
8226
diff
changeset
|
8 """Mercurial exceptions. |
0a9542703300
turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents:
8226
diff
changeset
|
9 |
0a9542703300
turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents:
8226
diff
changeset
|
10 This allows us to catch exceptions at higher levels without forcing |
0a9542703300
turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents:
8226
diff
changeset
|
11 imports. |
0a9542703300
turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents:
8226
diff
changeset
|
12 """ |
0a9542703300
turn some comments back into module docstrings
Martin Geisler <mg@lazybytes.net>
parents:
8226
diff
changeset
|
13 |
51863
f4733654f144
typing: add `from __future__ import annotations` to most files
Matt Harbison <matt_harbison@yahoo.com>
parents:
51290
diff
changeset
|
14 from __future__ import annotations |
25945
147bd9e238a1
error: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25484
diff
changeset
|
15 |
45882
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
16 import difflib |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
17 |
51285
9d3721552b6c
pytype: import typing directly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50660
diff
changeset
|
18 from typing import ( |
9d3721552b6c
pytype: import typing directly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50660
diff
changeset
|
19 AnyStr, |
9d3721552b6c
pytype: import typing directly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50660
diff
changeset
|
20 Iterable, |
9d3721552b6c
pytype: import typing directly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50660
diff
changeset
|
21 List, |
9d3721552b6c
pytype: import typing directly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50660
diff
changeset
|
22 Optional, |
9d3721552b6c
pytype: import typing directly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50660
diff
changeset
|
23 Sequence, |
9d3721552b6c
pytype: import typing directly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50660
diff
changeset
|
24 Union, |
9d3721552b6c
pytype: import typing directly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50660
diff
changeset
|
25 ) |
9d3721552b6c
pytype: import typing directly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50660
diff
changeset
|
26 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
27 # Do not import anything but pycompat here, please |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
28 from . import pycompat |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
29 |
51285
9d3721552b6c
pytype: import typing directly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50660
diff
changeset
|
30 |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
31 def _tobytes(exc) -> bytes: |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
32 """Byte-stringify exception in the same way as BaseException_str()""" |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
33 if not exc.args: |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
34 return b'' |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
35 if len(exc.args) == 1: |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
36 return pycompat.bytestr(exc.args[0]) |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
37 return b'(%s)' % b', '.join(b"'%s'" % pycompat.bytestr(a) for a in exc.args) |
7633 | 38 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
39 |
48946
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48889
diff
changeset
|
40 class Hint: |
29509
945b4c14c570
error: make HintException a mix-in class not derived from BaseException (API)
Yuya Nishihara <yuya@tcha.org>
parents:
28141
diff
changeset
|
41 """Mix-in to provide a hint of an error |
945b4c14c570
error: make HintException a mix-in class not derived from BaseException (API)
Yuya Nishihara <yuya@tcha.org>
parents:
28141
diff
changeset
|
42 |
29510
19205a0e2bf1
error: make hintable exceptions reject unknown keyword arguments (API)
Yuya Nishihara <yuya@tcha.org>
parents:
29509
diff
changeset
|
43 This should come first in the inheritance list to consume a hint and |
19205a0e2bf1
error: make hintable exceptions reject unknown keyword arguments (API)
Yuya Nishihara <yuya@tcha.org>
parents:
29509
diff
changeset
|
44 pass remaining arguments to the exception class. |
29509
945b4c14c570
error: make HintException a mix-in class not derived from BaseException (API)
Yuya Nishihara <yuya@tcha.org>
parents:
28141
diff
changeset
|
45 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
46 |
25248
821e664924dc
error: refactor common hint-pattern into a common base class
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
25242
diff
changeset
|
47 def __init__(self, *args, **kw): |
51288
8b2ea2246a5f
pytype: convert type comment for inline variable too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51287
diff
changeset
|
48 self.hint: Optional[bytes] = kw.pop('hint', None) |
29510
19205a0e2bf1
error: make hintable exceptions reject unknown keyword arguments (API)
Yuya Nishihara <yuya@tcha.org>
parents:
29509
diff
changeset
|
49 super(Hint, self).__init__(*args, **kw) |
25248
821e664924dc
error: refactor common hint-pattern into a common base class
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
25242
diff
changeset
|
50 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
51 |
47292
5a75be916316
errors: create superclass for Abort exception
Martin von Zweigbergk <martinvonz@google.com>
parents:
47291
diff
changeset
|
52 class Error(Hint, Exception): |
5a75be916316
errors: create superclass for Abort exception
Martin von Zweigbergk <martinvonz@google.com>
parents:
47291
diff
changeset
|
53 """Base class for Mercurial errors.""" |
47290
5e736d2e9703
errors: move Abort earlier, so more exceptions can subclass it
Martin von Zweigbergk <martinvonz@google.com>
parents:
47289
diff
changeset
|
54 |
47304
73f52278a158
errors: make exit codes class variables instead
Martin von Zweigbergk <martinvonz@google.com>
parents:
47295
diff
changeset
|
55 coarse_exit_code = None |
73f52278a158
errors: make exit codes class variables instead
Martin von Zweigbergk <martinvonz@google.com>
parents:
47295
diff
changeset
|
56 detailed_exit_code = None |
73f52278a158
errors: make exit codes class variables instead
Martin von Zweigbergk <martinvonz@google.com>
parents:
47295
diff
changeset
|
57 |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
58 def __init__(self, message: bytes, hint: Optional[bytes] = None) -> None: |
47290
5e736d2e9703
errors: move Abort earlier, so more exceptions can subclass it
Martin von Zweigbergk <martinvonz@google.com>
parents:
47289
diff
changeset
|
59 self.message = message |
5e736d2e9703
errors: move Abort earlier, so more exceptions can subclass it
Martin von Zweigbergk <martinvonz@google.com>
parents:
47289
diff
changeset
|
60 self.hint = hint |
5e736d2e9703
errors: move Abort earlier, so more exceptions can subclass it
Martin von Zweigbergk <martinvonz@google.com>
parents:
47289
diff
changeset
|
61 # Pass the message into the Exception constructor to help extensions |
5e736d2e9703
errors: move Abort earlier, so more exceptions can subclass it
Martin von Zweigbergk <martinvonz@google.com>
parents:
47289
diff
changeset
|
62 # that look for exc.args[0]. |
5e736d2e9703
errors: move Abort earlier, so more exceptions can subclass it
Martin von Zweigbergk <martinvonz@google.com>
parents:
47289
diff
changeset
|
63 Exception.__init__(self, message) |
5e736d2e9703
errors: move Abort earlier, so more exceptions can subclass it
Martin von Zweigbergk <martinvonz@google.com>
parents:
47289
diff
changeset
|
64 |
5e736d2e9703
errors: move Abort earlier, so more exceptions can subclass it
Martin von Zweigbergk <martinvonz@google.com>
parents:
47289
diff
changeset
|
65 def __bytes__(self): |
5e736d2e9703
errors: move Abort earlier, so more exceptions can subclass it
Martin von Zweigbergk <martinvonz@google.com>
parents:
47289
diff
changeset
|
66 return self.message |
5e736d2e9703
errors: move Abort earlier, so more exceptions can subclass it
Martin von Zweigbergk <martinvonz@google.com>
parents:
47289
diff
changeset
|
67 |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
68 def __str__(self) -> str: |
48889
9baec00b4ca1
error: unconditionally define __str__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
69 # the output would be unreadable if the message was translated, |
9baec00b4ca1
error: unconditionally define __str__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
70 # but do not replace it with encoding.strfromlocal(), which |
9baec00b4ca1
error: unconditionally define __str__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
71 # may raise another exception. |
9baec00b4ca1
error: unconditionally define __str__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
72 return pycompat.sysstr(self.__bytes__()) |
47290
5e736d2e9703
errors: move Abort earlier, so more exceptions can subclass it
Martin von Zweigbergk <martinvonz@google.com>
parents:
47289
diff
changeset
|
73 |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
74 def format(self) -> bytes: |
47290
5e736d2e9703
errors: move Abort earlier, so more exceptions can subclass it
Martin von Zweigbergk <martinvonz@google.com>
parents:
47289
diff
changeset
|
75 from .i18n import _ |
5e736d2e9703
errors: move Abort earlier, so more exceptions can subclass it
Martin von Zweigbergk <martinvonz@google.com>
parents:
47289
diff
changeset
|
76 |
5e736d2e9703
errors: move Abort earlier, so more exceptions can subclass it
Martin von Zweigbergk <martinvonz@google.com>
parents:
47289
diff
changeset
|
77 message = _(b"abort: %s\n") % self.message |
5e736d2e9703
errors: move Abort earlier, so more exceptions can subclass it
Martin von Zweigbergk <martinvonz@google.com>
parents:
47289
diff
changeset
|
78 if self.hint: |
5e736d2e9703
errors: move Abort earlier, so more exceptions can subclass it
Martin von Zweigbergk <martinvonz@google.com>
parents:
47289
diff
changeset
|
79 message += _(b"(%s)\n") % self.hint |
5e736d2e9703
errors: move Abort earlier, so more exceptions can subclass it
Martin von Zweigbergk <martinvonz@google.com>
parents:
47289
diff
changeset
|
80 return message |
5e736d2e9703
errors: move Abort earlier, so more exceptions can subclass it
Martin von Zweigbergk <martinvonz@google.com>
parents:
47289
diff
changeset
|
81 |
5e736d2e9703
errors: move Abort earlier, so more exceptions can subclass it
Martin von Zweigbergk <martinvonz@google.com>
parents:
47289
diff
changeset
|
82 |
47292
5a75be916316
errors: create superclass for Abort exception
Martin von Zweigbergk <martinvonz@google.com>
parents:
47291
diff
changeset
|
83 class Abort(Error): |
5a75be916316
errors: create superclass for Abort exception
Martin von Zweigbergk <martinvonz@google.com>
parents:
47291
diff
changeset
|
84 """Raised if a command needs to print an error and exit.""" |
5a75be916316
errors: create superclass for Abort exception
Martin von Zweigbergk <martinvonz@google.com>
parents:
47291
diff
changeset
|
85 |
5a75be916316
errors: create superclass for Abort exception
Martin von Zweigbergk <martinvonz@google.com>
parents:
47291
diff
changeset
|
86 |
47295
dd339191f2dc
errors: make StorageError subclass Error, attaching an exit code to it
Martin von Zweigbergk <martinvonz@google.com>
parents:
47292
diff
changeset
|
87 class StorageError(Error): |
39776
cb65d4b7e429
error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39596
diff
changeset
|
88 """Raised when an error occurs in a storage layer. |
cb65d4b7e429
error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39596
diff
changeset
|
89 |
cb65d4b7e429
error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39596
diff
changeset
|
90 Usually subclassed by a storage-specific exception. |
cb65d4b7e429
error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39596
diff
changeset
|
91 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
92 |
47304
73f52278a158
errors: make exit codes class variables instead
Martin von Zweigbergk <martinvonz@google.com>
parents:
47295
diff
changeset
|
93 detailed_exit_code = 50 |
39776
cb65d4b7e429
error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39596
diff
changeset
|
94 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
95 |
39776
cb65d4b7e429
error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39596
diff
changeset
|
96 class RevlogError(StorageError): |
45775
5bb900885311
errors: remove unnecessary override of __bytes__ in RevlogError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45682
diff
changeset
|
97 pass |
7633 | 98 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
99 |
43034
294afb982a88
sidedata: add a function to read sidedata from revlog raw text
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40972
diff
changeset
|
100 class SidedataHashError(RevlogError): |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
101 def __init__(self, key: int, expected: bytes, got: bytes) -> None: |
46625
3941fe53670d
error: add `hint` attribute to `SidedataHashError`
Raphaël Gomès <rgomes@octobus.net>
parents:
45942
diff
changeset
|
102 self.hint = None |
43034
294afb982a88
sidedata: add a function to read sidedata from revlog raw text
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40972
diff
changeset
|
103 self.sidedatakey = key |
294afb982a88
sidedata: add a function to read sidedata from revlog raw text
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40972
diff
changeset
|
104 self.expecteddigest = expected |
294afb982a88
sidedata: add a function to read sidedata from revlog raw text
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40972
diff
changeset
|
105 self.actualdigest = got |
294afb982a88
sidedata: add a function to read sidedata from revlog raw text
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40972
diff
changeset
|
106 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
107 |
23014
f00813325c5a
repoview: add a FilteredIndexError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23010
diff
changeset
|
108 class FilteredIndexError(IndexError): |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
109 __bytes__ = _tobytes |
23014
f00813325c5a
repoview: add a FilteredIndexError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23010
diff
changeset
|
110 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
111 |
7633 | 112 class LookupError(RevlogError, KeyError): |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
113 def __init__(self, name: bytes, index: bytes, message: bytes) -> None: |
7633 | 114 self.name = name |
24038
10d02cd18604
error: store filename and message on LookupError for later
Martin von Zweigbergk <martinvonz@google.com>
parents:
23415
diff
changeset
|
115 self.index = index |
24137
dcfdfd63bde4
error.LookupError: rename 'message' property to something else
Siddharth Agarwal <sid0@fb.com>
parents:
24120
diff
changeset
|
116 # this can't be called 'message' because at least some installs of |
dcfdfd63bde4
error.LookupError: rename 'message' property to something else
Siddharth Agarwal <sid0@fb.com>
parents:
24120
diff
changeset
|
117 # Python 2.6+ complain about the 'message' property being deprecated |
dcfdfd63bde4
error.LookupError: rename 'message' property to something else
Siddharth Agarwal <sid0@fb.com>
parents:
24120
diff
changeset
|
118 self.lookupmessage = message |
36541
c6a7b99f150a
error: fix isinstnace check to use bytes instead of str
Augie Fackler <augie@google.com>
parents:
35105
diff
changeset
|
119 if isinstance(name, bytes) and len(name) == 20: |
46651
6fc57680cfd6
error: remove shortening of node in error message
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46625
diff
changeset
|
120 from .node import hex |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
121 |
46651
6fc57680cfd6
error: remove shortening of node in error message
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46625
diff
changeset
|
122 name = hex(name) |
45503
bd5b2b29b82d
py3: fix formatting of LookupError for workingctx
Yuya Nishihara <yuya@tcha.org>
parents:
45151
diff
changeset
|
123 # if name is a binary node, it can be None |
bd5b2b29b82d
py3: fix formatting of LookupError for workingctx
Yuya Nishihara <yuya@tcha.org>
parents:
45151
diff
changeset
|
124 RevlogError.__init__( |
bd5b2b29b82d
py3: fix formatting of LookupError for workingctx
Yuya Nishihara <yuya@tcha.org>
parents:
45151
diff
changeset
|
125 self, b'%s@%s: %s' % (index, pycompat.bytestr(name), message) |
bd5b2b29b82d
py3: fix formatting of LookupError for workingctx
Yuya Nishihara <yuya@tcha.org>
parents:
45151
diff
changeset
|
126 ) |
7633 | 127 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
128 def __bytes__(self): |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
129 return RevlogError.__bytes__(self) |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
130 |
7633 | 131 def __str__(self): |
132 return RevlogError.__str__(self) | |
7636 | 133 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
134 |
38841
df0873ab5c14
revlog: use specialized exception for ambiguous prefix lookup
Martin von Zweigbergk <martinvonz@google.com>
parents:
38607
diff
changeset
|
135 class AmbiguousPrefixLookupError(LookupError): |
df0873ab5c14
revlog: use specialized exception for ambiguous prefix lookup
Martin von Zweigbergk <martinvonz@google.com>
parents:
38607
diff
changeset
|
136 pass |
df0873ab5c14
revlog: use specialized exception for ambiguous prefix lookup
Martin von Zweigbergk <martinvonz@google.com>
parents:
38607
diff
changeset
|
137 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
138 |
23015
21c44c1aed87
repoview: add a FilteredLookupError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23014
diff
changeset
|
139 class FilteredLookupError(LookupError): |
21c44c1aed87
repoview: add a FilteredLookupError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23014
diff
changeset
|
140 pass |
21c44c1aed87
repoview: add a FilteredLookupError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23014
diff
changeset
|
141 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
142 |
18855
50c922c1b514
hgweb: show correct error message for i18n environment
Takumi IINO <trot.thunder@gmail.com>
parents:
15017
diff
changeset
|
143 class ManifestLookupError(LookupError): |
50c922c1b514
hgweb: show correct error message for i18n environment
Takumi IINO <trot.thunder@gmail.com>
parents:
15017
diff
changeset
|
144 pass |
50c922c1b514
hgweb: show correct error message for i18n environment
Takumi IINO <trot.thunder@gmail.com>
parents:
15017
diff
changeset
|
145 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
146 |
11287
b901bb751999
error: change ParseError to CommandError
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
147 class CommandError(Exception): |
7636 | 148 """Exception raised on errors in parsing the command line.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
149 |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
150 def __init__(self, command: Optional[bytes], message: bytes) -> None: |
45678
bd2df58366b1
errors: name arguments to CommandError constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45677
diff
changeset
|
151 self.command = command |
bd2df58366b1
errors: name arguments to CommandError constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45677
diff
changeset
|
152 self.message = message |
bd2df58366b1
errors: name arguments to CommandError constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45677
diff
changeset
|
153 super(CommandError, self).__init__() |
bd2df58366b1
errors: name arguments to CommandError constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45677
diff
changeset
|
154 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
155 __bytes__ = _tobytes |
7637 | 156 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
157 |
45677
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45503
diff
changeset
|
158 class UnknownCommand(Exception): |
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45503
diff
changeset
|
159 """Exception raised if command is not in the command table.""" |
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45503
diff
changeset
|
160 |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
161 def __init__( |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
162 self, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
163 command: bytes, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
164 all_commands: Optional[List[bytes]] = None, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
165 ) -> None: |
45680
bb1a988ef4a5
errors: name arguments to UnknownCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45679
diff
changeset
|
166 self.command = command |
bb1a988ef4a5
errors: name arguments to UnknownCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45679
diff
changeset
|
167 self.all_commands = all_commands |
bb1a988ef4a5
errors: name arguments to UnknownCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45679
diff
changeset
|
168 super(UnknownCommand, self).__init__() |
bb1a988ef4a5
errors: name arguments to UnknownCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45679
diff
changeset
|
169 |
45677
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45503
diff
changeset
|
170 __bytes__ = _tobytes |
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45503
diff
changeset
|
171 |
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45503
diff
changeset
|
172 |
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45503
diff
changeset
|
173 class AmbiguousCommand(Exception): |
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45503
diff
changeset
|
174 """Exception raised if command shortcut matches more than one command.""" |
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45503
diff
changeset
|
175 |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
176 def __init__(self, prefix: bytes, matches: List[bytes]) -> None: |
45679
65e2b64670b5
errors: name arguments to AmbiguousCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45678
diff
changeset
|
177 self.prefix = prefix |
65e2b64670b5
errors: name arguments to AmbiguousCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45678
diff
changeset
|
178 self.matches = matches |
65e2b64670b5
errors: name arguments to AmbiguousCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45678
diff
changeset
|
179 super(AmbiguousCommand, self).__init__() |
65e2b64670b5
errors: name arguments to AmbiguousCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45678
diff
changeset
|
180 |
45677
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45503
diff
changeset
|
181 __bytes__ = _tobytes |
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45503
diff
changeset
|
182 |
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45503
diff
changeset
|
183 |
45825
8f07f5a9c3de
worker: raise exception instead of calling sys.exit() with child's code
Martin von Zweigbergk <martinvonz@google.com>
parents:
45776
diff
changeset
|
184 class WorkerError(Exception): |
8f07f5a9c3de
worker: raise exception instead of calling sys.exit() with child's code
Martin von Zweigbergk <martinvonz@google.com>
parents:
45776
diff
changeset
|
185 """Exception raised when a worker process dies.""" |
8f07f5a9c3de
worker: raise exception instead of calling sys.exit() with child's code
Martin von Zweigbergk <martinvonz@google.com>
parents:
45776
diff
changeset
|
186 |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
187 def __init__(self, status_code: int) -> None: |
45825
8f07f5a9c3de
worker: raise exception instead of calling sys.exit() with child's code
Martin von Zweigbergk <martinvonz@google.com>
parents:
45776
diff
changeset
|
188 self.status_code = status_code |
45903
64faa55716f4
tests: make test-worker.t pass on py2
Martin von Zweigbergk <martinvonz@google.com>
parents:
45894
diff
changeset
|
189 # Pass status code to superclass just so it becomes part of __bytes__ |
64faa55716f4
tests: make test-worker.t pass on py2
Martin von Zweigbergk <martinvonz@google.com>
parents:
45894
diff
changeset
|
190 super(WorkerError, self).__init__(status_code) |
64faa55716f4
tests: make test-worker.t pass on py2
Martin von Zweigbergk <martinvonz@google.com>
parents:
45894
diff
changeset
|
191 |
64faa55716f4
tests: make test-worker.t pass on py2
Martin von Zweigbergk <martinvonz@google.com>
parents:
45894
diff
changeset
|
192 __bytes__ = _tobytes |
45825
8f07f5a9c3de
worker: raise exception instead of calling sys.exit() with child's code
Martin von Zweigbergk <martinvonz@google.com>
parents:
45776
diff
changeset
|
193 |
8f07f5a9c3de
worker: raise exception instead of calling sys.exit() with child's code
Martin von Zweigbergk <martinvonz@google.com>
parents:
45776
diff
changeset
|
194 |
47291
d9c71bbe20f7
errors: make InterventionRequired subclass Abort
Martin von Zweigbergk <martinvonz@google.com>
parents:
47290
diff
changeset
|
195 class InterventionRequired(Abort): |
18931
3c224e0949de
error: introduce new InterventionRequired exception
Augie Fackler <raf@durin42.com>
parents:
18855
diff
changeset
|
196 """Exception raised when a command requires human intervention.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
197 |
47304
73f52278a158
errors: make exit codes class variables instead
Martin von Zweigbergk <martinvonz@google.com>
parents:
47295
diff
changeset
|
198 coarse_exit_code = 1 |
73f52278a158
errors: make exit codes class variables instead
Martin von Zweigbergk <martinvonz@google.com>
parents:
47295
diff
changeset
|
199 detailed_exit_code = 240 |
47291
d9c71bbe20f7
errors: make InterventionRequired subclass Abort
Martin von Zweigbergk <martinvonz@google.com>
parents:
47290
diff
changeset
|
200 |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
201 def format(self) -> bytes: |
47291
d9c71bbe20f7
errors: make InterventionRequired subclass Abort
Martin von Zweigbergk <martinvonz@google.com>
parents:
47290
diff
changeset
|
202 from .i18n import _ |
d9c71bbe20f7
errors: make InterventionRequired subclass Abort
Martin von Zweigbergk <martinvonz@google.com>
parents:
47290
diff
changeset
|
203 |
d9c71bbe20f7
errors: make InterventionRequired subclass Abort
Martin von Zweigbergk <martinvonz@google.com>
parents:
47290
diff
changeset
|
204 message = _(b"%s\n") % self.message |
d9c71bbe20f7
errors: make InterventionRequired subclass Abort
Martin von Zweigbergk <martinvonz@google.com>
parents:
47290
diff
changeset
|
205 if self.hint: |
d9c71bbe20f7
errors: make InterventionRequired subclass Abort
Martin von Zweigbergk <martinvonz@google.com>
parents:
47290
diff
changeset
|
206 message += _(b"(%s)\n") % self.hint |
d9c71bbe20f7
errors: make InterventionRequired subclass Abort
Martin von Zweigbergk <martinvonz@google.com>
parents:
47290
diff
changeset
|
207 return message |
18931
3c224e0949de
error: introduce new InterventionRequired exception
Augie Fackler <raf@durin42.com>
parents:
18855
diff
changeset
|
208 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
209 |
45151
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
210 class ConflictResolutionRequired(InterventionRequired): |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
211 """Exception raised when a continuable command required merge conflict resolution.""" |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
212 |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
213 def __init__(self, opname: bytes) -> None: |
45151
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
214 from .i18n import _ |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
215 |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
216 self.opname = opname |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
217 InterventionRequired.__init__( |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
218 self, |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
219 _( |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
220 b"unresolved conflicts (see 'hg resolve', then 'hg %s --continue')" |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
221 ) |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
222 % opname, |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
223 ) |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
224 |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43506
diff
changeset
|
225 |
45827
8d72e29ad1e0
errors: introduce InputError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45825
diff
changeset
|
226 class InputError(Abort): |
8d72e29ad1e0
errors: introduce InputError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45825
diff
changeset
|
227 """Indicates that the user made an error in their input. |
8d72e29ad1e0
errors: introduce InputError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45825
diff
changeset
|
228 |
8d72e29ad1e0
errors: introduce InputError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45825
diff
changeset
|
229 Examples: Invalid command, invalid flags, invalid revision. |
8d72e29ad1e0
errors: introduce InputError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45825
diff
changeset
|
230 """ |
8d72e29ad1e0
errors: introduce InputError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45825
diff
changeset
|
231 |
47304
73f52278a158
errors: make exit codes class variables instead
Martin von Zweigbergk <martinvonz@google.com>
parents:
47295
diff
changeset
|
232 detailed_exit_code = 10 |
47289
33c0c25d0b0f
errors: let each Abort subclass define its error code
Martin von Zweigbergk <martinvonz@google.com>
parents:
46981
diff
changeset
|
233 |
45827
8d72e29ad1e0
errors: introduce InputError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45825
diff
changeset
|
234 |
45840
527ce85c2e60
errors: introduce StateError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45827
diff
changeset
|
235 class StateError(Abort): |
527ce85c2e60
errors: introduce StateError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45827
diff
changeset
|
236 """Indicates that the operation might work if retried in a different state. |
527ce85c2e60
errors: introduce StateError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45827
diff
changeset
|
237 |
527ce85c2e60
errors: introduce StateError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45827
diff
changeset
|
238 Examples: Unresolved merge conflicts, unfinished operations. |
527ce85c2e60
errors: introduce StateError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45827
diff
changeset
|
239 """ |
527ce85c2e60
errors: introduce StateError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45827
diff
changeset
|
240 |
47304
73f52278a158
errors: make exit codes class variables instead
Martin von Zweigbergk <martinvonz@google.com>
parents:
47295
diff
changeset
|
241 detailed_exit_code = 20 |
47289
33c0c25d0b0f
errors: let each Abort subclass define its error code
Martin von Zweigbergk <martinvonz@google.com>
parents:
46981
diff
changeset
|
242 |
45840
527ce85c2e60
errors: introduce StateError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45827
diff
changeset
|
243 |
45877
ac362d5a7893
errors: introduce CanceledError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45840
diff
changeset
|
244 class CanceledError(Abort): |
ac362d5a7893
errors: introduce CanceledError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45840
diff
changeset
|
245 """Indicates that the user canceled the operation. |
ac362d5a7893
errors: introduce CanceledError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45840
diff
changeset
|
246 |
ac362d5a7893
errors: introduce CanceledError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45840
diff
changeset
|
247 Examples: Close commit editor with error status, quit chistedit. |
ac362d5a7893
errors: introduce CanceledError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45840
diff
changeset
|
248 """ |
ac362d5a7893
errors: introduce CanceledError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45840
diff
changeset
|
249 |
47304
73f52278a158
errors: make exit codes class variables instead
Martin von Zweigbergk <martinvonz@google.com>
parents:
47295
diff
changeset
|
250 detailed_exit_code = 250 |
47289
33c0c25d0b0f
errors: let each Abort subclass define its error code
Martin von Zweigbergk <martinvonz@google.com>
parents:
46981
diff
changeset
|
251 |
45877
ac362d5a7893
errors: introduce CanceledError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45840
diff
changeset
|
252 |
45915
8f50dc096cf4
errors: introduce SecurityError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45903
diff
changeset
|
253 class SecurityError(Abort): |
8f50dc096cf4
errors: introduce SecurityError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45903
diff
changeset
|
254 """Indicates that some aspect of security failed. |
8f50dc096cf4
errors: introduce SecurityError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45903
diff
changeset
|
255 |
8f50dc096cf4
errors: introduce SecurityError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45903
diff
changeset
|
256 Examples: Bad server credentials, expired local credentials for network |
8f50dc096cf4
errors: introduce SecurityError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45903
diff
changeset
|
257 filesystem, mismatched GPG signature, DoS protection. |
8f50dc096cf4
errors: introduce SecurityError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45903
diff
changeset
|
258 """ |
8f50dc096cf4
errors: introduce SecurityError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45903
diff
changeset
|
259 |
47304
73f52278a158
errors: make exit codes class variables instead
Martin von Zweigbergk <martinvonz@google.com>
parents:
47295
diff
changeset
|
260 detailed_exit_code = 150 |
47289
33c0c25d0b0f
errors: let each Abort subclass define its error code
Martin von Zweigbergk <martinvonz@google.com>
parents:
46981
diff
changeset
|
261 |
45915
8f50dc096cf4
errors: introduce SecurityError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45903
diff
changeset
|
262 |
26692
8d1cfd77b64f
hook: raise a separate exception for when loading a hook fails
Siddharth Agarwal <sid0@fb.com>
parents:
26683
diff
changeset
|
263 class HookLoadError(Abort): |
8d1cfd77b64f
hook: raise a separate exception for when loading a hook fails
Siddharth Agarwal <sid0@fb.com>
parents:
26683
diff
changeset
|
264 """raised when loading a hook fails, aborting an operation |
8d1cfd77b64f
hook: raise a separate exception for when loading a hook fails
Siddharth Agarwal <sid0@fb.com>
parents:
26683
diff
changeset
|
265 |
8d1cfd77b64f
hook: raise a separate exception for when loading a hook fails
Siddharth Agarwal <sid0@fb.com>
parents:
26683
diff
changeset
|
266 Exists to allow more specialized catching.""" |
8d1cfd77b64f
hook: raise a separate exception for when loading a hook fails
Siddharth Agarwal <sid0@fb.com>
parents:
26683
diff
changeset
|
267 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
268 |
23415
cdbb85489c41
hook: raise a more specialized HookAbort exception when a hook fails
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23016
diff
changeset
|
269 class HookAbort(Abort): |
cdbb85489c41
hook: raise a more specialized HookAbort exception when a hook fails
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23016
diff
changeset
|
270 """raised when a validation hook fails, aborting an operation |
cdbb85489c41
hook: raise a more specialized HookAbort exception when a hook fails
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23016
diff
changeset
|
271 |
cdbb85489c41
hook: raise a more specialized HookAbort exception when a hook fails
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23016
diff
changeset
|
272 Exists to allow more specialized catching.""" |
cdbb85489c41
hook: raise a more specialized HookAbort exception when a hook fails
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23016
diff
changeset
|
273 |
47304
73f52278a158
errors: make exit codes class variables instead
Martin von Zweigbergk <martinvonz@google.com>
parents:
47295
diff
changeset
|
274 detailed_exit_code = 40 |
47289
33c0c25d0b0f
errors: let each Abort subclass define its error code
Martin von Zweigbergk <martinvonz@google.com>
parents:
46981
diff
changeset
|
275 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
276 |
11288
2123aad24d56
error: add new ParseError for various parsing errors
Matt Mackall <mpm@selenic.com>
parents:
11287
diff
changeset
|
277 class ConfigError(Abort): |
22359
e3714b927af5
error: use docstrings, not bare strings, for error classes
Mike Edgar <adgar@google.com>
parents:
21747
diff
changeset
|
278 """Exception raised when parsing config files""" |
8144
fca54469480e
ui: introduce new config parser
Matt Mackall <mpm@selenic.com>
parents:
7947
diff
changeset
|
279 |
47304
73f52278a158
errors: make exit codes class variables instead
Martin von Zweigbergk <martinvonz@google.com>
parents:
47295
diff
changeset
|
280 detailed_exit_code = 30 |
73f52278a158
errors: make exit codes class variables instead
Martin von Zweigbergk <martinvonz@google.com>
parents:
47295
diff
changeset
|
281 |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
282 def __init__( |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
283 self, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
284 message: bytes, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
285 location: Optional[bytes] = None, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
286 hint: Optional[bytes] = None, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
287 ) -> None: |
47304
73f52278a158
errors: make exit codes class variables instead
Martin von Zweigbergk <martinvonz@google.com>
parents:
47295
diff
changeset
|
288 super(ConfigError, self).__init__(message, hint=hint) |
45894
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45891
diff
changeset
|
289 self.location = location |
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45891
diff
changeset
|
290 |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
291 def format(self) -> bytes: |
45894
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45891
diff
changeset
|
292 from .i18n import _ |
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45891
diff
changeset
|
293 |
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45891
diff
changeset
|
294 if self.location is not None: |
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45891
diff
changeset
|
295 message = _(b"config error at %s: %s\n") % ( |
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45891
diff
changeset
|
296 pycompat.bytestr(self.location), |
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45891
diff
changeset
|
297 self.message, |
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45891
diff
changeset
|
298 ) |
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45891
diff
changeset
|
299 else: |
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45891
diff
changeset
|
300 message = _(b"config error: %s\n") % self.message |
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45891
diff
changeset
|
301 if self.hint: |
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45891
diff
changeset
|
302 message += _(b"(%s)\n") % self.hint |
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45891
diff
changeset
|
303 return message |
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45891
diff
changeset
|
304 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
305 |
26683
634666c48b7d
update: introduce a 'UpdateAbort' exception
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26640
diff
changeset
|
306 class UpdateAbort(Abort): |
634666c48b7d
update: introduce a 'UpdateAbort' exception
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26640
diff
changeset
|
307 """Raised when an update is aborted for destination issue""" |
634666c48b7d
update: introduce a 'UpdateAbort' exception
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26640
diff
changeset
|
308 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
309 |
28141
13bb8de97f87
destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27628
diff
changeset
|
310 class MergeDestAbort(Abort): |
13bb8de97f87
destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27628
diff
changeset
|
311 """Raised when an update is aborted for destination issues""" |
13bb8de97f87
destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27628
diff
changeset
|
312 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
313 |
28141
13bb8de97f87
destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27628
diff
changeset
|
314 class NoMergeDestAbort(MergeDestAbort): |
13bb8de97f87
destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27628
diff
changeset
|
315 """Raised when an update is aborted because there is nothing to merge""" |
13bb8de97f87
destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27628
diff
changeset
|
316 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
317 |
28141
13bb8de97f87
destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27628
diff
changeset
|
318 class ManyMergeDestAbort(MergeDestAbort): |
30332
318a24b52eeb
spelling: fixes of non-dictionary words
Mads Kiilerich <madski@unity3d.com>
parents:
29536
diff
changeset
|
319 """Raised when an update is aborted because destination is ambiguous""" |
28141
13bb8de97f87
destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27628
diff
changeset
|
320 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
321 |
26896
5e46123e6c35
error: add structured exception for EOF at prompt
Siddharth Agarwal <sid0@fb.com>
parents:
26693
diff
changeset
|
322 class ResponseExpected(Abort): |
5e46123e6c35
error: add structured exception for EOF at prompt
Siddharth Agarwal <sid0@fb.com>
parents:
26693
diff
changeset
|
323 """Raised when an EOF is received for a prompt""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
324 |
26896
5e46123e6c35
error: add structured exception for EOF at prompt
Siddharth Agarwal <sid0@fb.com>
parents:
26693
diff
changeset
|
325 def __init__(self): |
5e46123e6c35
error: add structured exception for EOF at prompt
Siddharth Agarwal <sid0@fb.com>
parents:
26693
diff
changeset
|
326 from .i18n import _ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
327 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
328 Abort.__init__(self, _(b'response expected')) |
26896
5e46123e6c35
error: add structured exception for EOF at prompt
Siddharth Agarwal <sid0@fb.com>
parents:
26693
diff
changeset
|
329 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
330 |
46976
f9482db16cef
errors: introduce a class for remote errors
Martin von Zweigbergk <martinvonz@google.com>
parents:
46975
diff
changeset
|
331 class RemoteError(Abort): |
f9482db16cef
errors: introduce a class for remote errors
Martin von Zweigbergk <martinvonz@google.com>
parents:
46975
diff
changeset
|
332 """Exception raised when interacting with a remote repo fails""" |
f9482db16cef
errors: introduce a class for remote errors
Martin von Zweigbergk <martinvonz@google.com>
parents:
46975
diff
changeset
|
333 |
47304
73f52278a158
errors: make exit codes class variables instead
Martin von Zweigbergk <martinvonz@google.com>
parents:
47295
diff
changeset
|
334 detailed_exit_code = 100 |
47289
33c0c25d0b0f
errors: let each Abort subclass define its error code
Martin von Zweigbergk <martinvonz@google.com>
parents:
46981
diff
changeset
|
335 |
46976
f9482db16cef
errors: introduce a class for remote errors
Martin von Zweigbergk <martinvonz@google.com>
parents:
46975
diff
changeset
|
336 |
f9482db16cef
errors: introduce a class for remote errors
Martin von Zweigbergk <martinvonz@google.com>
parents:
46975
diff
changeset
|
337 class OutOfBandError(RemoteError): |
22359
e3714b927af5
error: use docstrings, not bare strings, for error classes
Mike Edgar <adgar@google.com>
parents:
21747
diff
changeset
|
338 """Exception raised when a remote repo reports failure""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
339 |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
340 def __init__( |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
341 self, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
342 message: Optional[bytes] = None, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
343 hint: Optional[bytes] = None, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
344 ): |
46975
14ddb1dca2c0
errors: make OutOfBandError extend Abort
Martin von Zweigbergk <martinvonz@google.com>
parents:
46899
diff
changeset
|
345 from .i18n import _ |
14ddb1dca2c0
errors: make OutOfBandError extend Abort
Martin von Zweigbergk <martinvonz@google.com>
parents:
46899
diff
changeset
|
346 |
46981
abd18d6306f1
errors: remove unnecessary varargs handling from OutOfBandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
46976
diff
changeset
|
347 if message: |
46975
14ddb1dca2c0
errors: make OutOfBandError extend Abort
Martin von Zweigbergk <martinvonz@google.com>
parents:
46899
diff
changeset
|
348 # Abort.format() adds a trailing newline |
46981
abd18d6306f1
errors: remove unnecessary varargs handling from OutOfBandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
46976
diff
changeset
|
349 message = _(b"remote error:\n%s") % message.rstrip(b'\n') |
46975
14ddb1dca2c0
errors: make OutOfBandError extend Abort
Martin von Zweigbergk <martinvonz@google.com>
parents:
46899
diff
changeset
|
350 else: |
14ddb1dca2c0
errors: make OutOfBandError extend Abort
Martin von Zweigbergk <martinvonz@google.com>
parents:
46899
diff
changeset
|
351 message = _(b"remote error") |
46981
abd18d6306f1
errors: remove unnecessary varargs handling from OutOfBandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
46976
diff
changeset
|
352 super(OutOfBandError, self).__init__(message, hint=hint) |
15017
f4522df38c65
wireproto: add out-of-band error class to allow remote repo to report errors
Andrew Pritchard <andrewp@fogcreek.com>
parents:
14761
diff
changeset
|
353 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
354 |
45887
7eb221b9af6c
errors: make ParseError a subtype of Abort
Martin von Zweigbergk <martinvonz@google.com>
parents:
45885
diff
changeset
|
355 class ParseError(Abort): |
24040
7f375d2de945
error: update docstring on ParseError
Augie Fackler <augie@google.com>
parents:
24038
diff
changeset
|
356 """Raised when parsing config files and {rev,file}sets (msg[, pos])""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
357 |
47304
73f52278a158
errors: make exit codes class variables instead
Martin von Zweigbergk <martinvonz@google.com>
parents:
47295
diff
changeset
|
358 detailed_exit_code = 10 |
73f52278a158
errors: make exit codes class variables instead
Martin von Zweigbergk <martinvonz@google.com>
parents:
47295
diff
changeset
|
359 |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
360 def __init__( |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
361 self, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
362 message: bytes, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
363 location: Optional[Union[bytes, int]] = None, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
364 hint: Optional[bytes] = None, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
365 ): |
47304
73f52278a158
errors: make exit codes class variables instead
Martin von Zweigbergk <martinvonz@google.com>
parents:
47295
diff
changeset
|
366 super(ParseError, self).__init__(message, hint=hint) |
45776
0fc8b066928a
errors: name arguments to ParseError constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45775
diff
changeset
|
367 self.location = location |
0fc8b066928a
errors: name arguments to ParseError constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45775
diff
changeset
|
368 |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
369 def format(self) -> bytes: |
45884
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
370 from .i18n import _ |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
371 |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
372 if self.location is not None: |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
373 message = _(b"hg: parse error at %s: %s\n") % ( |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
374 pycompat.bytestr(self.location), |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
375 self.message, |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
376 ) |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
377 else: |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
378 message = _(b"hg: parse error: %s\n") % self.message |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
379 if self.hint: |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
380 message += _(b"(%s)\n") % self.hint |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
381 return message |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45883
diff
changeset
|
382 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
383 |
34251
61714510220d
error: move patch.PatchError so it can easily implement __bytes__ (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32616
diff
changeset
|
384 class PatchError(Exception): |
61714510220d
error: move patch.PatchError so it can easily implement __bytes__ (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32616
diff
changeset
|
385 __bytes__ = _tobytes |
61714510220d
error: move patch.PatchError so it can easily implement __bytes__ (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32616
diff
changeset
|
386 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
387 |
48363
6a454e7053a1
errors: return more detailed errors when failing to parse or apply patch
Martin von Zweigbergk <martinvonz@google.com>
parents:
48284
diff
changeset
|
388 class PatchParseError(PatchError): |
6a454e7053a1
errors: return more detailed errors when failing to parse or apply patch
Martin von Zweigbergk <martinvonz@google.com>
parents:
48284
diff
changeset
|
389 __bytes__ = _tobytes |
6a454e7053a1
errors: return more detailed errors when failing to parse or apply patch
Martin von Zweigbergk <martinvonz@google.com>
parents:
48284
diff
changeset
|
390 |
6a454e7053a1
errors: return more detailed errors when failing to parse or apply patch
Martin von Zweigbergk <martinvonz@google.com>
parents:
48284
diff
changeset
|
391 |
6a454e7053a1
errors: return more detailed errors when failing to parse or apply patch
Martin von Zweigbergk <martinvonz@google.com>
parents:
48284
diff
changeset
|
392 class PatchApplicationError(PatchError): |
6a454e7053a1
errors: return more detailed errors when failing to parse or apply patch
Martin von Zweigbergk <martinvonz@google.com>
parents:
48284
diff
changeset
|
393 __bytes__ = _tobytes |
6a454e7053a1
errors: return more detailed errors when failing to parse or apply patch
Martin von Zweigbergk <martinvonz@google.com>
parents:
48284
diff
changeset
|
394 |
6a454e7053a1
errors: return more detailed errors when failing to parse or apply patch
Martin von Zweigbergk <martinvonz@google.com>
parents:
48284
diff
changeset
|
395 |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
396 def getsimilar(symbols: Iterable[bytes], value: bytes) -> List[bytes]: |
45882
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
397 sim = lambda x: difflib.SequenceMatcher(None, value, x).ratio() |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
398 # The cutoff for similarity here is pretty arbitrary. It should |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
399 # probably be investigated and tweaked. |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
400 return [s for s in symbols if sim(s) > 0.6] |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
401 |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
402 |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
403 def similarity_hint(similar: List[bytes]) -> Optional[bytes]: |
45882
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
404 from .i18n import _ |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
405 |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
406 if len(similar) == 1: |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
407 return _(b"did you mean %s?") % similar[0] |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
408 elif similar: |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
409 ss = b", ".join(sorted(similar)) |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
410 return _(b"did you mean one of %s?") % ss |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
411 else: |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
412 return None |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
413 |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45877
diff
changeset
|
414 |
24217
d2b81256db1e
error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents:
24190
diff
changeset
|
415 class UnknownIdentifier(ParseError): |
d2b81256db1e
error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents:
24190
diff
changeset
|
416 """Exception raised when a {rev,file}set references an unknown identifier""" |
d2b81256db1e
error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents:
24190
diff
changeset
|
417 |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
418 def __init__(self, function: bytes, symbols: Iterable[bytes]) -> None: |
25945
147bd9e238a1
error: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25484
diff
changeset
|
419 from .i18n import _ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
420 |
45883
1817b66897ad
errors: create "similarity hint" for UnknownIdentifier eagerly in constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45882
diff
changeset
|
421 similar = getsimilar(symbols, function) |
1817b66897ad
errors: create "similarity hint" for UnknownIdentifier eagerly in constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45882
diff
changeset
|
422 hint = similarity_hint(similar) |
1817b66897ad
errors: create "similarity hint" for UnknownIdentifier eagerly in constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45882
diff
changeset
|
423 |
1817b66897ad
errors: create "similarity hint" for UnknownIdentifier eagerly in constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45882
diff
changeset
|
424 ParseError.__init__( |
1817b66897ad
errors: create "similarity hint" for UnknownIdentifier eagerly in constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45882
diff
changeset
|
425 self, _(b"unknown identifier: %s") % function, hint=hint |
1817b66897ad
errors: create "similarity hint" for UnknownIdentifier eagerly in constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45882
diff
changeset
|
426 ) |
24217
d2b81256db1e
error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents:
24190
diff
changeset
|
427 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
428 |
29509
945b4c14c570
error: make HintException a mix-in class not derived from BaseException (API)
Yuya Nishihara <yuya@tcha.org>
parents:
28141
diff
changeset
|
429 class RepoError(Hint, Exception): |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
430 __bytes__ = _tobytes |
7637 | 431 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
432 |
9423
1444a42f6052
Make distinct lookup error for localrepo.lookup
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
433 class RepoLookupError(RepoError): |
1444a42f6052
Make distinct lookup error for localrepo.lookup
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
434 pass |
1444a42f6052
Make distinct lookup error for localrepo.lookup
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
435 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
436 |
23016
2bd51e61c65e
repoview: add a FilteredRepoLookupError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23015
diff
changeset
|
437 class FilteredRepoLookupError(RepoLookupError): |
2bd51e61c65e
repoview: add a FilteredRepoLookupError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23015
diff
changeset
|
438 pass |
2bd51e61c65e
repoview: add a FilteredRepoLookupError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23015
diff
changeset
|
439 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
440 |
7637 | 441 class CapabilityError(RepoError): |
442 pass | |
7640 | 443 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
444 |
13447
931a72e00efa
introduce new RequirementError (issue2649)
Adrian Buehlmann <adrian@cadifra.com>
parents:
11574
diff
changeset
|
445 class RequirementError(RepoError): |
931a72e00efa
introduce new RequirementError (issue2649)
Adrian Buehlmann <adrian@cadifra.com>
parents:
11574
diff
changeset
|
446 """Exception raised if .hg/requires has an unknown entry.""" |
931a72e00efa
introduce new RequirementError (issue2649)
Adrian Buehlmann <adrian@cadifra.com>
parents:
11574
diff
changeset
|
447 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
448 |
31959
b445a3f00528
stdio: add machinery to identify failed stdout/stderr writes
Bryan O'Sullivan <bryano@fb.com>
parents:
31503
diff
changeset
|
449 class StdioError(IOError): |
b445a3f00528
stdio: add machinery to identify failed stdout/stderr writes
Bryan O'Sullivan <bryano@fb.com>
parents:
31503
diff
changeset
|
450 """Raised if I/O to stdout or stderr fails""" |
b445a3f00528
stdio: add machinery to identify failed stdout/stderr writes
Bryan O'Sullivan <bryano@fb.com>
parents:
31503
diff
changeset
|
451 |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
452 def __init__(self, err: IOError) -> None: |
31959
b445a3f00528
stdio: add machinery to identify failed stdout/stderr writes
Bryan O'Sullivan <bryano@fb.com>
parents:
31503
diff
changeset
|
453 IOError.__init__(self, err.errno, err.strerror) |
b445a3f00528
stdio: add machinery to identify failed stdout/stderr writes
Bryan O'Sullivan <bryano@fb.com>
parents:
31503
diff
changeset
|
454 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
455 # no __bytes__() because error message is derived from the standard IOError |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
456 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
457 |
26985
039a53c87370
error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26896
diff
changeset
|
458 class UnsupportedMergeRecords(Abort): |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
459 def __init__(self, recordtypes: Iterable[bytes]) -> None: |
26985
039a53c87370
error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26896
diff
changeset
|
460 from .i18n import _ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
461 |
26985
039a53c87370
error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26896
diff
changeset
|
462 self.recordtypes = sorted(recordtypes) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
463 s = b' '.join(self.recordtypes) |
26985
039a53c87370
error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26896
diff
changeset
|
464 Abort.__init__( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
465 self, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
466 _(b'unsupported merge state records: %s') % s, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
467 hint=_( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
468 b'see https://mercurial-scm.org/wiki/MergeStateRecords for ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
469 b'more information' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
470 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
471 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
472 |
26985
039a53c87370
error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26896
diff
changeset
|
473 |
32596
19df975eb555
obsolete: raise richer exception on unknown version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32402
diff
changeset
|
474 class UnknownVersion(Abort): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45915
diff
changeset
|
475 """generic exception for aborting from an encounter with an unknown version""" |
32596
19df975eb555
obsolete: raise richer exception on unknown version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32402
diff
changeset
|
476 |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
477 def __init__( |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
478 self, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
479 msg: bytes, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
480 hint: Optional[bytes] = None, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
481 version: Optional[bytes] = None, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
482 ) -> None: |
32596
19df975eb555
obsolete: raise richer exception on unknown version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32402
diff
changeset
|
483 self.version = version |
19df975eb555
obsolete: raise richer exception on unknown version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32402
diff
changeset
|
484 super(UnknownVersion, self).__init__(msg, hint=hint) |
19df975eb555
obsolete: raise richer exception on unknown version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32402
diff
changeset
|
485 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
486 |
7640 | 487 class LockError(IOError): |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
488 def __init__( |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
489 self, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
490 errno: int, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
491 strerror: str, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
492 filename: bytes, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
493 desc: Optional[bytes], |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
494 ) -> None: |
7640 | 495 IOError.__init__(self, errno, strerror, filename) |
496 self.desc = desc | |
497 | |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
498 # no __bytes__() because error message is derived from the standard IOError |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
499 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
500 |
7640 | 501 class LockHeld(LockError): |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
502 def __init__( |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
503 self, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
504 errno: int, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
505 filename: bytes, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
506 desc: Optional[bytes], |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
507 locker, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
508 ): |
51286
81224afd938d
lock: properly convert error to bytes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51285
diff
changeset
|
509 LockError.__init__(self, errno, 'Lock held', filename, desc) |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
510 self.filename: bytes = filename |
7640 | 511 self.locker = locker |
512 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
513 |
7640 | 514 class LockUnavailable(LockError): |
515 pass | |
7641
d2f753830f80
error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents:
7640
diff
changeset
|
516 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
517 |
26355
f51713b8c6fa
error: add an exception to indicate lock inheritance API contract violations
Siddharth Agarwal <sid0@fb.com>
parents:
25945
diff
changeset
|
518 # LockError is for errors while acquiring the lock -- this is unrelated |
26438
024644b1900b
error: make lock inheritance contract violations a subclass of RuntimeError
Siddharth Agarwal <sid0@fb.com>
parents:
26394
diff
changeset
|
519 class LockInheritanceContractViolation(RuntimeError): |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
520 __bytes__ = _tobytes |
26355
f51713b8c6fa
error: add an exception to indicate lock inheritance API contract violations
Siddharth Agarwal <sid0@fb.com>
parents:
25945
diff
changeset
|
521 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
522 |
7641
d2f753830f80
error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents:
7640
diff
changeset
|
523 class ResponseError(Exception): |
d2f753830f80
error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents:
7640
diff
changeset
|
524 """Raised to print an error with part of output and exit.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
525 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
526 __bytes__ = _tobytes |
7641
d2f753830f80
error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents:
7640
diff
changeset
|
527 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
528 |
7644
182b7114d35a
error: move SignalInterrupt
Matt Mackall <mpm@selenic.com>
parents:
7643
diff
changeset
|
529 # derived from KeyboardInterrupt to simplify some breakout code |
182b7114d35a
error: move SignalInterrupt
Matt Mackall <mpm@selenic.com>
parents:
7643
diff
changeset
|
530 class SignalInterrupt(KeyboardInterrupt): |
182b7114d35a
error: move SignalInterrupt
Matt Mackall <mpm@selenic.com>
parents:
7643
diff
changeset
|
531 """Exception raised on SIGTERM and SIGHUP.""" |
7646 | 532 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
533 |
7646 | 534 class SignatureError(Exception): |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
535 __bytes__ = _tobytes |
21184
28d76afa1568
bundle2: fix raising errors during heads checking
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
18931
diff
changeset
|
536 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
537 |
21184
28d76afa1568
bundle2: fix raising errors during heads checking
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
18931
diff
changeset
|
538 class PushRaced(RuntimeError): |
28d76afa1568
bundle2: fix raising errors during heads checking
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
18931
diff
changeset
|
539 """An exception raised during unbundling that indicate a push race""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
540 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
541 __bytes__ = _tobytes |
21184
28d76afa1568
bundle2: fix raising errors during heads checking
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
18931
diff
changeset
|
542 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
543 |
32340
9c023179e8d0
error: add hint to ProgrammingError
Yuya Nishihara <yuya@tcha.org>
parents:
32023
diff
changeset
|
544 class ProgrammingError(Hint, RuntimeError): |
30585
0f865311ae3f
error: make it clear that ProgrammingError is for mercurial developers
Jun Wu <quark@fb.com>
parents:
30573
diff
changeset
|
545 """Raised if a mercurial (core or extension) developer made a mistake""" |
39579
921aeb9ac508
error: ensure ProgrammingError message is always a str
Augie Fackler <augie@google.com>
parents:
39559
diff
changeset
|
546 |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
547 def __init__(self, msg: AnyStr, *args, **kwargs): |
39596
409c42d6a570
py3: use sysstr() to convert ProgrammingError bytes with no unicode error risk
Yuya Nishihara <yuya@tcha.org>
parents:
39579
diff
changeset
|
548 # On Python 3, turn the message back into a string since this is |
409c42d6a570
py3: use sysstr() to convert ProgrammingError bytes with no unicode error risk
Yuya Nishihara <yuya@tcha.org>
parents:
39579
diff
changeset
|
549 # an internal-only error that won't be printed except in a |
409c42d6a570
py3: use sysstr() to convert ProgrammingError bytes with no unicode error risk
Yuya Nishihara <yuya@tcha.org>
parents:
39579
diff
changeset
|
550 # stack traces. |
409c42d6a570
py3: use sysstr() to convert ProgrammingError bytes with no unicode error risk
Yuya Nishihara <yuya@tcha.org>
parents:
39579
diff
changeset
|
551 msg = pycompat.sysstr(msg) |
39579
921aeb9ac508
error: ensure ProgrammingError message is always a str
Augie Fackler <augie@google.com>
parents:
39559
diff
changeset
|
552 super(ProgrammingError, self).__init__(msg, *args, **kwargs) |
921aeb9ac508
error: ensure ProgrammingError message is always a str
Augie Fackler <augie@google.com>
parents:
39559
diff
changeset
|
553 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
554 __bytes__ = _tobytes |
30573 | 555 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
556 |
32402
c8e10565a113
error: add a new exception named WdirUnsupported
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32340
diff
changeset
|
557 class WdirUnsupported(Exception): |
c8e10565a113
error: add a new exception named WdirUnsupported
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32340
diff
changeset
|
558 """An exception which is raised when 'wdir()' is not supported""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
559 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
560 __bytes__ = _tobytes |
32402
c8e10565a113
error: add a new exception named WdirUnsupported
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32340
diff
changeset
|
561 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
562 |
21618
7568f5c1c801
bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
563 # bundle2 related errors |
7568f5c1c801
bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
564 class BundleValueError(ValueError): |
21621
b6eb56a9335d
bundle2: introduce a ``params`` attribute to BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21620
diff
changeset
|
565 """error raised when bundle2 cannot be processed""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
566 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
567 __bytes__ = _tobytes |
21620
6eaa71b2a3cc
bundle2: introduce a parttype attribute to BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21618
diff
changeset
|
568 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
569 |
26393
cff70549a959
bundle2: rename error exception class for unsupported feature
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26355
diff
changeset
|
570 class BundleUnknownFeatureError(BundleValueError): |
26394
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
571 def __init__(self, parttype=None, params=(), values=()): |
21620
6eaa71b2a3cc
bundle2: introduce a parttype attribute to BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21618
diff
changeset
|
572 self.parttype = parttype |
21621
b6eb56a9335d
bundle2: introduce a ``params`` attribute to BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21620
diff
changeset
|
573 self.params = params |
26394
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
574 self.values = values |
21627
3e8bcc90f07c
bundle2: support None parttype in BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21621
diff
changeset
|
575 if self.parttype is None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
576 msg = b'Stream Parameter' |
21627
3e8bcc90f07c
bundle2: support None parttype in BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21621
diff
changeset
|
577 else: |
3e8bcc90f07c
bundle2: support None parttype in BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21621
diff
changeset
|
578 msg = parttype |
26394
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
579 entries = self.params |
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
580 if self.params and self.values: |
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
581 assert len(self.params) == len(self.values) |
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
582 entries = [] |
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
583 for idx, par in enumerate(self.params): |
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
584 val = self.values[idx] |
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
585 if val is None: |
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
586 entries.append(val) |
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
587 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
588 entries.append(b"%s=%r" % (par, pycompat.maybebytestr(val))) |
26394
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
589 if entries: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
590 msg = b'%s - %s' % (msg, b', '.join(entries)) |
46899
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
591 ValueError.__init__(self, msg) # TODO: convert to str? |
21618
7568f5c1c801
bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
592 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
593 |
21618
7568f5c1c801
bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
594 class ReadOnlyPartError(RuntimeError): |
7568f5c1c801
bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
595 """error raised when code tries to alter a part being generated""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
596 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
597 __bytes__ = _tobytes |
21618
7568f5c1c801
bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
598 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
599 |
25484
a5192774e925
bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25249
diff
changeset
|
600 class PushkeyFailed(Abort): |
a5192774e925
bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25249
diff
changeset
|
601 """error raised when a pushkey part failed to update a value""" |
a5192774e925
bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25249
diff
changeset
|
602 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
603 def __init__( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
604 self, partid, namespace=None, key=None, new=None, old=None, ret=None |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
605 ): |
25484
a5192774e925
bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25249
diff
changeset
|
606 self.partid = partid |
a5192774e925
bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25249
diff
changeset
|
607 self.namespace = namespace |
a5192774e925
bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25249
diff
changeset
|
608 self.key = key |
a5192774e925
bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25249
diff
changeset
|
609 self.new = new |
a5192774e925
bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25249
diff
changeset
|
610 self.old = old |
a5192774e925
bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25249
diff
changeset
|
611 self.ret = ret |
a5192774e925
bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25249
diff
changeset
|
612 # no i18n expected to be processed into a better message |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
613 Abort.__init__( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
614 self, b'failed to update value for "%s/%s"' % (namespace, key) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
615 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
616 |
25484
a5192774e925
bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25249
diff
changeset
|
617 |
39777
b63dee7bd0d9
global: replace most uses of RevlogError with StorageError (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39776
diff
changeset
|
618 class CensoredNodeError(StorageError): |
24190
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24137
diff
changeset
|
619 """error raised when content verification fails on a censored node |
22595
244478687edd
error: add CensoredNodeError, will be thrown when content deliberately erased
Mike Edgar <adgar@google.com>
parents:
22359
diff
changeset
|
620 |
24190
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24137
diff
changeset
|
621 Also contains the tombstone data substituted for the uncensored data. |
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24137
diff
changeset
|
622 """ |
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24137
diff
changeset
|
623 |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
624 def __init__(self, filename: bytes, node: bytes, tombstone: bytes): |
25945
147bd9e238a1
error: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25484
diff
changeset
|
625 from .node import short |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
626 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
627 StorageError.__init__(self, b'%s:%s' % (filename, short(node))) |
24190
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24137
diff
changeset
|
628 self.tombstone = tombstone |
24120
a450e0a2ba0a
revlog: in addgroup, reject ill-formed deltas based on censored nodes
Mike Edgar <adgar@google.com>
parents:
24040
diff
changeset
|
629 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
630 |
39777
b63dee7bd0d9
global: replace most uses of RevlogError with StorageError (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39776
diff
changeset
|
631 class CensoredBaseError(StorageError): |
24120
a450e0a2ba0a
revlog: in addgroup, reject ill-formed deltas based on censored nodes
Mike Edgar <adgar@google.com>
parents:
24040
diff
changeset
|
632 """error raised when a delta is rejected because its base is censored |
a450e0a2ba0a
revlog: in addgroup, reject ill-formed deltas based on censored nodes
Mike Edgar <adgar@google.com>
parents:
24040
diff
changeset
|
633 |
a450e0a2ba0a
revlog: in addgroup, reject ill-formed deltas based on censored nodes
Mike Edgar <adgar@google.com>
parents:
24040
diff
changeset
|
634 A delta based on a censored revision must be formed as single patch |
a450e0a2ba0a
revlog: in addgroup, reject ill-formed deltas based on censored nodes
Mike Edgar <adgar@google.com>
parents:
24040
diff
changeset
|
635 operation which replaces the entire base with new content. This ensures |
a450e0a2ba0a
revlog: in addgroup, reject ill-formed deltas based on censored nodes
Mike Edgar <adgar@google.com>
parents:
24040
diff
changeset
|
636 the delta may be applied by clones which have not censored the base. |
a450e0a2ba0a
revlog: in addgroup, reject ill-formed deltas based on censored nodes
Mike Edgar <adgar@google.com>
parents:
24040
diff
changeset
|
637 """ |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
638 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
639 |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
640 class InvalidBundleSpecification(Exception): |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
641 """error raised when a bundle specification is invalid. |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
642 |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
643 This is used for syntax errors as opposed to support errors. |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
644 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
645 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
646 __bytes__ = _tobytes |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
647 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
648 |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
649 class UnsupportedBundleSpecification(Exception): |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
650 """error raised when a bundle specification is not supported.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
651 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
652 __bytes__ = _tobytes |
29536
b17a6e3cd2ac
shelve: make unshelve be able to abort in any case
Kostia Balytskyi <ikostia@fb.com>
parents:
29510
diff
changeset
|
653 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
654 |
29536
b17a6e3cd2ac
shelve: make unshelve be able to abort in any case
Kostia Balytskyi <ikostia@fb.com>
parents:
29510
diff
changeset
|
655 class CorruptedState(Exception): |
b17a6e3cd2ac
shelve: make unshelve be able to abort in any case
Kostia Balytskyi <ikostia@fb.com>
parents:
29510
diff
changeset
|
656 """error raised when a command is not able to read its state from file""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
657 |
32616
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32596
diff
changeset
|
658 __bytes__ = _tobytes |
32002
bf855efe5664
httppeer: wrap HTTPResponse.read() globally
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31959
diff
changeset
|
659 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
660 |
50660
bf16ef96defe
rust-dirstate: fall back to v1 if reading v2 failed
Raphaël Gomès <rgomes@octobus.net>
parents:
50329
diff
changeset
|
661 class CorruptedDirstate(Exception): |
bf16ef96defe
rust-dirstate: fall back to v1 if reading v2 failed
Raphaël Gomès <rgomes@octobus.net>
parents:
50329
diff
changeset
|
662 """error raised the dirstate appears corrupted on-disk. It may be due to |
bf16ef96defe
rust-dirstate: fall back to v1 if reading v2 failed
Raphaël Gomès <rgomes@octobus.net>
parents:
50329
diff
changeset
|
663 a dirstate version mismatch (i.e. expecting v2 and finding v1 on disk).""" |
bf16ef96defe
rust-dirstate: fall back to v1 if reading v2 failed
Raphaël Gomès <rgomes@octobus.net>
parents:
50329
diff
changeset
|
664 |
bf16ef96defe
rust-dirstate: fall back to v1 if reading v2 failed
Raphaël Gomès <rgomes@octobus.net>
parents:
50329
diff
changeset
|
665 __bytes__ = _tobytes |
bf16ef96defe
rust-dirstate: fall back to v1 if reading v2 failed
Raphaël Gomès <rgomes@octobus.net>
parents:
50329
diff
changeset
|
666 |
bf16ef96defe
rust-dirstate: fall back to v1 if reading v2 failed
Raphaël Gomès <rgomes@octobus.net>
parents:
50329
diff
changeset
|
667 |
32023
a29580905771
error: rename RichIOError to PeerTransportError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32002
diff
changeset
|
668 class PeerTransportError(Abort): |
a29580905771
error: rename RichIOError to PeerTransportError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32002
diff
changeset
|
669 """Transport-level I/O error when communicating with a peer repo.""" |
35105
795bfa2a9103
error: add InMemoryMergeConflictsError
Phil Cohen <phillco@fb.com>
parents:
34251
diff
changeset
|
670 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
671 |
35105
795bfa2a9103
error: add InMemoryMergeConflictsError
Phil Cohen <phillco@fb.com>
parents:
34251
diff
changeset
|
672 class InMemoryMergeConflictsError(Exception): |
795bfa2a9103
error: add InMemoryMergeConflictsError
Phil Cohen <phillco@fb.com>
parents:
34251
diff
changeset
|
673 """Exception raised when merge conflicts arose during an in-memory merge.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
674 |
35105
795bfa2a9103
error: add InMemoryMergeConflictsError
Phil Cohen <phillco@fb.com>
parents:
34251
diff
changeset
|
675 __bytes__ = _tobytes |
39559
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38841
diff
changeset
|
676 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
677 |
39559
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38841
diff
changeset
|
678 class WireprotoCommandError(Exception): |
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38841
diff
changeset
|
679 """Represents an error during execution of a wire protocol command. |
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38841
diff
changeset
|
680 |
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38841
diff
changeset
|
681 Should only be thrown by wire protocol version 2 commands. |
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38841
diff
changeset
|
682 |
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38841
diff
changeset
|
683 The error is a formatter string and an optional iterable of arguments. |
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38841
diff
changeset
|
684 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
685 |
51287
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
686 def __init__( |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
687 self, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
688 message: bytes, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
689 args: Optional[Sequence[bytes]] = None, |
f15cb5111a1e
pytype: move some type comment to proper annotation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
51286
diff
changeset
|
690 ) -> None: |
39559
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38841
diff
changeset
|
691 self.message = message |
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38841
diff
changeset
|
692 self.messageargs = args |