Show More
@@ -1,171 +1,171 b'' | |||||
1 | # error.py - Mercurial exceptions |
|
1 | # error.py - Mercurial exceptions | |
2 | # |
|
2 | # | |
3 | # Copyright 2005-2008 Matt Mackall <mpm@selenic.com> |
|
3 | # Copyright 2005-2008 Matt Mackall <mpm@selenic.com> | |
4 | # |
|
4 | # | |
5 | # This software may be used and distributed according to the terms of the |
|
5 | # This software may be used and distributed according to the terms of the | |
6 | # GNU General Public License version 2 or any later version. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
|
7 | |||
8 | """Mercurial exceptions. |
|
8 | """Mercurial exceptions. | |
9 |
|
9 | |||
10 | This allows us to catch exceptions at higher levels without forcing |
|
10 | This allows us to catch exceptions at higher levels without forcing | |
11 | imports. |
|
11 | imports. | |
12 | """ |
|
12 | """ | |
13 |
|
13 | |||
14 | # Do not import anything here, please |
|
14 | # Do not import anything here, please | |
15 |
|
15 | |||
16 | class HintException(Exception): |
|
16 | class HintException(Exception): | |
17 | def __init__(self, *args, **kw): |
|
17 | def __init__(self, *args, **kw): | |
18 | Exception.__init__(self, *args) |
|
18 | Exception.__init__(self, *args) | |
19 | self.hint = kw.get('hint') |
|
19 | self.hint = kw.get('hint') | |
20 |
|
20 | |||
21 | class RevlogError(Exception): |
|
21 | class RevlogError(HintException): | |
22 | pass |
|
22 | pass | |
23 |
|
23 | |||
24 | class FilteredIndexError(IndexError): |
|
24 | class FilteredIndexError(IndexError): | |
25 | pass |
|
25 | pass | |
26 |
|
26 | |||
27 | class LookupError(RevlogError, KeyError): |
|
27 | class LookupError(RevlogError, KeyError): | |
28 | def __init__(self, name, index, message): |
|
28 | def __init__(self, name, index, message): | |
29 | self.name = name |
|
29 | self.name = name | |
30 | self.index = index |
|
30 | self.index = index | |
31 | # this can't be called 'message' because at least some installs of |
|
31 | # this can't be called 'message' because at least some installs of | |
32 | # Python 2.6+ complain about the 'message' property being deprecated |
|
32 | # Python 2.6+ complain about the 'message' property being deprecated | |
33 | self.lookupmessage = message |
|
33 | self.lookupmessage = message | |
34 | if isinstance(name, str) and len(name) == 20: |
|
34 | if isinstance(name, str) and len(name) == 20: | |
35 | from node import short |
|
35 | from node import short | |
36 | name = short(name) |
|
36 | name = short(name) | |
37 | RevlogError.__init__(self, '%s@%s: %s' % (index, name, message)) |
|
37 | RevlogError.__init__(self, '%s@%s: %s' % (index, name, message)) | |
38 |
|
38 | |||
39 | def __str__(self): |
|
39 | def __str__(self): | |
40 | return RevlogError.__str__(self) |
|
40 | return RevlogError.__str__(self) | |
41 |
|
41 | |||
42 | class FilteredLookupError(LookupError): |
|
42 | class FilteredLookupError(LookupError): | |
43 | pass |
|
43 | pass | |
44 |
|
44 | |||
45 | class ManifestLookupError(LookupError): |
|
45 | class ManifestLookupError(LookupError): | |
46 | pass |
|
46 | pass | |
47 |
|
47 | |||
48 | class CommandError(Exception): |
|
48 | class CommandError(Exception): | |
49 | """Exception raised on errors in parsing the command line.""" |
|
49 | """Exception raised on errors in parsing the command line.""" | |
50 |
|
50 | |||
51 | class InterventionRequired(Exception): |
|
51 | class InterventionRequired(Exception): | |
52 | """Exception raised when a command requires human intervention.""" |
|
52 | """Exception raised when a command requires human intervention.""" | |
53 |
|
53 | |||
54 | class Abort(HintException): |
|
54 | class Abort(HintException): | |
55 | """Raised if a command needs to print an error and exit.""" |
|
55 | """Raised if a command needs to print an error and exit.""" | |
56 | pass |
|
56 | pass | |
57 |
|
57 | |||
58 | class HookAbort(Abort): |
|
58 | class HookAbort(Abort): | |
59 | """raised when a validation hook fails, aborting an operation |
|
59 | """raised when a validation hook fails, aborting an operation | |
60 |
|
60 | |||
61 | Exists to allow more specialized catching.""" |
|
61 | Exists to allow more specialized catching.""" | |
62 | pass |
|
62 | pass | |
63 |
|
63 | |||
64 | class ConfigError(Abort): |
|
64 | class ConfigError(Abort): | |
65 | """Exception raised when parsing config files""" |
|
65 | """Exception raised when parsing config files""" | |
66 |
|
66 | |||
67 | class OutOfBandError(Exception): |
|
67 | class OutOfBandError(Exception): | |
68 | """Exception raised when a remote repo reports failure""" |
|
68 | """Exception raised when a remote repo reports failure""" | |
69 |
|
69 | |||
70 | def __init__(self, *args, **kw): |
|
70 | def __init__(self, *args, **kw): | |
71 | Exception.__init__(self, *args) |
|
71 | Exception.__init__(self, *args) | |
72 | self.hint = kw.get('hint') |
|
72 | self.hint = kw.get('hint') | |
73 |
|
73 | |||
74 | class ParseError(Exception): |
|
74 | class ParseError(Exception): | |
75 | """Raised when parsing config files and {rev,file}sets (msg[, pos])""" |
|
75 | """Raised when parsing config files and {rev,file}sets (msg[, pos])""" | |
76 |
|
76 | |||
77 | class UnknownIdentifier(ParseError): |
|
77 | class UnknownIdentifier(ParseError): | |
78 | """Exception raised when a {rev,file}set references an unknown identifier""" |
|
78 | """Exception raised when a {rev,file}set references an unknown identifier""" | |
79 |
|
79 | |||
80 | def __init__(self, function, symbols): |
|
80 | def __init__(self, function, symbols): | |
81 | from i18n import _ |
|
81 | from i18n import _ | |
82 | ParseError.__init__(self, _("unknown identifier: %s") % function) |
|
82 | ParseError.__init__(self, _("unknown identifier: %s") % function) | |
83 | self.function = function |
|
83 | self.function = function | |
84 | self.symbols = symbols |
|
84 | self.symbols = symbols | |
85 |
|
85 | |||
86 | class RepoError(HintException): |
|
86 | class RepoError(HintException): | |
87 | pass |
|
87 | pass | |
88 |
|
88 | |||
89 | class RepoLookupError(RepoError): |
|
89 | class RepoLookupError(RepoError): | |
90 | pass |
|
90 | pass | |
91 |
|
91 | |||
92 | class FilteredRepoLookupError(RepoLookupError): |
|
92 | class FilteredRepoLookupError(RepoLookupError): | |
93 | pass |
|
93 | pass | |
94 |
|
94 | |||
95 | class CapabilityError(RepoError): |
|
95 | class CapabilityError(RepoError): | |
96 | pass |
|
96 | pass | |
97 |
|
97 | |||
98 | class RequirementError(RepoError): |
|
98 | class RequirementError(RepoError): | |
99 | """Exception raised if .hg/requires has an unknown entry.""" |
|
99 | """Exception raised if .hg/requires has an unknown entry.""" | |
100 | pass |
|
100 | pass | |
101 |
|
101 | |||
102 | class LockError(IOError): |
|
102 | class LockError(IOError): | |
103 | def __init__(self, errno, strerror, filename, desc): |
|
103 | def __init__(self, errno, strerror, filename, desc): | |
104 | IOError.__init__(self, errno, strerror, filename) |
|
104 | IOError.__init__(self, errno, strerror, filename) | |
105 | self.desc = desc |
|
105 | self.desc = desc | |
106 |
|
106 | |||
107 | class LockHeld(LockError): |
|
107 | class LockHeld(LockError): | |
108 | def __init__(self, errno, filename, desc, locker): |
|
108 | def __init__(self, errno, filename, desc, locker): | |
109 | LockError.__init__(self, errno, 'Lock held', filename, desc) |
|
109 | LockError.__init__(self, errno, 'Lock held', filename, desc) | |
110 | self.locker = locker |
|
110 | self.locker = locker | |
111 |
|
111 | |||
112 | class LockUnavailable(LockError): |
|
112 | class LockUnavailable(LockError): | |
113 | pass |
|
113 | pass | |
114 |
|
114 | |||
115 | class ResponseError(Exception): |
|
115 | class ResponseError(Exception): | |
116 | """Raised to print an error with part of output and exit.""" |
|
116 | """Raised to print an error with part of output and exit.""" | |
117 |
|
117 | |||
118 | class UnknownCommand(Exception): |
|
118 | class UnknownCommand(Exception): | |
119 | """Exception raised if command is not in the command table.""" |
|
119 | """Exception raised if command is not in the command table.""" | |
120 |
|
120 | |||
121 | class AmbiguousCommand(Exception): |
|
121 | class AmbiguousCommand(Exception): | |
122 | """Exception raised if command shortcut matches more than one command.""" |
|
122 | """Exception raised if command shortcut matches more than one command.""" | |
123 |
|
123 | |||
124 | # derived from KeyboardInterrupt to simplify some breakout code |
|
124 | # derived from KeyboardInterrupt to simplify some breakout code | |
125 | class SignalInterrupt(KeyboardInterrupt): |
|
125 | class SignalInterrupt(KeyboardInterrupt): | |
126 | """Exception raised on SIGTERM and SIGHUP.""" |
|
126 | """Exception raised on SIGTERM and SIGHUP.""" | |
127 |
|
127 | |||
128 | class SignatureError(Exception): |
|
128 | class SignatureError(Exception): | |
129 | pass |
|
129 | pass | |
130 |
|
130 | |||
131 | class PushRaced(RuntimeError): |
|
131 | class PushRaced(RuntimeError): | |
132 | """An exception raised during unbundling that indicate a push race""" |
|
132 | """An exception raised during unbundling that indicate a push race""" | |
133 |
|
133 | |||
134 | # bundle2 related errors |
|
134 | # bundle2 related errors | |
135 | class BundleValueError(ValueError): |
|
135 | class BundleValueError(ValueError): | |
136 | """error raised when bundle2 cannot be processed""" |
|
136 | """error raised when bundle2 cannot be processed""" | |
137 |
|
137 | |||
138 | class UnsupportedPartError(BundleValueError): |
|
138 | class UnsupportedPartError(BundleValueError): | |
139 | def __init__(self, parttype=None, params=()): |
|
139 | def __init__(self, parttype=None, params=()): | |
140 | self.parttype = parttype |
|
140 | self.parttype = parttype | |
141 | self.params = params |
|
141 | self.params = params | |
142 | if self.parttype is None: |
|
142 | if self.parttype is None: | |
143 | msg = 'Stream Parameter' |
|
143 | msg = 'Stream Parameter' | |
144 | else: |
|
144 | else: | |
145 | msg = parttype |
|
145 | msg = parttype | |
146 | if self.params: |
|
146 | if self.params: | |
147 | msg = '%s - %s' % (msg, ', '.join(self.params)) |
|
147 | msg = '%s - %s' % (msg, ', '.join(self.params)) | |
148 | ValueError.__init__(self, msg) |
|
148 | ValueError.__init__(self, msg) | |
149 |
|
149 | |||
150 | class ReadOnlyPartError(RuntimeError): |
|
150 | class ReadOnlyPartError(RuntimeError): | |
151 | """error raised when code tries to alter a part being generated""" |
|
151 | """error raised when code tries to alter a part being generated""" | |
152 | pass |
|
152 | pass | |
153 |
|
153 | |||
154 | class CensoredNodeError(RevlogError): |
|
154 | class CensoredNodeError(RevlogError): | |
155 | """error raised when content verification fails on a censored node |
|
155 | """error raised when content verification fails on a censored node | |
156 |
|
156 | |||
157 | Also contains the tombstone data substituted for the uncensored data. |
|
157 | Also contains the tombstone data substituted for the uncensored data. | |
158 | """ |
|
158 | """ | |
159 |
|
159 | |||
160 | def __init__(self, filename, node, tombstone): |
|
160 | def __init__(self, filename, node, tombstone): | |
161 | from node import short |
|
161 | from node import short | |
162 | RevlogError.__init__(self, '%s:%s' % (filename, short(node))) |
|
162 | RevlogError.__init__(self, '%s:%s' % (filename, short(node))) | |
163 | self.tombstone = tombstone |
|
163 | self.tombstone = tombstone | |
164 |
|
164 | |||
165 | class CensoredBaseError(RevlogError): |
|
165 | class CensoredBaseError(RevlogError): | |
166 | """error raised when a delta is rejected because its base is censored |
|
166 | """error raised when a delta is rejected because its base is censored | |
167 |
|
167 | |||
168 | A delta based on a censored revision must be formed as single patch |
|
168 | A delta based on a censored revision must be formed as single patch | |
169 | operation which replaces the entire base with new content. This ensures |
|
169 | operation which replaces the entire base with new content. This ensures | |
170 | the delta may be applied by clones which have not censored the base. |
|
170 | the delta may be applied by clones which have not censored the base. | |
171 | """ |
|
171 | """ |
General Comments 0
You need to be logged in to leave comments.
Login now