Mercurial > hg-stable
annotate mercurial/error.py @ 46952:82366464190a
init: use `get_clone_path` when suitable
`hg init` has this weird feature were you can refer to `[paths]` entry select the path to initialize. We move that code to the new APIs.
Differential Revision: https://phab.mercurial-scm.org/D10418
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 14 Apr 2021 18:02:25 +0200 |
parents | 8b6e36e4b553 |
children | 14ddb1dca2c0 |
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:
46796
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 |
25945
147bd9e238a1
error: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25484
diff
changeset
|
14 from __future__ import absolute_import |
147bd9e238a1
error: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25484
diff
changeset
|
15 |
45897
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45892
diff
changeset
|
16 import difflib |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45892
diff
changeset
|
17 |
32639
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
18 # Do not import anything but pycompat here, please |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
19 from . import pycompat |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
20 |
46388
ae62ab82a345
typing: ensure that error.Abort is given bytes
Matt Harbison <matt_harbison@yahoo.com>
parents:
45957
diff
changeset
|
21 if pycompat.TYPE_CHECKING: |
ae62ab82a345
typing: ensure that error.Abort is given bytes
Matt Harbison <matt_harbison@yahoo.com>
parents:
45957
diff
changeset
|
22 from typing import ( |
46899
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
23 Any, |
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
24 AnyStr, |
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
25 Iterable, |
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
26 List, |
46388
ae62ab82a345
typing: ensure that error.Abort is given bytes
Matt Harbison <matt_harbison@yahoo.com>
parents:
45957
diff
changeset
|
27 Optional, |
46899
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
28 Sequence, |
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
29 Union, |
46388
ae62ab82a345
typing: ensure that error.Abort is given bytes
Matt Harbison <matt_harbison@yahoo.com>
parents:
45957
diff
changeset
|
30 ) |
ae62ab82a345
typing: ensure that error.Abort is given bytes
Matt Harbison <matt_harbison@yahoo.com>
parents:
45957
diff
changeset
|
31 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
32 |
32639
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
33 def _tobytes(exc): |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
34 """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:
32622
diff
changeset
|
35 if not exc.args: |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
36 return b'' |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
37 if len(exc.args) == 1: |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
38 return pycompat.bytestr(exc.args[0]) |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
39 return b'(%s)' % b', '.join(b"'%s'" % pycompat.bytestr(a) for a in exc.args) |
7633 | 40 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
41 |
29509
945b4c14c570
error: make HintException a mix-in class not derived from BaseException (API)
Yuya Nishihara <yuya@tcha.org>
parents:
28141
diff
changeset
|
42 class Hint(object): |
945b4c14c570
error: make HintException a mix-in class not derived from BaseException (API)
Yuya Nishihara <yuya@tcha.org>
parents:
28141
diff
changeset
|
43 """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
|
44 |
29510
19205a0e2bf1
error: make hintable exceptions reject unknown keyword arguments (API)
Yuya Nishihara <yuya@tcha.org>
parents:
29509
diff
changeset
|
45 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
|
46 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
|
47 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
48 |
25248
821e664924dc
error: refactor common hint-pattern into a common base class
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
25242
diff
changeset
|
49 def __init__(self, *args, **kw): |
43554
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43418
diff
changeset
|
50 self.hint = kw.pop('hint', None) |
29510
19205a0e2bf1
error: make hintable exceptions reject unknown keyword arguments (API)
Yuya Nishihara <yuya@tcha.org>
parents:
29509
diff
changeset
|
51 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
|
52 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
53 |
39792
cb65d4b7e429
error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39612
diff
changeset
|
54 class StorageError(Hint, Exception): |
cb65d4b7e429
error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39612
diff
changeset
|
55 """Raised when an error occurs in a storage layer. |
cb65d4b7e429
error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39612
diff
changeset
|
56 |
cb65d4b7e429
error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39612
diff
changeset
|
57 Usually subclassed by a storage-specific exception. |
cb65d4b7e429
error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39612
diff
changeset
|
58 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
59 |
39792
cb65d4b7e429
error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39612
diff
changeset
|
60 __bytes__ = _tobytes |
cb65d4b7e429
error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39612
diff
changeset
|
61 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
62 |
39792
cb65d4b7e429
error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39612
diff
changeset
|
63 class RevlogError(StorageError): |
45798
5bb900885311
errors: remove unnecessary override of __bytes__ in RevlogError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45682
diff
changeset
|
64 pass |
7633 | 65 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
66 |
43034
294afb982a88
sidedata: add a function to read sidedata from revlog raw text
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40985
diff
changeset
|
67 class SidedataHashError(RevlogError): |
294afb982a88
sidedata: add a function to read sidedata from revlog raw text
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40985
diff
changeset
|
68 def __init__(self, key, expected, got): |
46664
3941fe53670d
error: add `hint` attribute to `SidedataHashError`
Raphaël Gomès <rgomes@octobus.net>
parents:
45957
diff
changeset
|
69 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:
40985
diff
changeset
|
70 self.sidedatakey = key |
294afb982a88
sidedata: add a function to read sidedata from revlog raw text
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40985
diff
changeset
|
71 self.expecteddigest = expected |
294afb982a88
sidedata: add a function to read sidedata from revlog raw text
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40985
diff
changeset
|
72 self.actualdigest = got |
294afb982a88
sidedata: add a function to read sidedata from revlog raw text
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40985
diff
changeset
|
73 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
74 |
23014
f00813325c5a
repoview: add a FilteredIndexError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23010
diff
changeset
|
75 class FilteredIndexError(IndexError): |
32639
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
76 __bytes__ = _tobytes |
23014
f00813325c5a
repoview: add a FilteredIndexError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23010
diff
changeset
|
77 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
78 |
7633 | 79 class LookupError(RevlogError, KeyError): |
80 def __init__(self, name, index, message): | |
81 self.name = name | |
24038
10d02cd18604
error: store filename and message on LookupError for later
Martin von Zweigbergk <martinvonz@google.com>
parents:
23415
diff
changeset
|
82 self.index = index |
24137
dcfdfd63bde4
error.LookupError: rename 'message' property to something else
Siddharth Agarwal <sid0@fb.com>
parents:
24120
diff
changeset
|
83 # 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
|
84 # 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
|
85 self.lookupmessage = message |
36570
c6a7b99f150a
error: fix isinstnace check to use bytes instead of str
Augie Fackler <augie@google.com>
parents:
35128
diff
changeset
|
86 if isinstance(name, bytes) and len(name) == 20: |
46690
6fc57680cfd6
error: remove shortening of node in error message
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46664
diff
changeset
|
87 from .node import hex |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
88 |
46690
6fc57680cfd6
error: remove shortening of node in error message
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46664
diff
changeset
|
89 name = hex(name) |
45217
bd5b2b29b82d
py3: fix formatting of LookupError for workingctx
Yuya Nishihara <yuya@tcha.org>
parents:
45151
diff
changeset
|
90 # 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
|
91 RevlogError.__init__( |
bd5b2b29b82d
py3: fix formatting of LookupError for workingctx
Yuya Nishihara <yuya@tcha.org>
parents:
45151
diff
changeset
|
92 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
|
93 ) |
7633 | 94 |
32639
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
95 def __bytes__(self): |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
96 return RevlogError.__bytes__(self) |
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
97 |
7633 | 98 def __str__(self): |
99 return RevlogError.__str__(self) | |
7636 | 100 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
101 |
38880
df0873ab5c14
revlog: use specialized exception for ambiguous prefix lookup
Martin von Zweigbergk <martinvonz@google.com>
parents:
38608
diff
changeset
|
102 class AmbiguousPrefixLookupError(LookupError): |
df0873ab5c14
revlog: use specialized exception for ambiguous prefix lookup
Martin von Zweigbergk <martinvonz@google.com>
parents:
38608
diff
changeset
|
103 pass |
df0873ab5c14
revlog: use specialized exception for ambiguous prefix lookup
Martin von Zweigbergk <martinvonz@google.com>
parents:
38608
diff
changeset
|
104 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
105 |
23015
21c44c1aed87
repoview: add a FilteredLookupError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23014
diff
changeset
|
106 class FilteredLookupError(LookupError): |
21c44c1aed87
repoview: add a FilteredLookupError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23014
diff
changeset
|
107 pass |
21c44c1aed87
repoview: add a FilteredLookupError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23014
diff
changeset
|
108 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
109 |
18855
50c922c1b514
hgweb: show correct error message for i18n environment
Takumi IINO <trot.thunder@gmail.com>
parents:
15017
diff
changeset
|
110 class ManifestLookupError(LookupError): |
50c922c1b514
hgweb: show correct error message for i18n environment
Takumi IINO <trot.thunder@gmail.com>
parents:
15017
diff
changeset
|
111 pass |
50c922c1b514
hgweb: show correct error message for i18n environment
Takumi IINO <trot.thunder@gmail.com>
parents:
15017
diff
changeset
|
112 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
113 |
11287
b901bb751999
error: change ParseError to CommandError
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
114 class CommandError(Exception): |
7636 | 115 """Exception raised on errors in parsing the command line.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
116 |
45678
bd2df58366b1
errors: name arguments to CommandError constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45677
diff
changeset
|
117 def __init__(self, command, message): |
46899
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
118 # type: (bytes, bytes) -> None |
45678
bd2df58366b1
errors: name arguments to CommandError constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45677
diff
changeset
|
119 self.command = command |
bd2df58366b1
errors: name arguments to CommandError constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45677
diff
changeset
|
120 self.message = message |
bd2df58366b1
errors: name arguments to CommandError constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45677
diff
changeset
|
121 super(CommandError, self).__init__() |
bd2df58366b1
errors: name arguments to CommandError constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45677
diff
changeset
|
122 |
32639
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
123 __bytes__ = _tobytes |
7637 | 124 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
125 |
45677
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45217
diff
changeset
|
126 class UnknownCommand(Exception): |
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45217
diff
changeset
|
127 """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:
45217
diff
changeset
|
128 |
45680
bb1a988ef4a5
errors: name arguments to UnknownCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45679
diff
changeset
|
129 def __init__(self, command, all_commands=None): |
46899
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
130 # type: (bytes, Optional[List[bytes]]) -> None |
45680
bb1a988ef4a5
errors: name arguments to UnknownCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45679
diff
changeset
|
131 self.command = command |
bb1a988ef4a5
errors: name arguments to UnknownCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45679
diff
changeset
|
132 self.all_commands = all_commands |
bb1a988ef4a5
errors: name arguments to UnknownCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45679
diff
changeset
|
133 super(UnknownCommand, self).__init__() |
bb1a988ef4a5
errors: name arguments to UnknownCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45679
diff
changeset
|
134 |
45677
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45217
diff
changeset
|
135 __bytes__ = _tobytes |
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45217
diff
changeset
|
136 |
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45217
diff
changeset
|
137 |
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45217
diff
changeset
|
138 class AmbiguousCommand(Exception): |
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45217
diff
changeset
|
139 """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:
45217
diff
changeset
|
140 |
45679
65e2b64670b5
errors: name arguments to AmbiguousCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45678
diff
changeset
|
141 def __init__(self, prefix, matches): |
46899
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
142 # type: (bytes, List[bytes]) -> None |
45679
65e2b64670b5
errors: name arguments to AmbiguousCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45678
diff
changeset
|
143 self.prefix = prefix |
65e2b64670b5
errors: name arguments to AmbiguousCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45678
diff
changeset
|
144 self.matches = matches |
65e2b64670b5
errors: name arguments to AmbiguousCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45678
diff
changeset
|
145 super(AmbiguousCommand, self).__init__() |
65e2b64670b5
errors: name arguments to AmbiguousCommand constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45678
diff
changeset
|
146 |
45677
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45217
diff
changeset
|
147 __bytes__ = _tobytes |
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45217
diff
changeset
|
148 |
bdd2cdf9e248
errors: move UnknownCommand and AmbiguousCommand near CommandError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45217
diff
changeset
|
149 |
45844
8f07f5a9c3de
worker: raise exception instead of calling sys.exit() with child's code
Martin von Zweigbergk <martinvonz@google.com>
parents:
45799
diff
changeset
|
150 class WorkerError(Exception): |
8f07f5a9c3de
worker: raise exception instead of calling sys.exit() with child's code
Martin von Zweigbergk <martinvonz@google.com>
parents:
45799
diff
changeset
|
151 """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:
45799
diff
changeset
|
152 |
8f07f5a9c3de
worker: raise exception instead of calling sys.exit() with child's code
Martin von Zweigbergk <martinvonz@google.com>
parents:
45799
diff
changeset
|
153 def __init__(self, status_code): |
46899
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
154 # type: (int) -> None |
45844
8f07f5a9c3de
worker: raise exception instead of calling sys.exit() with child's code
Martin von Zweigbergk <martinvonz@google.com>
parents:
45799
diff
changeset
|
155 self.status_code = status_code |
45918
64faa55716f4
tests: make test-worker.t pass on py2
Martin von Zweigbergk <martinvonz@google.com>
parents:
45909
diff
changeset
|
156 # 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:
45909
diff
changeset
|
157 super(WorkerError, self).__init__(status_code) |
64faa55716f4
tests: make test-worker.t pass on py2
Martin von Zweigbergk <martinvonz@google.com>
parents:
45909
diff
changeset
|
158 |
64faa55716f4
tests: make test-worker.t pass on py2
Martin von Zweigbergk <martinvonz@google.com>
parents:
45909
diff
changeset
|
159 __bytes__ = _tobytes |
45844
8f07f5a9c3de
worker: raise exception instead of calling sys.exit() with child's code
Martin von Zweigbergk <martinvonz@google.com>
parents:
45799
diff
changeset
|
160 |
8f07f5a9c3de
worker: raise exception instead of calling sys.exit() with child's code
Martin von Zweigbergk <martinvonz@google.com>
parents:
45799
diff
changeset
|
161 |
29509
945b4c14c570
error: make HintException a mix-in class not derived from BaseException (API)
Yuya Nishihara <yuya@tcha.org>
parents:
28141
diff
changeset
|
162 class InterventionRequired(Hint, Exception): |
18931
3c224e0949de
error: introduce new InterventionRequired exception
Augie Fackler <raf@durin42.com>
parents:
18855
diff
changeset
|
163 """Exception raised when a command requires human intervention.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
164 |
32639
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
165 __bytes__ = _tobytes |
18931
3c224e0949de
error: introduce new InterventionRequired exception
Augie Fackler <raf@durin42.com>
parents:
18855
diff
changeset
|
166 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
167 |
45151
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43554
diff
changeset
|
168 class ConflictResolutionRequired(InterventionRequired): |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43554
diff
changeset
|
169 """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:
43554
diff
changeset
|
170 |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43554
diff
changeset
|
171 def __init__(self, opname): |
46899
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
172 # type: (bytes) -> None |
45151
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43554
diff
changeset
|
173 from .i18n import _ |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43554
diff
changeset
|
174 |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43554
diff
changeset
|
175 self.opname = opname |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43554
diff
changeset
|
176 InterventionRequired.__init__( |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43554
diff
changeset
|
177 self, |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43554
diff
changeset
|
178 _( |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43554
diff
changeset
|
179 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:
43554
diff
changeset
|
180 ) |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43554
diff
changeset
|
181 % opname, |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43554
diff
changeset
|
182 ) |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43554
diff
changeset
|
183 |
e429e7c801b2
error: normalize "unresolved conflicts" error messages with a custom class
Daniel Ploch <dploch@google.com>
parents:
43554
diff
changeset
|
184 |
29509
945b4c14c570
error: make HintException a mix-in class not derived from BaseException (API)
Yuya Nishihara <yuya@tcha.org>
parents:
28141
diff
changeset
|
185 class Abort(Hint, Exception): |
11288
2123aad24d56
error: add new ParseError for various parsing errors
Matt Mackall <mpm@selenic.com>
parents:
11287
diff
changeset
|
186 """Raised if a command needs to print an error and exit.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
187 |
45682
d2e1dcd4490d
errors: name arguments to Abort constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45680
diff
changeset
|
188 def __init__(self, message, hint=None): |
46388
ae62ab82a345
typing: ensure that error.Abort is given bytes
Matt Harbison <matt_harbison@yahoo.com>
parents:
45957
diff
changeset
|
189 # type: (bytes, Optional[bytes]) -> None |
45682
d2e1dcd4490d
errors: name arguments to Abort constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45680
diff
changeset
|
190 self.message = message |
d2e1dcd4490d
errors: name arguments to Abort constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45680
diff
changeset
|
191 self.hint = hint |
d2e1dcd4490d
errors: name arguments to Abort constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45680
diff
changeset
|
192 # Pass the message into the Exception constructor to help extensions |
d2e1dcd4490d
errors: name arguments to Abort constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45680
diff
changeset
|
193 # that look for exc.args[0]. |
d2e1dcd4490d
errors: name arguments to Abort constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45680
diff
changeset
|
194 Exception.__init__(self, message) |
d2e1dcd4490d
errors: name arguments to Abort constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45680
diff
changeset
|
195 |
d2e1dcd4490d
errors: name arguments to Abort constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45680
diff
changeset
|
196 def __bytes__(self): |
d2e1dcd4490d
errors: name arguments to Abort constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45680
diff
changeset
|
197 return self.message |
11288
2123aad24d56
error: add new ParseError for various parsing errors
Matt Mackall <mpm@selenic.com>
parents:
11287
diff
changeset
|
198 |
43417
822202e72f69
py3: do not reimplement Abort.__str__() on Python 2
Yuya Nishihara <yuya@tcha.org>
parents:
43402
diff
changeset
|
199 if pycompat.ispy3: |
822202e72f69
py3: do not reimplement Abort.__str__() on Python 2
Yuya Nishihara <yuya@tcha.org>
parents:
43402
diff
changeset
|
200 |
822202e72f69
py3: do not reimplement Abort.__str__() on Python 2
Yuya Nishihara <yuya@tcha.org>
parents:
43402
diff
changeset
|
201 def __str__(self): |
43418
ca3dca416f8d
py3: add inline comment about encoding issue of str(Abort())
Yuya Nishihara <yuya@tcha.org>
parents:
43417
diff
changeset
|
202 # the output would be unreadable if the message was translated, |
ca3dca416f8d
py3: add inline comment about encoding issue of str(Abort())
Yuya Nishihara <yuya@tcha.org>
parents:
43417
diff
changeset
|
203 # but do not replace it with encoding.strfromlocal(), which |
ca3dca416f8d
py3: add inline comment about encoding issue of str(Abort())
Yuya Nishihara <yuya@tcha.org>
parents:
43417
diff
changeset
|
204 # may raise another exception. |
43417
822202e72f69
py3: do not reimplement Abort.__str__() on Python 2
Yuya Nishihara <yuya@tcha.org>
parents:
43402
diff
changeset
|
205 return pycompat.sysstr(self.__bytes__()) |
43402
40bf3d7ecc42
py3: add a __str__ method to Abort
Denis Laxalde <denis@laxalde.org>
parents:
43077
diff
changeset
|
206 |
45900
600aec73f309
errors: format "abort: " text in a new Abort.format() method
Martin von Zweigbergk <martinvonz@google.com>
parents:
45899
diff
changeset
|
207 def format(self): |
46899
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
208 # type: () -> bytes |
45900
600aec73f309
errors: format "abort: " text in a new Abort.format() method
Martin von Zweigbergk <martinvonz@google.com>
parents:
45899
diff
changeset
|
209 from .i18n import _ |
600aec73f309
errors: format "abort: " text in a new Abort.format() method
Martin von Zweigbergk <martinvonz@google.com>
parents:
45899
diff
changeset
|
210 |
600aec73f309
errors: format "abort: " text in a new Abort.format() method
Martin von Zweigbergk <martinvonz@google.com>
parents:
45899
diff
changeset
|
211 message = _(b"abort: %s\n") % self.message |
600aec73f309
errors: format "abort: " text in a new Abort.format() method
Martin von Zweigbergk <martinvonz@google.com>
parents:
45899
diff
changeset
|
212 if self.hint: |
600aec73f309
errors: format "abort: " text in a new Abort.format() method
Martin von Zweigbergk <martinvonz@google.com>
parents:
45899
diff
changeset
|
213 message += _(b"(%s)\n") % self.hint |
600aec73f309
errors: format "abort: " text in a new Abort.format() method
Martin von Zweigbergk <martinvonz@google.com>
parents:
45899
diff
changeset
|
214 return message |
600aec73f309
errors: format "abort: " text in a new Abort.format() method
Martin von Zweigbergk <martinvonz@google.com>
parents:
45899
diff
changeset
|
215 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
216 |
45846
8d72e29ad1e0
errors: introduce InputError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45844
diff
changeset
|
217 class InputError(Abort): |
8d72e29ad1e0
errors: introduce InputError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45844
diff
changeset
|
218 """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:
45844
diff
changeset
|
219 |
8d72e29ad1e0
errors: introduce InputError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45844
diff
changeset
|
220 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:
45844
diff
changeset
|
221 """ |
8d72e29ad1e0
errors: introduce InputError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45844
diff
changeset
|
222 |
8d72e29ad1e0
errors: introduce InputError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45844
diff
changeset
|
223 |
45859
527ce85c2e60
errors: introduce StateError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45846
diff
changeset
|
224 class StateError(Abort): |
527ce85c2e60
errors: introduce StateError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45846
diff
changeset
|
225 """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:
45846
diff
changeset
|
226 |
527ce85c2e60
errors: introduce StateError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45846
diff
changeset
|
227 Examples: Unresolved merge conflicts, unfinished operations. |
527ce85c2e60
errors: introduce StateError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45846
diff
changeset
|
228 """ |
527ce85c2e60
errors: introduce StateError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45846
diff
changeset
|
229 |
527ce85c2e60
errors: introduce StateError and use it from commands and cmdutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
45846
diff
changeset
|
230 |
45892
ac362d5a7893
errors: introduce CanceledError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45859
diff
changeset
|
231 class CanceledError(Abort): |
ac362d5a7893
errors: introduce CanceledError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45859
diff
changeset
|
232 """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:
45859
diff
changeset
|
233 |
ac362d5a7893
errors: introduce CanceledError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45859
diff
changeset
|
234 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:
45859
diff
changeset
|
235 """ |
ac362d5a7893
errors: introduce CanceledError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45859
diff
changeset
|
236 |
ac362d5a7893
errors: introduce CanceledError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45859
diff
changeset
|
237 |
45930
8f50dc096cf4
errors: introduce SecurityError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45918
diff
changeset
|
238 class SecurityError(Abort): |
8f50dc096cf4
errors: introduce SecurityError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45918
diff
changeset
|
239 """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:
45918
diff
changeset
|
240 |
8f50dc096cf4
errors: introduce SecurityError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45918
diff
changeset
|
241 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:
45918
diff
changeset
|
242 filesystem, mismatched GPG signature, DoS protection. |
8f50dc096cf4
errors: introduce SecurityError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45918
diff
changeset
|
243 """ |
8f50dc096cf4
errors: introduce SecurityError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45918
diff
changeset
|
244 |
8f50dc096cf4
errors: introduce SecurityError and use it in a few places
Martin von Zweigbergk <martinvonz@google.com>
parents:
45918
diff
changeset
|
245 |
26692
8d1cfd77b64f
hook: raise a separate exception for when loading a hook fails
Siddharth Agarwal <sid0@fb.com>
parents:
26683
diff
changeset
|
246 class HookLoadError(Abort): |
8d1cfd77b64f
hook: raise a separate exception for when loading a hook fails
Siddharth Agarwal <sid0@fb.com>
parents:
26683
diff
changeset
|
247 """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
|
248 |
8d1cfd77b64f
hook: raise a separate exception for when loading a hook fails
Siddharth Agarwal <sid0@fb.com>
parents:
26683
diff
changeset
|
249 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
|
250 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
251 |
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
|
252 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
|
253 """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
|
254 |
cdbb85489c41
hook: raise a more specialized HookAbort exception when a hook fails
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23016
diff
changeset
|
255 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
|
256 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
257 |
11288
2123aad24d56
error: add new ParseError for various parsing errors
Matt Mackall <mpm@selenic.com>
parents:
11287
diff
changeset
|
258 class ConfigError(Abort): |
22359
e3714b927af5
error: use docstrings, not bare strings, for error classes
Mike Edgar <adgar@google.com>
parents:
21747
diff
changeset
|
259 """Exception raised when parsing config files""" |
8144
fca54469480e
ui: introduce new config parser
Matt Mackall <mpm@selenic.com>
parents:
7947
diff
changeset
|
260 |
45909
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45906
diff
changeset
|
261 def __init__(self, message, location=None, hint=None): |
46899
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
262 # type: (bytes, Optional[bytes], Optional[bytes]) -> None |
45909
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45906
diff
changeset
|
263 super(ConfigError, self).__init__(message, hint=hint) |
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45906
diff
changeset
|
264 self.location = location |
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45906
diff
changeset
|
265 |
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45906
diff
changeset
|
266 def format(self): |
46899
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
267 # type: () -> bytes |
45909
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45906
diff
changeset
|
268 from .i18n import _ |
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45906
diff
changeset
|
269 |
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45906
diff
changeset
|
270 if self.location is not None: |
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45906
diff
changeset
|
271 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:
45906
diff
changeset
|
272 pycompat.bytestr(self.location), |
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45906
diff
changeset
|
273 self.message, |
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45906
diff
changeset
|
274 ) |
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45906
diff
changeset
|
275 else: |
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45906
diff
changeset
|
276 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:
45906
diff
changeset
|
277 if self.hint: |
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45906
diff
changeset
|
278 message += _(b"(%s)\n") % self.hint |
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45906
diff
changeset
|
279 return message |
9dc1351d0b5f
errors: raise ConfigError on failure to parse config file
Martin von Zweigbergk <martinvonz@google.com>
parents:
45906
diff
changeset
|
280 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
281 |
26683
634666c48b7d
update: introduce a 'UpdateAbort' exception
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26640
diff
changeset
|
282 class UpdateAbort(Abort): |
634666c48b7d
update: introduce a 'UpdateAbort' exception
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26640
diff
changeset
|
283 """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
|
284 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
285 |
28141
13bb8de97f87
destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27628
diff
changeset
|
286 class MergeDestAbort(Abort): |
13bb8de97f87
destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27628
diff
changeset
|
287 """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
|
288 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
289 |
28141
13bb8de97f87
destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27628
diff
changeset
|
290 class NoMergeDestAbort(MergeDestAbort): |
13bb8de97f87
destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27628
diff
changeset
|
291 """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
|
292 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
293 |
28141
13bb8de97f87
destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27628
diff
changeset
|
294 class ManyMergeDestAbort(MergeDestAbort): |
30342
318a24b52eeb
spelling: fixes of non-dictionary words
Mads Kiilerich <madski@unity3d.com>
parents:
29536
diff
changeset
|
295 """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
|
296 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
297 |
26896
5e46123e6c35
error: add structured exception for EOF at prompt
Siddharth Agarwal <sid0@fb.com>
parents:
26693
diff
changeset
|
298 class ResponseExpected(Abort): |
5e46123e6c35
error: add structured exception for EOF at prompt
Siddharth Agarwal <sid0@fb.com>
parents:
26693
diff
changeset
|
299 """Raised when an EOF is received for a prompt""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
300 |
26896
5e46123e6c35
error: add structured exception for EOF at prompt
Siddharth Agarwal <sid0@fb.com>
parents:
26693
diff
changeset
|
301 def __init__(self): |
5e46123e6c35
error: add structured exception for EOF at prompt
Siddharth Agarwal <sid0@fb.com>
parents:
26693
diff
changeset
|
302 from .i18n import _ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
303 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
304 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
|
305 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
306 |
29509
945b4c14c570
error: make HintException a mix-in class not derived from BaseException (API)
Yuya Nishihara <yuya@tcha.org>
parents:
28141
diff
changeset
|
307 class OutOfBandError(Hint, Exception): |
22359
e3714b927af5
error: use docstrings, not bare strings, for error classes
Mike Edgar <adgar@google.com>
parents:
21747
diff
changeset
|
308 """Exception raised when a remote repo reports failure""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
309 |
32639
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
310 __bytes__ = _tobytes |
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
|
311 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
312 |
45902
7eb221b9af6c
errors: make ParseError a subtype of Abort
Martin von Zweigbergk <martinvonz@google.com>
parents:
45900
diff
changeset
|
313 class ParseError(Abort): |
24040
7f375d2de945
error: update docstring on ParseError
Augie Fackler <augie@google.com>
parents:
24038
diff
changeset
|
314 """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
|
315 |
45799
0fc8b066928a
errors: name arguments to ParseError constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45798
diff
changeset
|
316 def __init__(self, message, location=None, hint=None): |
46899
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
317 # type: (bytes, Optional[Union[bytes, int]], Optional[bytes]) -> None |
45902
7eb221b9af6c
errors: make ParseError a subtype of Abort
Martin von Zweigbergk <martinvonz@google.com>
parents:
45900
diff
changeset
|
318 super(ParseError, self).__init__(message, hint=hint) |
45799
0fc8b066928a
errors: name arguments to ParseError constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45798
diff
changeset
|
319 self.location = location |
0fc8b066928a
errors: name arguments to ParseError constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45798
diff
changeset
|
320 |
45899
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45898
diff
changeset
|
321 def format(self): |
46899
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
322 # type: () -> bytes |
45899
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45898
diff
changeset
|
323 from .i18n import _ |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45898
diff
changeset
|
324 |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45898
diff
changeset
|
325 if self.location is not None: |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45898
diff
changeset
|
326 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:
45898
diff
changeset
|
327 pycompat.bytestr(self.location), |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45898
diff
changeset
|
328 self.message, |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45898
diff
changeset
|
329 ) |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45898
diff
changeset
|
330 else: |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45898
diff
changeset
|
331 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:
45898
diff
changeset
|
332 if self.hint: |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45898
diff
changeset
|
333 message += _(b"(%s)\n") % self.hint |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45898
diff
changeset
|
334 return message |
98399dd1b96c
errors: make formatparse() an instance method on ParseError
Martin von Zweigbergk <martinvonz@google.com>
parents:
45898
diff
changeset
|
335 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
336 |
34258
61714510220d
error: move patch.PatchError so it can easily implement __bytes__ (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32639
diff
changeset
|
337 class PatchError(Exception): |
61714510220d
error: move patch.PatchError so it can easily implement __bytes__ (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32639
diff
changeset
|
338 __bytes__ = _tobytes |
61714510220d
error: move patch.PatchError so it can easily implement __bytes__ (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32639
diff
changeset
|
339 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
340 |
45897
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45892
diff
changeset
|
341 def getsimilar(symbols, value): |
46899
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
342 # type: (Iterable[bytes], bytes) -> List[bytes] |
45897
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45892
diff
changeset
|
343 sim = lambda x: difflib.SequenceMatcher(None, value, x).ratio() |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45892
diff
changeset
|
344 # 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:
45892
diff
changeset
|
345 # probably be investigated and tweaked. |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45892
diff
changeset
|
346 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:
45892
diff
changeset
|
347 |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45892
diff
changeset
|
348 |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45892
diff
changeset
|
349 def similarity_hint(similar): |
46899
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
350 # type: (List[bytes]) -> Optional[bytes] |
45897
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45892
diff
changeset
|
351 from .i18n import _ |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45892
diff
changeset
|
352 |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45892
diff
changeset
|
353 if len(similar) == 1: |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45892
diff
changeset
|
354 return _(b"did you mean %s?") % similar[0] |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45892
diff
changeset
|
355 elif similar: |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45892
diff
changeset
|
356 ss = b", ".join(sorted(similar)) |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45892
diff
changeset
|
357 return _(b"did you mean one of %s?") % ss |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45892
diff
changeset
|
358 else: |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45892
diff
changeset
|
359 return None |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45892
diff
changeset
|
360 |
8cc9e7f762d6
errors: move similarity_hint() to error module
Martin von Zweigbergk <martinvonz@google.com>
parents:
45892
diff
changeset
|
361 |
24217
d2b81256db1e
error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents:
24190
diff
changeset
|
362 class UnknownIdentifier(ParseError): |
d2b81256db1e
error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents:
24190
diff
changeset
|
363 """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
|
364 |
d2b81256db1e
error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents:
24190
diff
changeset
|
365 def __init__(self, function, symbols): |
46899
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
366 # type: (bytes, Iterable[bytes]) -> None |
25945
147bd9e238a1
error: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25484
diff
changeset
|
367 from .i18n import _ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
368 |
45898
1817b66897ad
errors: create "similarity hint" for UnknownIdentifier eagerly in constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45897
diff
changeset
|
369 similar = getsimilar(symbols, function) |
1817b66897ad
errors: create "similarity hint" for UnknownIdentifier eagerly in constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45897
diff
changeset
|
370 hint = similarity_hint(similar) |
1817b66897ad
errors: create "similarity hint" for UnknownIdentifier eagerly in constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45897
diff
changeset
|
371 |
1817b66897ad
errors: create "similarity hint" for UnknownIdentifier eagerly in constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45897
diff
changeset
|
372 ParseError.__init__( |
1817b66897ad
errors: create "similarity hint" for UnknownIdentifier eagerly in constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
45897
diff
changeset
|
373 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:
45897
diff
changeset
|
374 ) |
24217
d2b81256db1e
error: add a new UnknownIdentifier error type
Augie Fackler <augie@google.com>
parents:
24190
diff
changeset
|
375 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
376 |
29509
945b4c14c570
error: make HintException a mix-in class not derived from BaseException (API)
Yuya Nishihara <yuya@tcha.org>
parents:
28141
diff
changeset
|
377 class RepoError(Hint, Exception): |
32639
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
378 __bytes__ = _tobytes |
7637 | 379 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
380 |
9423
1444a42f6052
Make distinct lookup error for localrepo.lookup
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
381 class RepoLookupError(RepoError): |
1444a42f6052
Make distinct lookup error for localrepo.lookup
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
382 pass |
1444a42f6052
Make distinct lookup error for localrepo.lookup
Matt Mackall <mpm@selenic.com>
parents:
8227
diff
changeset
|
383 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
384 |
23016
2bd51e61c65e
repoview: add a FilteredRepoLookupError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23015
diff
changeset
|
385 class FilteredRepoLookupError(RepoLookupError): |
2bd51e61c65e
repoview: add a FilteredRepoLookupError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23015
diff
changeset
|
386 pass |
2bd51e61c65e
repoview: add a FilteredRepoLookupError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23015
diff
changeset
|
387 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
388 |
7637 | 389 class CapabilityError(RepoError): |
390 pass | |
7640 | 391 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
392 |
13447
931a72e00efa
introduce new RequirementError (issue2649)
Adrian Buehlmann <adrian@cadifra.com>
parents:
11574
diff
changeset
|
393 class RequirementError(RepoError): |
931a72e00efa
introduce new RequirementError (issue2649)
Adrian Buehlmann <adrian@cadifra.com>
parents:
11574
diff
changeset
|
394 """Exception raised if .hg/requires has an unknown entry.""" |
931a72e00efa
introduce new RequirementError (issue2649)
Adrian Buehlmann <adrian@cadifra.com>
parents:
11574
diff
changeset
|
395 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
396 |
31959
b445a3f00528
stdio: add machinery to identify failed stdout/stderr writes
Bryan O'Sullivan <bryano@fb.com>
parents:
31510
diff
changeset
|
397 class StdioError(IOError): |
b445a3f00528
stdio: add machinery to identify failed stdout/stderr writes
Bryan O'Sullivan <bryano@fb.com>
parents:
31510
diff
changeset
|
398 """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:
31510
diff
changeset
|
399 |
b445a3f00528
stdio: add machinery to identify failed stdout/stderr writes
Bryan O'Sullivan <bryano@fb.com>
parents:
31510
diff
changeset
|
400 def __init__(self, err): |
46899
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
401 # type: (IOError) -> None |
31959
b445a3f00528
stdio: add machinery to identify failed stdout/stderr writes
Bryan O'Sullivan <bryano@fb.com>
parents:
31510
diff
changeset
|
402 IOError.__init__(self, err.errno, err.strerror) |
b445a3f00528
stdio: add machinery to identify failed stdout/stderr writes
Bryan O'Sullivan <bryano@fb.com>
parents:
31510
diff
changeset
|
403 |
32639
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
404 # 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:
32622
diff
changeset
|
405 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
406 |
26985
039a53c87370
error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26896
diff
changeset
|
407 class UnsupportedMergeRecords(Abort): |
039a53c87370
error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26896
diff
changeset
|
408 def __init__(self, recordtypes): |
46899
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
409 # type: (Iterable[bytes]) -> None |
26985
039a53c87370
error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26896
diff
changeset
|
410 from .i18n import _ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
411 |
26985
039a53c87370
error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26896
diff
changeset
|
412 self.recordtypes = sorted(recordtypes) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
413 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
|
414 Abort.__init__( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
415 self, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
416 _(b'unsupported merge state records: %s') % s, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
417 hint=_( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
418 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
|
419 b'more information' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
420 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
421 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
422 |
26985
039a53c87370
error: add a structured exception for unsupported merge records
Siddharth Agarwal <sid0@fb.com>
parents:
26896
diff
changeset
|
423 |
32622
19df975eb555
obsolete: raise richer exception on unknown version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32440
diff
changeset
|
424 class UnknownVersion(Abort): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45930
diff
changeset
|
425 """generic exception for aborting from an encounter with an unknown version""" |
32622
19df975eb555
obsolete: raise richer exception on unknown version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32440
diff
changeset
|
426 |
19df975eb555
obsolete: raise richer exception on unknown version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32440
diff
changeset
|
427 def __init__(self, msg, hint=None, version=None): |
46899
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
428 # type: (bytes, Optional[bytes], Optional[bytes]) -> None |
32622
19df975eb555
obsolete: raise richer exception on unknown version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32440
diff
changeset
|
429 self.version = version |
19df975eb555
obsolete: raise richer exception on unknown version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32440
diff
changeset
|
430 super(UnknownVersion, self).__init__(msg, hint=hint) |
19df975eb555
obsolete: raise richer exception on unknown version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32440
diff
changeset
|
431 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
432 |
7640 | 433 class LockError(IOError): |
434 def __init__(self, errno, strerror, filename, desc): | |
46899
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
435 # TODO: figure out if this should be bytes or str |
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
436 # _type: (int, str, str, bytes) -> None |
7640 | 437 IOError.__init__(self, errno, strerror, filename) |
438 self.desc = desc | |
439 | |
32639
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
440 # 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:
32622
diff
changeset
|
441 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
442 |
7640 | 443 class LockHeld(LockError): |
444 def __init__(self, errno, filename, desc, locker): | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
445 LockError.__init__(self, errno, b'Lock held', filename, desc) |
7640 | 446 self.locker = locker |
447 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
448 |
7640 | 449 class LockUnavailable(LockError): |
450 pass | |
7641
d2f753830f80
error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents:
7640
diff
changeset
|
451 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
452 |
26355
f51713b8c6fa
error: add an exception to indicate lock inheritance API contract violations
Siddharth Agarwal <sid0@fb.com>
parents:
25945
diff
changeset
|
453 # 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
|
454 class LockInheritanceContractViolation(RuntimeError): |
32639
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
455 __bytes__ = _tobytes |
26355
f51713b8c6fa
error: add an exception to indicate lock inheritance API contract violations
Siddharth Agarwal <sid0@fb.com>
parents:
25945
diff
changeset
|
456 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
457 |
7641
d2f753830f80
error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents:
7640
diff
changeset
|
458 class ResponseError(Exception): |
d2f753830f80
error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents:
7640
diff
changeset
|
459 """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
|
460 |
32639
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
461 __bytes__ = _tobytes |
7641
d2f753830f80
error: move UnexpectedOutput (now ResponseError)
Matt Mackall <mpm@selenic.com>
parents:
7640
diff
changeset
|
462 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
463 |
7644
182b7114d35a
error: move SignalInterrupt
Matt Mackall <mpm@selenic.com>
parents:
7643
diff
changeset
|
464 # derived from KeyboardInterrupt to simplify some breakout code |
182b7114d35a
error: move SignalInterrupt
Matt Mackall <mpm@selenic.com>
parents:
7643
diff
changeset
|
465 class SignalInterrupt(KeyboardInterrupt): |
182b7114d35a
error: move SignalInterrupt
Matt Mackall <mpm@selenic.com>
parents:
7643
diff
changeset
|
466 """Exception raised on SIGTERM and SIGHUP.""" |
7646 | 467 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
468 |
7646 | 469 class SignatureError(Exception): |
32639
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
470 __bytes__ = _tobytes |
21184
28d76afa1568
bundle2: fix raising errors during heads checking
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
18931
diff
changeset
|
471 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
472 |
21184
28d76afa1568
bundle2: fix raising errors during heads checking
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
18931
diff
changeset
|
473 class PushRaced(RuntimeError): |
28d76afa1568
bundle2: fix raising errors during heads checking
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
18931
diff
changeset
|
474 """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
|
475 |
32639
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
476 __bytes__ = _tobytes |
21184
28d76afa1568
bundle2: fix raising errors during heads checking
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
18931
diff
changeset
|
477 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
478 |
32379
9c023179e8d0
error: add hint to ProgrammingError
Yuya Nishihara <yuya@tcha.org>
parents:
32023
diff
changeset
|
479 class ProgrammingError(Hint, RuntimeError): |
30590
0f865311ae3f
error: make it clear that ProgrammingError is for mercurial developers
Jun Wu <quark@fb.com>
parents:
30578
diff
changeset
|
480 """Raised if a mercurial (core or extension) developer made a mistake""" |
39595
921aeb9ac508
error: ensure ProgrammingError message is always a str
Augie Fackler <augie@google.com>
parents:
39575
diff
changeset
|
481 |
921aeb9ac508
error: ensure ProgrammingError message is always a str
Augie Fackler <augie@google.com>
parents:
39575
diff
changeset
|
482 def __init__(self, msg, *args, **kwargs): |
46899
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
483 # type: (AnyStr, Any, Any) -> None |
39612
409c42d6a570
py3: use sysstr() to convert ProgrammingError bytes with no unicode error risk
Yuya Nishihara <yuya@tcha.org>
parents:
39595
diff
changeset
|
484 # 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:
39595
diff
changeset
|
485 # 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:
39595
diff
changeset
|
486 # stack traces. |
409c42d6a570
py3: use sysstr() to convert ProgrammingError bytes with no unicode error risk
Yuya Nishihara <yuya@tcha.org>
parents:
39595
diff
changeset
|
487 msg = pycompat.sysstr(msg) |
39595
921aeb9ac508
error: ensure ProgrammingError message is always a str
Augie Fackler <augie@google.com>
parents:
39575
diff
changeset
|
488 super(ProgrammingError, self).__init__(msg, *args, **kwargs) |
921aeb9ac508
error: ensure ProgrammingError message is always a str
Augie Fackler <augie@google.com>
parents:
39575
diff
changeset
|
489 |
32639
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
490 __bytes__ = _tobytes |
30578 | 491 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
492 |
32440
c8e10565a113
error: add a new exception named WdirUnsupported
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32379
diff
changeset
|
493 class WdirUnsupported(Exception): |
c8e10565a113
error: add a new exception named WdirUnsupported
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32379
diff
changeset
|
494 """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
|
495 |
32639
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
496 __bytes__ = _tobytes |
32440
c8e10565a113
error: add a new exception named WdirUnsupported
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32379
diff
changeset
|
497 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
498 |
21618
7568f5c1c801
bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
499 # bundle2 related errors |
7568f5c1c801
bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
500 class BundleValueError(ValueError): |
21621
b6eb56a9335d
bundle2: introduce a ``params`` attribute to BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21620
diff
changeset
|
501 """error raised when bundle2 cannot be processed""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
502 |
32639
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
503 __bytes__ = _tobytes |
21620
6eaa71b2a3cc
bundle2: introduce a parttype attribute to BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21618
diff
changeset
|
504 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
505 |
26393
cff70549a959
bundle2: rename error exception class for unsupported feature
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26355
diff
changeset
|
506 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
|
507 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
|
508 self.parttype = parttype |
21621
b6eb56a9335d
bundle2: introduce a ``params`` attribute to BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21620
diff
changeset
|
509 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
|
510 self.values = values |
21627
3e8bcc90f07c
bundle2: support None parttype in BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21621
diff
changeset
|
511 if self.parttype is None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
512 msg = b'Stream Parameter' |
21627
3e8bcc90f07c
bundle2: support None parttype in BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21621
diff
changeset
|
513 else: |
3e8bcc90f07c
bundle2: support None parttype in BundleValueError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21621
diff
changeset
|
514 msg = parttype |
26394
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
515 entries = self.params |
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
516 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
|
517 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
|
518 entries = [] |
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
519 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
|
520 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
|
521 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
|
522 entries.append(val) |
e75da738add5
bundle2: allow to specify unsupported value on error
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26393
diff
changeset
|
523 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
524 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
|
525 if entries: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
526 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
|
527 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
|
528 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
529 |
21618
7568f5c1c801
bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
530 class ReadOnlyPartError(RuntimeError): |
7568f5c1c801
bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
531 """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
|
532 |
32639
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
533 __bytes__ = _tobytes |
21618
7568f5c1c801
bundle2: move exception classes into the error module
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21184
diff
changeset
|
534 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
535 |
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
|
536 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
|
537 """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
|
538 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
539 def __init__( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
540 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
|
541 ): |
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
|
542 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
|
543 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
|
544 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
|
545 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
|
546 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
|
547 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
|
548 # 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
|
549 Abort.__init__( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
550 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
|
551 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
552 |
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
|
553 |
39793
b63dee7bd0d9
global: replace most uses of RevlogError with StorageError (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39792
diff
changeset
|
554 class CensoredNodeError(StorageError): |
24190
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24137
diff
changeset
|
555 """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
|
556 |
24190
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24137
diff
changeset
|
557 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
|
558 """ |
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24137
diff
changeset
|
559 |
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24137
diff
changeset
|
560 def __init__(self, filename, node, tombstone): |
46899
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
561 # type: (bytes, bytes, bytes) -> None |
25945
147bd9e238a1
error: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25484
diff
changeset
|
562 from .node import short |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
563 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
564 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
|
565 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
|
566 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
567 |
39793
b63dee7bd0d9
global: replace most uses of RevlogError with StorageError (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39792
diff
changeset
|
568 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
|
569 """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
|
570 |
a450e0a2ba0a
revlog: in addgroup, reject ill-formed deltas based on censored nodes
Mike Edgar <adgar@google.com>
parents:
24040
diff
changeset
|
571 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
|
572 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
|
573 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
|
574 """ |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
575 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
576 |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
577 class InvalidBundleSpecification(Exception): |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
578 """error raised when a bundle specification is invalid. |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
579 |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
580 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
|
581 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
582 |
32639
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
583 __bytes__ = _tobytes |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
584 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
585 |
26640
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
586 class UnsupportedBundleSpecification(Exception): |
b13fdcc4e700
exchange: refactor bundle specification parsing
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26438
diff
changeset
|
587 """error raised when a bundle specification is not supported.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
588 |
32639
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
589 __bytes__ = _tobytes |
29536
b17a6e3cd2ac
shelve: make unshelve be able to abort in any case
Kostia Balytskyi <ikostia@fb.com>
parents:
29510
diff
changeset
|
590 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
591 |
29536
b17a6e3cd2ac
shelve: make unshelve be able to abort in any case
Kostia Balytskyi <ikostia@fb.com>
parents:
29510
diff
changeset
|
592 class CorruptedState(Exception): |
b17a6e3cd2ac
shelve: make unshelve be able to abort in any case
Kostia Balytskyi <ikostia@fb.com>
parents:
29510
diff
changeset
|
593 """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
|
594 |
32639
6df193b5c437
py3: implement __bytes__() on most of our exception classes
Yuya Nishihara <yuya@tcha.org>
parents:
32622
diff
changeset
|
595 __bytes__ = _tobytes |
32002
bf855efe5664
httppeer: wrap HTTPResponse.read() globally
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31959
diff
changeset
|
596 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
597 |
32023
a29580905771
error: rename RichIOError to PeerTransportError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32002
diff
changeset
|
598 class PeerTransportError(Abort): |
a29580905771
error: rename RichIOError to PeerTransportError
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32002
diff
changeset
|
599 """Transport-level I/O error when communicating with a peer repo.""" |
35128
795bfa2a9103
error: add InMemoryMergeConflictsError
Phil Cohen <phillco@fb.com>
parents:
34258
diff
changeset
|
600 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
601 |
35128
795bfa2a9103
error: add InMemoryMergeConflictsError
Phil Cohen <phillco@fb.com>
parents:
34258
diff
changeset
|
602 class InMemoryMergeConflictsError(Exception): |
795bfa2a9103
error: add InMemoryMergeConflictsError
Phil Cohen <phillco@fb.com>
parents:
34258
diff
changeset
|
603 """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
|
604 |
35128
795bfa2a9103
error: add InMemoryMergeConflictsError
Phil Cohen <phillco@fb.com>
parents:
34258
diff
changeset
|
605 __bytes__ = _tobytes |
39575
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38880
diff
changeset
|
606 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
607 |
39575
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38880
diff
changeset
|
608 class WireprotoCommandError(Exception): |
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38880
diff
changeset
|
609 """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:
38880
diff
changeset
|
610 |
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38880
diff
changeset
|
611 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:
38880
diff
changeset
|
612 |
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38880
diff
changeset
|
613 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:
38880
diff
changeset
|
614 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43034
diff
changeset
|
615 |
39575
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38880
diff
changeset
|
616 def __init__(self, message, args=None): |
46899
8b6e36e4b553
typing: add type hints to mercurial/error.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
46819
diff
changeset
|
617 # type: (bytes, Optional[Sequence[bytes]]) -> None |
39575
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38880
diff
changeset
|
618 self.message = message |
07b58266bce3
wireprotov2: implement commands as a generator of objects
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38880
diff
changeset
|
619 self.messageargs = args |