/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
101
101
        try:
102
102
            fmt = self._get_format_string()
103
103
            if fmt:
104
 
                s = fmt % self.__dict__
 
104
                d = dict(self.__dict__)
 
105
                # special case: python2.5 puts the 'message' attribute in a
 
106
                # slot, so it isn't seen in __dict__
 
107
                d['message'] = getattr(self, 'message', 'no message')
 
108
                s = fmt % d
105
109
                # __str__() should always return a 'str' object
106
110
                # never a 'unicode' object.
107
111
                if isinstance(s, unicode):
132
136
               )
133
137
 
134
138
 
 
139
class InternalBzrError(BzrError):
 
140
    """Base class for errors that are internal in nature.
 
141
 
 
142
    This is a convenience class for errors that are internal. The
 
143
    internal_error attribute can still be altered in subclasses, if needed.
 
144
    Using this class is simply an easy way to get internal errors.
 
145
    """
 
146
 
 
147
    internal_error = True
 
148
 
 
149
 
135
150
class BzrNewError(BzrError):
136
151
    """Deprecated error base class."""
137
152
    # base classes should override the docstring with their human-
170
185
    _fmt = "The tree builder is already building a tree."
171
186
 
172
187
 
173
 
class BzrCheckError(BzrError):
 
188
class BzrCheckError(InternalBzrError):
174
189
    
175
190
    _fmt = "Internal check failed: %(message)s"
176
191
 
177
 
    internal_error = True
178
 
 
179
192
    def __init__(self, message):
180
193
        BzrError.__init__(self)
181
194
        self.message = message
182
195
 
183
196
 
184
 
class DisabledMethod(BzrError):
 
197
class DisabledMethod(InternalBzrError):
185
198
 
186
199
    _fmt = "The smart server method '%(class_name)s' is disabled."
187
200
 
188
 
    internal_error = True
189
 
 
190
201
    def __init__(self, class_name):
191
202
        BzrError.__init__(self)
192
203
        self.class_name = class_name
213
224
        self.transport = transport
214
225
 
215
226
 
216
 
class InvalidEntryName(BzrError):
 
227
class InvalidEntryName(InternalBzrError):
217
228
    
218
229
    _fmt = "Invalid entry name: %(name)s"
219
230
 
220
 
    internal_error = True
221
 
 
222
231
    def __init__(self, name):
223
232
        BzrError.__init__(self)
224
233
        self.name = name
279
288
        BzrError.__init__(self, repository=repository, file_id=file_id)
280
289
 
281
290
 
282
 
class InventoryModified(BzrError):
 
291
class InventoryModified(InternalBzrError):
283
292
 
284
293
    _fmt = ("The current inventory for the tree %(tree)r has been modified,"
285
294
            " so a clean inventory cannot be read without data loss.")
286
295
 
287
 
    internal_error = True
288
 
 
289
296
    def __init__(self, tree):
290
297
        self.tree = tree
291
298
 
312
319
        self.url = url
313
320
 
314
321
 
315
 
class WorkingTreeAlreadyPopulated(BzrError):
 
322
class WorkingTreeAlreadyPopulated(InternalBzrError):
316
323
 
317
324
    _fmt = 'Working tree already populated in "%(base)s"'
318
325
 
319
 
    internal_error = True
320
 
 
321
326
    def __init__(self, base):
322
327
        self.base = base
323
328
 
 
329
 
324
330
class BzrCommandError(BzrError):
325
331
    """Error from user command"""
326
332
 
327
 
    internal_error = False
328
 
 
329
333
    # Error from malformed user command; please avoid raising this as a
330
334
    # generic exception not caused by user input.
331
335
    #
487
491
    _fmt = 'Directory not empty: "%(path)s"%(extra)s'
488
492
 
489
493
 
490
 
class ReadingCompleted(BzrError):
 
494
class ReadingCompleted(InternalBzrError):
491
495
    
492
496
    _fmt = ("The MediumRequest '%(request)s' has already had finish_reading "
493
497
            "called upon it - the request has been completed and no more "
494
498
            "data may be read.")
495
499
 
496
 
    internal_error = True
497
 
 
498
500
    def __init__(self, request):
499
501
        self.request = request
500
502
 
776
778
    _fmt = 'Cannot operate on "%(filename)s" because it is a control file'
777
779
 
778
780
 
779
 
class LockError(BzrError):
 
781
class LockError(InternalBzrError):
780
782
 
781
783
    _fmt = "Lock error: %(msg)s"
782
784
 
783
 
    internal_error = True
784
 
 
785
785
    # All exceptions from the lock/unlock functions should be from
786
786
    # this exception class.  They will be translated as necessary. The
787
787
    # original exception is available as e.original_error
