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