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