789
789
    # New code should prefer to raise specific subclasses
790
790
    def __init__(self, message):
791
791
        # Python 2.5 uses a slot for StandardError.message,
792
 
        # so use a different variable name
793
 
        # so it is exposed in self.__dict__
 
792
        # so use a different variable name.  We now work around this in
 
793
        # BzrError.__str__, but this member name is kept for compatability.
794
794
        self.msg = message
795
795
 
796
796
 
924
924
 
925
925
    _fmt = "The object %(obj)s does not support token specifying a token when locking."
926
926
 
927
 
    internal_error = True
928
 
 
929
927
    def __init__(self, obj):
930
928
        self.obj = obj
931
929
 
981
979
    _fmt = "Commit refused because there are unknowns in the tree."
982
980
 
983
981
 
984
 
class NoSuchRevision(BzrError):
 
982
class NoSuchRevision(InternalBzrError):
985
983
 
986
984
    _fmt = "%(branch)s has no revision %(revision)s"
987
985
 
988
 
    internal_error = True
989
 
 
990
986
    def __init__(self, branch, revision):
991
987
        # 'branch' may sometimes be an internal object like a KnitRevisionStore
992
988
        BzrError.__init__(self, branch=branch, revision=revision)
993
989
 
994
990
 
995
991
# zero_ninetyone: this exception is no longer raised and should be removed
996
 
class NotLeftParentDescendant(BzrError):
 
992
class NotLeftParentDescendant(InternalBzrError):
997
993
 
998
994
    _fmt = ("Revision %(old_revision)s is not the left parent of"
999
995
            " %(new_revision)s, but branch %(branch_location)s expects this")
1000
996
 
1001
 
    internal_error = True
1002
 
 
1003
997
    def __init__(self, branch, old_revision, new_revision):
