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