##// END OF EJS Templates
error: make lock inheritance contract violations a subclass of RuntimeError...
Siddharth Agarwal -
r26438:024644b1 default
parent child Browse files
Show More
@@ -1,203 +1,203
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 HintException(Exception):
19 19 def __init__(self, *args, **kw):
20 20 Exception.__init__(self, *args)
21 21 self.hint = kw.get('hint')
22 22
23 23 class RevlogError(HintException):
24 24 pass
25 25
26 26 class FilteredIndexError(IndexError):
27 27 pass
28 28
29 29 class LookupError(RevlogError, KeyError):
30 30 def __init__(self, name, index, message):
31 31 self.name = name
32 32 self.index = index
33 33 # this can't be called 'message' because at least some installs of
34 34 # Python 2.6+ complain about the 'message' property being deprecated
35 35 self.lookupmessage = message
36 36 if isinstance(name, str) and len(name) == 20:
37 37 from .node import short
38 38 name = short(name)
39 39 RevlogError.__init__(self, '%s@%s: %s' % (index, name, message))
40 40
41 41 def __str__(self):
42 42 return RevlogError.__str__(self)
43 43
44 44 class FilteredLookupError(LookupError):
45 45 pass
46 46
47 47 class ManifestLookupError(LookupError):
48 48 pass
49 49
50 50 class CommandError(Exception):
51 51 """Exception raised on errors in parsing the command line."""
52 52
53 53 class InterventionRequired(Exception):
54 54 """Exception raised when a command requires human intervention."""
55 55
56 56 class Abort(HintException):
57 57 """Raised if a command needs to print an error and exit."""
58 58 pass
59 59
60 60 class HookAbort(Abort):
61 61 """raised when a validation hook fails, aborting an operation
62 62
63 63 Exists to allow more specialized catching."""
64 64 pass
65 65
66 66 class ConfigError(Abort):
67 67 """Exception raised when parsing config files"""
68 68
69 69 class OutOfBandError(Exception):
70 70 """Exception raised when a remote repo reports failure"""
71 71
72 72 def __init__(self, *args, **kw):
73 73 Exception.__init__(self, *args)
74 74 self.hint = kw.get('hint')
75 75
76 76 class ParseError(Exception):
77 77 """Raised when parsing config files and {rev,file}sets (msg[, pos])"""
78 78
79 79 class UnknownIdentifier(ParseError):
80 80 """Exception raised when a {rev,file}set references an unknown identifier"""
81 81
82 82 def __init__(self, function, symbols):
83 83 from .i18n import _
84 84 ParseError.__init__(self, _("unknown identifier: %s") % function)
85 85 self.function = function
86 86 self.symbols = symbols
87 87
88 88 class RepoError(HintException):
89 89 pass
90 90
91 91 class RepoLookupError(RepoError):
92 92 pass
93 93
94 94 class FilteredRepoLookupError(RepoLookupError):
95 95 pass
96 96
97 97 class CapabilityError(RepoError):
98 98 pass
99 99
100 100 class RequirementError(RepoError):
101 101 """Exception raised if .hg/requires has an unknown entry."""
102 102 pass
103 103
104 104 class LockError(IOError):
105 105 def __init__(self, errno, strerror, filename, desc):
106 106 IOError.__init__(self, errno, strerror, filename)
107 107 self.desc = desc
108 108
109 109 class LockHeld(LockError):
110 110 def __init__(self, errno, filename, desc, locker):
111 111 LockError.__init__(self, errno, 'Lock held', filename, desc)
112 112 self.locker = locker
113 113
114 114 class LockUnavailable(LockError):
115 115 pass
116 116
117 117 # LockError is for errors while acquiring the lock -- this is unrelated
118 class LockInheritanceContractViolation(AssertionError):
118 class LockInheritanceContractViolation(RuntimeError):
119 119 pass
120 120
121 121 class ResponseError(Exception):
122 122 """Raised to print an error with part of output and exit."""
123 123
124 124 class UnknownCommand(Exception):
125 125 """Exception raised if command is not in the command table."""
126 126
127 127 class AmbiguousCommand(Exception):
128 128 """Exception raised if command shortcut matches more than one command."""
129 129
130 130 # derived from KeyboardInterrupt to simplify some breakout code
131 131 class SignalInterrupt(KeyboardInterrupt):
132 132 """Exception raised on SIGTERM and SIGHUP."""
133 133
134 134 class SignatureError(Exception):
135 135 pass
136 136
137 137 class PushRaced(RuntimeError):
138 138 """An exception raised during unbundling that indicate a push race"""
139 139
140 140 # bundle2 related errors
141 141 class BundleValueError(ValueError):
142 142 """error raised when bundle2 cannot be processed"""
143 143
144 144 class BundleUnknownFeatureError(BundleValueError):
145 145 def __init__(self, parttype=None, params=(), values=()):
146 146 self.parttype = parttype
147 147 self.params = params
148 148 self.values = values
149 149 if self.parttype is None:
150 150 msg = 'Stream Parameter'
151 151 else:
152 152 msg = parttype
153 153 entries = self.params
154 154 if self.params and self.values:
155 155 assert len(self.params) == len(self.values)
156 156 entries = []
157 157 for idx, par in enumerate(self.params):
158 158 val = self.values[idx]
159 159 if val is None:
160 160 entries.append(val)
161 161 else:
162 162 entries.append("%s=%r" % (par, val))
163 163 if entries:
164 164 msg = '%s - %s' % (msg, ', '.join(entries))
165 165 ValueError.__init__(self, msg)
166 166
167 167 class ReadOnlyPartError(RuntimeError):
168 168 """error raised when code tries to alter a part being generated"""
169 169 pass
170 170
171 171 class PushkeyFailed(Abort):
172 172 """error raised when a pushkey part failed to update a value"""
173 173
174 174 def __init__(self, partid, namespace=None, key=None, new=None, old=None,
175 175 ret=None):
176 176 self.partid = partid
177 177 self.namespace = namespace
178 178 self.key = key
179 179 self.new = new
180 180 self.old = old
181 181 self.ret = ret
182 182 # no i18n expected to be processed into a better message
183 183 Abort.__init__(self, 'failed to update value for "%s/%s"'
184 184 % (namespace, key))
185 185
186 186 class CensoredNodeError(RevlogError):
187 187 """error raised when content verification fails on a censored node
188 188
189 189 Also contains the tombstone data substituted for the uncensored data.
190 190 """
191 191
192 192 def __init__(self, filename, node, tombstone):
193 193 from .node import short
194 194 RevlogError.__init__(self, '%s:%s' % (filename, short(node)))
195 195 self.tombstone = tombstone
196 196
197 197 class CensoredBaseError(RevlogError):
198 198 """error raised when a delta is rejected because its base is censored
199 199
200 200 A delta based on a censored revision must be formed as single patch
201 201 operation which replaces the entire base with new content. This ensures
202 202 the delta may be applied by clones which have not censored the base.
203 203 """
General Comments 0
You need to be logged in to leave comments. Login now