1004
998
        BzrError.__init__(self, branch_location=branch.base,
1005
999
                          old_revision=old_revision,
1065
1059
    _fmt = ("These branches have diverged."
1066
1060
            " Use the merge command to reconcile them.")
1067
1061
 
1068
 
    internal_error = False
1069
 
 
1070
1062
    def __init__(self, branch1, branch2):
1071
1063
        self.branch1 = branch1
1072
1064
        self.branch2 = branch2
1073
1065
 
1074
1066
 
1075
 
class NotLefthandHistory(BzrError):
 
1067
class NotLefthandHistory(InternalBzrError):
1076
1068
 
1077
1069
    _fmt = "Supplied history does not follow left-hand parents"
1078
1070
 
1079
 
    internal_error = True
1080
 
 
1081
1071
    def __init__(self, history):
1082
1072
        BzrError.__init__(self, history=history)
1083
1073
 
1087
1077
    _fmt = ("Branches have no common ancestor, and"
1088
1078
            " no merge base revision was specified.")
1089
1079
 
1090
 
    internal_error = False
1091
 
 
1092
1080
 
1093
1081
class NoCommonAncestor(BzrError):
1094
1082
    
1305
1293
    _fmt = "Text did not match its checksum: %(message)s"
1306
1294
 
1307
1295
 
1308
 
class KnitError(BzrError):
 
1296
class KnitError(InternalBzrError):
1309
1297
    
1310
1298
    _fmt = "Knit error"
1311
1299
 
1312
 
    internal_error = True
1313
 
 
1314
1300
 
1315
1301
class KnitCorrupt(KnitError):
1316
1302
 
1380
1366
        BzrError.__init__(self)
1381
1367
 
1382
1368
 
1383
 
class TooManyConcurrentRequests(BzrError):
 
1369
class TooManyConcurrentRequests(InternalBzrError):
1384
1370
 
1385
1371
    _fmt = ("The medium '%(medium)s' has reached its concurrent request limit."
1386
1372
            " Be sure to finish_writing and finish_reading on the"
1387
1373
            " currently open request.")
1388
1374
 
1389
 
    internal_error = True
1390
 
 
1391
1375
    def __init__(self, medium):
1392
1376
        self.medium = medium
1393
1377
 
1583
1567
        self.graph = graph
1584
1568
 
1585
1569
 
1586
 
class WritingCompleted(BzrError):
 
1570
class WritingCompleted(InternalBzrError):
1587
1571
 
1588
1572
    _fmt = ("The MediumRequest '%(request)s' has already had finish_writing "
1589
1573
            "called upon it - accept bytes may not be called anymore.")
1590
1574
 
1591
 
    internal_error = True
1592
 
 
1593
1575
    def __init__(self, request):
1594
1576
        self.request = request
1595
1577
 
1596
1578
 
1597
 
class WritingNotComplete(BzrError):
 
1579
class WritingNotComplete(InternalBzrError):
1598
1580
 
1599
1581
    _fmt = ("The MediumRequest '%(request)s' has not has finish_writing "
1600
1582
            "called upon it - until the write phase is complete no "
1601
1583
            "data may be read.")
1602
1584
 
1603
 
    internal_error = True
1604
 
 
1605
1585
    def __init__(self, request):
1606
1586
        self.request = request
1607
1587
 
1615
1595
        self.filename = filename
1616
1596
 
1617
1597
 
1618
 
class MediumNotConnected(BzrError):
 
1598
class MediumNotConnected(InternalBzrError):
1619
1599
 
1620
1600
    _fmt = """The medium '%(medium)s' is not connected."""
1621
1601
 
1622
 
    internal_error = True
1623
 
 
1624
1602
    def __init__(self, medium):
1625
1603
        self.medium = medium
1626
1604
 
1702
1680
        self.root_trans_id = transform.root
1703
1681
 
1704
1682
 
1705
 
class BzrBadParameter(BzrError):
 
1683
class BzrBadParameter(InternalBzrError):
1706
1684
 
1707
1685
    _fmt = "Bad parameter: %(param)r"
1708
1686
 
1709
 
    internal_error = True
1710
 
 
1711
1687
    # This exception should never be thrown, but it is a base class for all
1712
1688
    # parameter-to-function errors.
1713
1689
 
2096
2072
    _fmt = """This operation requires rich root data storage"""
2097
2073
 
2098
2074
 
2099
 
class NoSmartMedium(BzrError):
 
2075
class NoSmartMedium(InternalBzrError):
2100
2076
 
2101
2077
    _fmt = "The transport '%(transport)s' cannot tunnel the smart protocol."
2102
2078
 
2103
 
    internal_error = True
2104
 
 
2105
2079
    def __init__(self, transport):
2106
2080
        self.transport = transport
2107
2081
 
2138
2112
        self.revision_id = revision_id
2139
2113
 
2140
2114
 
2141
 
class IllegalUseOfScopeReplacer(BzrError):
 
2115
class IllegalUseOfScopeReplacer(InternalBzrError):
2142
2116
 
2143
2117
    _fmt = ("ScopeReplacer object %(name)r was used incorrectly:"
2144
2118
            " %(msg)s%(extra)s")
2145
2119
 
2146
 
    internal_error = True
2147
 
 
2148
2120
    def __init__(self, name, msg, extra=None):
2149
2121
        BzrError.__init__(self)
2150
2122
        self.name = name
2155
2127
            self.extra = ''
2156
2128
 
2157
2129
 
2158
 
class InvalidImportLine(BzrError):
 
2130
class InvalidImportLine(InternalBzrError):
2159
2131
 
2160
2132
    _fmt = "Not a valid import statement: %(msg)\n%(text)s"
2161
2133
 
2162
 
    internal_error = True
2163
 
 
2164
2134
    def __init__(self, text, msg):
2165
2135
        BzrError.__init__(self)
2166
2136
        self.text = text
2167
2137
        self.msg = msg
2168
2138
 
2169
2139
 
2170
 
class ImportNameCollision(BzrError):
 
2140
class ImportNameCollision(InternalBzrError):
2171
2141
 
2172
2142
    _fmt = ("Tried to import an object to the same name as"
2173
2143
            " an existing object. %(name)s")
2174
2144
 
2175
 
    internal_error = True
2176
 
 
2177
2145
    def __init__(self, name):
2178
2146
        BzrError.__init__(self)
2179
2147
        self.name = name
2244
2212
        self.other_tree = other_tree
2245
2213
 
2246
2214
 
2247
 
class BadReferenceTarget(BzrError):
 
2215
class BadReferenceTarget(InternalBzrError):
2248
2216
 
2249
2217
    _fmt = "Can't add reference to %(other_tree)s into %(tree)s." \
2250
2218
           "%(reason)s"
2251
2219
 
2252
 
    internal_error = True
2253
 
 
2254
2220
    def __init__(self, tree, other_tree, reason):
2255
2221
        self.tree = tree
2256
2222
        self.other_tree = other_tree
2325
2291
 
2326
2292
    _fmt = "Unexpected end of container stream"
2327
2293
 
2328
 
    internal_error = False
2329
 
 
2330
2294
 
2331
2295
class UnknownRecordTypeError(ContainerError):
2332
2296
 
2360
2324
        self.name = name
2361
2325
 
2362
2326
 
2363
 
class NoDestinationAddress(BzrError):
 
2327
class NoDestinationAddress(InternalBzrError):
2364
2328
 
2365
2329
    _fmt = "Message does not have a destination address."
2366
2330
 
2367
 
    internal_error = True
2368
 
 
2369
2331
 
2370
2332
class SMTPError(BzrError):
2371
2333