/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

  • Committer: Robert Collins
  • Date: 2009-03-13 02:25:46 UTC
  • mfrom: (4133 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4183.
  • Revision ID: robertc@robertcollins.net-20090313022546-e7de5zsdkbay5okf
MergeĀ .dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Exceptions for bzr, and reporting of them.
18
18
"""
19
19
 
20
 
 
21
20
from bzrlib import (
22
21
    osutils,
23
22
    symbol_versioning,
32
31
 
33
32
 
34
33
# TODO: is there any value in providing the .args field used by standard
35
 
# python exceptions?   A list of values with no names seems less useful 
 
34
# python exceptions?   A list of values with no names seems less useful
36
35
# to me.
37
36
 
38
 
# TODO: Perhaps convert the exception to a string at the moment it's 
 
37
# TODO: Perhaps convert the exception to a string at the moment it's
39
38
# constructed to make sure it will succeed.  But that says nothing about
40
39
# exceptions that are never raised.
41
40
 
62
61
    :cvar _fmt: Format string to display the error; this is expanded
63
62
    by the instance's dict.
64
63
    """
65
 
    
 
64
 
66
65
    internal_error = False
67
66
 
68
67
    def __init__(self, msg=None, **kwds):
73
72
        arguments can be given.  The first is for generic "user" errors which
74
73
        are not intended to be caught and so do not need a specific subclass.
75
74
        The second case is for use with subclasses that provide a _fmt format
76
 
        string to print the arguments.  
 
75
        string to print the arguments.
77
76
 
78
 
        Keyword arguments are taken as parameters to the error, which can 
79
 
        be inserted into the format string template.  It's recommended 
80
 
        that subclasses override the __init__ method to require specific 
 
77
        Keyword arguments are taken as parameters to the error, which can
 
78
        be inserted into the format string template.  It's recommended
 
79
        that subclasses override the __init__ method to require specific
81
80
        parameters.
82
81
 
83
82
        :param msg: If given, this is the literal complete text for the error,
134
133
            s = str(s)
135
134
        return s
136
135
 
 
136
    def __repr__(self):
 
137
        return '%s(%s)' % (self.__class__.__name__, str(self))
 
138
 
137
139
    def _get_format_string(self):
138
140
        """Return format string for this exception or None"""
139
141
        fmt = getattr(self, '_fmt', None)
152
154
               )
153
155
 
154
156
    def __eq__(self, other):
155
 
        if self.__class__ != other.__class__:
 
157
        if self.__class__ is not other.__class__:
156
158
            return NotImplemented
157
159
        return self.__dict__ == other.__dict__
158
160
 
263
265
 
264
266
 
265
267
class InvalidEntryName(InternalBzrError):
266
 
    
 
268
 
267
269
    _fmt = "Invalid entry name: %(name)s"
268
270
 
269
271
    def __init__(self, name):
272
274
 
273
275
 
274
276
class InvalidRevisionNumber(BzrError):
275
 
    
 
277
 
276
278
    _fmt = "Invalid revision number %(revno)s"
277
279
 
278
280
    def __init__(self, revno):
327
329
class NoSuchId(BzrError):
328
330
 
329
331
    _fmt = 'The file id "%(file_id)s" is not present in the tree %(tree)s.'
330
 
    
 
332
 
331
333
    def __init__(self, tree, file_id):
332
334
        BzrError.__init__(self)
333
335
        self.file_id = file_id
360
362
class NoWorkingTree(BzrError):
361
363
 
362
364
    _fmt = 'No WorkingTree exists for "%(base)s".'
363
 
    
 
365
 
364
366
    def __init__(self, base):
365
367
        BzrError.__init__(self)
366
368
        self.base = base
475
477
    def __init__(self, name, value):
476
478
        BzrError.__init__(self, name=name, value=value)
477
479
 
478
 
    
 
480
 
479
481
class StrictCommitFailed(BzrError):
480
482
 
481
483
    _fmt = "Commit refused because there are unknown files in the tree"
484
486
# XXX: Should be unified with TransportError; they seem to represent the
485
487
# same thing
486
488
# RBC 20060929: I think that unifiying with TransportError would be a mistake
487
 
# - this is finer than a TransportError - and more useful as such. It 
 
489
# - this is finer than a TransportError - and more useful as such. It
488
490
# differentiates between 'transport has failed' and 'operation on a transport
489
491
# has failed.'
490
492
class PathError(BzrError):
491
 
    
 
493
 
492
494
    _fmt = "Generic path error: %(path)r%(extra)s)"
493
495
 
494
496
    def __init__(self, path, extra=None):
548
550
 
549
551
 
550
552
class ReadingCompleted(InternalBzrError):
551
 
    
 
553
 
552
554
    _fmt = ("The MediumRequest '%(request)s' has already had finish_reading "
553
555
            "called upon it - the request has been completed and no more "
554
556
            "data may be read.")
646
648
 
647
649
 
648
650
class ReadError(PathError):
649
 
    
 
651
 
650
652
    _fmt = """Error reading from %(path)r."""
651
653
 
652
654
 
687
689
 
688
690
# TODO: This is given a URL; we try to unescape it but doing that from inside
689
691
# the exception object is a bit undesirable.
690
 
# TODO: Probably this behavior of should be a common superclass 
 
692
# TODO: Probably this behavior of should be a common superclass
691
693
class NotBranchError(PathError):
692
694
 
693
695
    _fmt = 'Not a branch: "%(path)s".'
762
764
 
763
765
 
764
766
class UnknownFormatError(BzrError):
765
 
    
 
767
 
766
768
    _fmt = "Unknown %(kind)s format: %(format)r"
767
769
 
768
770
    def __init__(self, format, kind='branch'):
771
773
 
772
774
 
773
775
class IncompatibleFormat(BzrError):
774
 
    
 
776
 
775
777
    _fmt = "Format %(format)s is not compatible with .bzr version %(bzrdir)s."
776
778
 
777
779
    def __init__(self, format, bzrdir_format):
794
796
 
795
797
 
796
798
class IncompatibleRevision(BzrError):
797
 
    
 
799
 
798
800
    _fmt = "Revision is not compatible with %(repo_format)s"
799
801
 
800
802
    def __init__(self, repo_format):
1001
1003
 
1002
1004
class LockContention(LockError):
1003
1005
 
1004
 
    _fmt = 'Could not acquire lock "%(lock)s"'
 
1006
    _fmt = 'Could not acquire lock "%(lock)s": %(msg)s'
1005
1007
    # TODO: show full url for lock, combining the transport and relative
1006
1008
    # bits?
1007
1009
 
1008
1010
    internal_error = False
1009
1011
 
1010
 
    def __init__(self, lock):
 
1012
    def __init__(self, lock, msg=''):
1011
1013
        self.lock = lock
 
1014
        self.msg = msg
1012
1015
 
1013
1016
 
1014
1017
class LockBroken(LockError):
1128
1131
 
1129
1132
class NoSuchRevisionInTree(NoSuchRevision):
1130
1133
    """When using Tree.revision_tree, and the revision is not accessible."""
1131
 
    
 
1134
 
1132
1135
    _fmt = "The revision id {%(revision_id)s} is not present in the tree %(tree)s."
1133
1136
 
1134
1137
    def __init__(self, tree, revision_id):
1198
1201
 
1199
1202
 
1200
1203
class NoCommonAncestor(BzrError):
1201
 
    
 
1204
 
1202
1205
    _fmt = "Revisions have no common ancestor: %(revision_a)s %(revision_b)s"
1203
1206
 
1204
1207
    def __init__(self, revision_a, revision_b):
1272
1275
        self.branch = branch
1273
1276
        self.master = master
1274
1277
 
1275
 
        
 
1278
 
1276
1279
class CommitToDoubleBoundBranch(BzrError):
1277
1280
 
1278
1281
    _fmt = ("Cannot commit to branch %(branch)s."
1348
1351
class WeaveParentMismatch(WeaveError):
1349
1352
 
1350
1353
    _fmt = "Parents are mismatched between two revisions. %(message)s"
1351
 
    
 
1354
 
1352
1355
 
1353
1356
class WeaveInvalidChecksum(WeaveError):
1354
1357
 
1380
1383
 
1381
1384
 
1382
1385
class VersionedFileError(BzrError):
1383
 
    
 
1386
 
1384
1387
    _fmt = "Versioned file error"
1385
1388
 
1386
1389
 
1387
1390
class RevisionNotPresent(VersionedFileError):
1388
 
    
 
1391
 
1389
1392
    _fmt = 'Revision {%(revision_id)s} not present in "%(file_id)s".'
1390
1393
 
1391
1394
    def __init__(self, revision_id, file_id):
1395
1398
 
1396
1399
 
1397
1400
class RevisionAlreadyPresent(VersionedFileError):
1398
 
    
 
1401
 
1399
1402
    _fmt = 'Revision {%(revision_id)s} already present in "%(file_id)s".'
1400
1403
 
1401
1404
    def __init__(self, revision_id, file_id):
1410
1413
 
1411
1414
 
1412
1415
class KnitError(InternalBzrError):
1413
 
    
 
1416
 
1414
1417
    _fmt = "Knit error"
1415
1418
 
1416
1419
 
1424
1427
        self.how = how
1425
1428
 
1426
1429
 
 
1430
class SHA1KnitCorrupt(KnitCorrupt):
 
1431
 
 
1432
    _fmt = ("Knit %(filename)s corrupt: sha-1 of reconstructed text does not "
 
1433
        "match expected sha-1. key %(key)s expected sha %(expected)s actual "
 
1434
        "sha %(actual)s")
 
1435
 
 
1436
    def __init__(self, filename, actual, expected, key, content):
 
1437
        KnitError.__init__(self)
 
1438
        self.filename = filename
 
1439
        self.actual = actual
 
1440
        self.expected = expected
 
1441
        self.key = key
 
1442
        self.content = content
 
1443
 
 
1444
 
1427
1445
class KnitDataStreamIncompatible(KnitError):
1428
1446
    # Not raised anymore, as we can convert data streams.  In future we may
1429
1447
    # need it again for more exotic cases, so we're keeping it around for now.
1433
1451
    def __init__(self, stream_format, target_format):
1434
1452
        self.stream_format = stream_format
1435
1453
        self.target_format = target_format
1436
 
        
 
1454
 
1437
1455
 
1438
1456
class KnitDataStreamUnknown(KnitError):
1439
1457
    # Indicates a data stream we don't know how to handle.
1442
1460
 
1443
1461
    def __init__(self, stream_format):
1444
1462
        self.stream_format = stream_format
1445
 
        
 
1463
 
1446
1464
 
1447
1465
class KnitHeaderError(KnitError):
1448
1466
 
1458
1476
 
1459
1477
    Currently only 'fulltext' and 'line-delta' are supported.
1460
1478
    """
1461
 
    
 
1479
 
1462
1480
    _fmt = ("Knit index %(filename)s does not have a known method"
1463
1481
            " in options: %(options)r")
1464
1482
 
1468
1486
        self.options = options
1469
1487
 
1470
1488
 
 
1489
class RetryWithNewPacks(BzrError):
 
1490
    """Raised when we realize that the packs on disk have changed.
 
1491
 
 
1492
    This is meant as more of a signaling exception, to trap between where a
 
1493
    local error occurred and the code that can actually handle the error and
 
1494
    code that can retry appropriately.
 
1495
    """
 
1496
 
 
1497
    internal_error = True
 
1498
 
 
1499
    _fmt = ("Pack files have changed, reload and retry. context: %(context)s"
 
1500
            " %(orig_error)s")
 
1501
 
 
1502
    def __init__(self, context, reload_occurred, exc_info):
 
1503
        """create a new RetryWithNewPacks error.
 
1504
 
 
1505
        :param reload_occurred: Set to True if we know that the packs have
 
1506
            already been reloaded, and we are failing because of an in-memory
 
1507
            cache miss. If set to True then we will ignore if a reload says
 
1508
            nothing has changed, because we assume it has already reloaded. If
 
1509
            False, then a reload with nothing changed will force an error.
 
1510
        :param exc_info: The original exception traceback, so if there is a
 
1511
            problem we can raise the original error (value from sys.exc_info())
 
1512
        """
 
1513
        BzrError.__init__(self)
 
1514
        self.reload_occurred = reload_occurred
 
1515
        self.exc_info = exc_info
 
1516
        self.orig_error = exc_info[1]
 
1517
        # TODO: The global error handler should probably treat this by
 
1518
        #       raising/printing the original exception with a bit about
 
1519
        #       RetryWithNewPacks also not being caught
 
1520
 
 
1521
 
 
1522
class RetryAutopack(RetryWithNewPacks):
 
1523
    """Raised when we are autopacking and we find a missing file.
 
1524
 
 
1525
    Meant as a signaling exception, to tell the autopack code it should try
 
1526
    again.
 
1527
    """
 
1528
 
 
1529
    internal_error = True
 
1530
 
 
1531
    _fmt = ("Pack files have changed, reload and try autopack again."
 
1532
            " context: %(context)s %(orig_error)s")
 
1533
 
 
1534
 
1471
1535
class NoSuchExportFormat(BzrError):
1472
 
    
 
1536
 
1473
1537
    _fmt = "Export format %(format)r not supported"
1474
1538
 
1475
1539
    def __init__(self, format):
1478
1542
 
1479
1543
 
1480
1544
class TransportError(BzrError):
1481
 
    
 
1545
 
1482
1546
    _fmt = "Transport error: %(msg)s %(orig_error)s"
1483
1547
 
1484
1548
    def __init__(self, msg=None, orig_error=None):
1529
1593
 
1530
1594
class SmartMessageHandlerError(InternalBzrError):
1531
1595
 
1532
 
    _fmt = "The message handler raised an exception: %(exc_value)s."
 
1596
    _fmt = ("The message handler raised an exception:\n"
 
1597
            "%(traceback_text)s")
1533
1598
 
1534
1599
    def __init__(self, exc_info):
1535
 
        self.exc_type, self.exc_value, self.tb = exc_info
1536
 
        
 
1600
        import traceback
 
1601
        self.exc_type, self.exc_value, self.exc_tb = exc_info
 
1602
        self.exc_info = exc_info
 
1603
        traceback_strings = traceback.format_exception(
 
1604
                self.exc_type, self.exc_value, self.exc_tb)
 
1605
        self.traceback_text = ''.join(traceback_strings)
 
1606
 
1537
1607
 
1538
1608
# A set of semi-meaningful errors which can be thrown
1539
1609
class TransportNotPossible(TransportError):
1565
1635
            self.port = ':%s' % port
1566
1636
 
1567
1637
 
 
1638
# XXX: This is also used for unexpected end of file, which is different at the
 
1639
# TCP level from "connection reset".
1568
1640
class ConnectionReset(TransportError):
1569
1641
 
1570
1642
    _fmt = "Connection closed: %(msg)s %(orig_error)s"
1611
1683
 
1612
1684
    _fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1613
1685
 
1614
 
    def __init__(self, source, target, is_permanent=False, qual_proto=None):
 
1686
    def __init__(self, source, target, is_permanent=False):
1615
1687
        self.source = source
1616
1688
        self.target = target
1617
1689
        if is_permanent:
1618
1690
            self.permanently = ' permanently'
1619
1691
        else:
1620
1692
            self.permanently = ''
1621
 
        self._qualified_proto = qual_proto
1622
1693
        TransportError.__init__(self)
1623
1694
 
1624
 
    def _requalify_url(self, url):
1625
 
        """Restore the qualified proto in front of the url"""
1626
 
        # When this exception is raised, source and target are in
1627
 
        # user readable format. But some transports may use a
1628
 
        # different proto (http+urllib:// will present http:// to
1629
 
        # the user. If a qualified proto is specified, the code
1630
 
        # trapping the exception can get the qualified urls to
1631
 
        # properly handle the redirection themself (creating a
1632
 
        # new transport object from the target url for example).
1633
 
        # But checking that the scheme of the original and
1634
 
        # redirected urls are the same can be tricky. (see the
1635
 
        # FIXME in BzrDir.open_from_transport for the unique use
1636
 
        # case so far).
1637
 
        if self._qualified_proto is None:
1638
 
            return url
1639
 
 
1640
 
        # The TODO related to NotBranchError mention that doing
1641
 
        # that kind of manipulation on the urls may not be the
1642
 
        # exception object job. On the other hand, this object is
1643
 
        # the interface between the code and the user so
1644
 
        # presenting the urls in different ways is indeed its
1645
 
        # job...
1646
 
        import urlparse
1647
 
        proto, netloc, path, query, fragment = urlparse.urlsplit(url)
1648
 
        return urlparse.urlunsplit((self._qualified_proto, netloc, path,
1649
 
                                   query, fragment))
1650
 
 
1651
 
    def get_source_url(self):
1652
 
        return self._requalify_url(self.source)
1653
 
 
1654
 
    def get_target_url(self):
1655
 
        return self._requalify_url(self.target)
1656
 
 
1657
1695
 
1658
1696
class TooManyRedirections(TransportError):
1659
1697
 
1694
1732
 
1695
1733
class WorkingTreeNotRevision(BzrError):
1696
1734
 
1697
 
    _fmt = ("The working tree for %(basedir)s has changed since" 
 
1735
    _fmt = ("The working tree for %(basedir)s has changed since"
1698
1736
            " the last commit, but weave merge requires that it be"
1699
1737
            " unchanged")
1700
1738
 
2014
2052
    _fmt = """This tree contains left-over files from a failed operation.
2015
2053
    Please examine %(limbo_dir)s to see if it contains any files you wish to
2016
2054
    keep, and delete it when you are done."""
2017
 
    
 
2055
 
2018
2056
    def __init__(self, limbo_dir):
2019
2057
       BzrError.__init__(self)
2020
2058
       self.limbo_dir = limbo_dir
2136
2174
    _fmt = "Cannot perform local-only commits on unbound branches."
2137
2175
 
2138
2176
 
2139
 
class MissingProgressBarFinish(BzrError):
2140
 
 
2141
 
    _fmt = "A nested progress bar was not 'finished' correctly."
2142
 
 
2143
 
 
2144
2177
class InvalidProgressBarType(BzrError):
2145
2178
 
2146
2179
    _fmt = ("Environment variable BZR_PROGRESS_BAR='%(bar_type)s"
2172
2205
 
2173
2206
 
2174
2207
class BinaryFile(BzrError):
2175
 
    
 
2208
 
2176
2209
    _fmt = "File is binary but should be text."
2177
2210
 
2178
2211
 
2198
2231
 
2199
2232
 
2200
2233
class NotABundle(BzrError):
2201
 
    
 
2234
 
2202
2235
    _fmt = "Not a bzr revision-bundle: %(text)r"
2203
2236
 
2204
2237
    def __init__(self, text):
2206
2239
        self.text = text
2207
2240
 
2208
2241
 
2209
 
class BadBundle(BzrError): 
2210
 
    
 
2242
class BadBundle(BzrError):
 
2243
 
2211
2244
    _fmt = "Bad bzr revision-bundle: %(text)r"
2212
2245
 
2213
2246
    def __init__(self, text):
2215
2248
        self.text = text
2216
2249
 
2217
2250
 
2218
 
class MalformedHeader(BadBundle): 
2219
 
    
 
2251
class MalformedHeader(BadBundle):
 
2252
 
2220
2253
    _fmt = "Malformed bzr revision-bundle header: %(text)r"
2221
2254
 
2222
2255
 
2223
 
class MalformedPatches(BadBundle): 
2224
 
    
 
2256
class MalformedPatches(BadBundle):
 
2257
 
2225
2258
    _fmt = "Malformed patches in bzr revision-bundle: %(text)r"
2226
2259
 
2227
2260
 
2228
 
class MalformedFooter(BadBundle): 
2229
 
    
 
2261
class MalformedFooter(BadBundle):
 
2262
 
2230
2263
    _fmt = "Malformed footer in bzr revision-bundle: %(text)r"
2231
2264
 
2232
2265
 
2233
2266
class UnsupportedEOLMarker(BadBundle):
2234
 
    
2235
 
    _fmt = "End of line marker was not \\n in bzr revision-bundle"    
 
2267
 
 
2268
    _fmt = "End of line marker was not \\n in bzr revision-bundle"
2236
2269
 
2237
2270
    def __init__(self):
2238
 
        # XXX: BadBundle's constructor assumes there's explanatory text, 
 
2271
        # XXX: BadBundle's constructor assumes there's explanatory text,
2239
2272
        # but for this there is not
2240
2273
        BzrError.__init__(self)
2241
2274
 
2242
2275
 
2243
2276
class IncompatibleBundleFormat(BzrError):
2244
 
    
 
2277
 
2245
2278
    _fmt = "Bundle format %(bundle_format)s is incompatible with %(other)s"
2246
2279
 
2247
2280
    def __init__(self, bundle_format, other):
2251
2284
 
2252
2285
 
2253
2286
class BadInventoryFormat(BzrError):
2254
 
    
 
2287
 
2255
2288
    _fmt = "Root class for inventory serialization errors"
2256
2289
 
2257
2290
 
2310
2343
        self.revision_id = revision_id
2311
2344
        self.ghost_revision_id = ghost_revision_id
2312
2345
 
2313
 
        
 
2346
 
2314
2347
class GhostRevisionUnusableHere(BzrError):
2315
2348
 
2316
2349
    _fmt = "Ghost revision {%(revision_id)s} cannot be used here."
2408
2441
 
2409
2442
 
2410
2443
class UnsupportedInventoryKind(BzrError):
2411
 
    
 
2444
 
2412
2445
    _fmt = """Unsupported entry kind %(kind)s"""
2413
2446
 
2414
2447
    def __init__(self, kind):
2426
2459
 
2427
2460
 
2428
2461
class SubsumeTargetNeedsUpgrade(BzrError):
2429
 
    
 
2462
 
2430
2463
    _fmt = """Subsume target %(other_tree)s needs to be upgraded."""
2431
2464
 
2432
2465
    def __init__(self, other_tree):
2460
2493
    def __init__(self, branch):
2461
2494
        self.branch = branch
2462
2495
 
2463
 
        
 
2496
 
2464
2497
class TagAlreadyExists(BzrError):
2465
2498
 
2466
2499
    _fmt = "Tag %(tag_name)s already exists."
2471
2504
 
2472
2505
class MalformedBugIdentifier(BzrError):
2473
2506
 
2474
 
    _fmt = "Did not understand bug identifier %(bug_id)s: %(reason)s"
 
2507
    _fmt = ('Did not understand bug identifier %(bug_id)s: %(reason)s. '
 
2508
            'See "bzr help bugs" for more information on this feature.')
2475
2509
 
2476
2510
    def __init__(self, bug_id, reason):
2477
2511
        self.bug_id = bug_id
2549
2583
        """
2550
2584
        self.error_from_smart_server = error_from_smart_server
2551
2585
        self.error_tuple = error_from_smart_server.error_tuple
2552
 
        
 
2586
 
2553
2587
 
2554
2588
class ContainerError(BzrError):
2555
2589
    """Base class of container errors."""
2558
2592
class UnknownContainerFormatError(ContainerError):
2559
2593
 
2560
2594
    _fmt = "Unrecognised container format: %(container_format)r"
2561
 
    
 
2595
 
2562
2596
    def __init__(self, container_format):
2563
2597
        self.container_format = container_format
2564
2598
 
2628
2662
 
2629
2663
class NoMailAddressSpecified(BzrError):
2630
2664
 
2631
 
    _fmt = "No mail-to address specified."
 
2665
    _fmt = "No mail-to address (--mail-to) or output (-o) specified."
2632
2666
 
2633
2667
 
2634
2668
class UnknownMailClient(BzrError):
2714
2748
    _fmt = "'%(display_url)s' is already standalone."
2715
2749
 
2716
2750
 
 
2751
class AlreadyWithTrees(BzrDirError):
 
2752
 
 
2753
    _fmt = ("Shared repository '%(display_url)s' already creates "
 
2754
            "working trees.")
 
2755
 
 
2756
 
 
2757
class AlreadyWithNoTrees(BzrDirError):
 
2758
 
 
2759
    _fmt = ("Shared repository '%(display_url)s' already doesn't create "
 
2760
            "working trees.")
 
2761
 
 
2762
 
2717
2763
class ReconfigurationNotSupported(BzrDirError):
2718
2764
 
2719
2765
    _fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2773
2819
 
2774
2820
 
2775
2821
class CommandAvailableInPlugin(StandardError):
2776
 
    
 
2822
 
2777
2823
    internal_error = False
2778
2824
 
2779
2825
    def __init__(self, cmd_name, plugin_metadata, provider):
2780
 
        
 
2826
 
2781
2827
        self.plugin_metadata = plugin_metadata
2782
2828
        self.cmd_name = cmd_name
2783
2829
        self.provider = provider
2784
2830
 
2785
2831
    def __str__(self):
2786
2832
 
2787
 
        _fmt = ('"%s" is not a standard bzr command. \n' 
 
2833
        _fmt = ('"%s" is not a standard bzr command. \n'
2788
2834
                'However, the following official plugin provides this command: %s\n'
2789
2835
                'You can install it by going to: %s'
2790
 
                % (self.cmd_name, self.plugin_metadata['name'], 
 
2836
                % (self.cmd_name, self.plugin_metadata['name'],
2791
2837
                    self.plugin_metadata['url']))
2792
2838
 
2793
2839
        return _fmt
2794
2840
 
2795
2841
 
2796
2842
class NoPluginAvailable(BzrError):
2797
 
    pass    
 
2843
    pass
2798
2844
 
2799
2845
 
2800
2846
class NotATerminal(BzrError):
2884
2930
    """A pre_change_branch_tip hook function may raise this to cleanly and
2885
2931
    explicitly abort a change to a branch tip.
2886
2932
    """
2887
 
    
 
2933
 
2888
2934
    _fmt = u"Tip change rejected: %(msg)s"
2889
2935
 
2890
2936
    def __init__(self, msg):
2891
2937
        self.msg = msg
2892
2938
 
 
2939
 
 
2940
class ShelfCorrupt(BzrError):
 
2941
 
 
2942
    _fmt = "Shelf corrupt."
 
2943
 
 
2944
 
 
2945
class NoSuchShelfId(BzrError):
 
2946
 
 
2947
    _fmt = 'No changes are shelved with id "%(shelf_id)d".'
 
2948
 
 
2949
    def __init__(self, shelf_id):
 
2950
        BzrError.__init__(self, shelf_id=shelf_id)
 
2951
 
 
2952
 
 
2953
class InvalidShelfId(BzrError):
 
2954
 
 
2955
    _fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.'
 
2956
 
 
2957
    def __init__(self, invalid_id):
 
2958
        BzrError.__init__(self, invalid_id=invalid_id)
 
2959
 
 
2960
 
 
2961
class UserAbort(BzrError):
 
2962
 
 
2963
    _fmt = 'The user aborted the operation.'
 
2964
 
 
2965
 
 
2966
class MustHaveWorkingTree(BzrError):
 
2967
 
 
2968
    _fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
 
2969
 
 
2970
    def __init__(self, format, url):
 
2971
        BzrError.__init__(self, format=format, url=url)
 
2972
 
 
2973
 
 
2974
class NoSuchView(BzrError):
 
2975
    """A view does not exist.
 
2976
    """
 
2977
 
 
2978
    _fmt = u"No such view: %(view_name)s."
 
2979
 
 
2980
    def __init__(self, view_name):
 
2981
        self.view_name = view_name
 
2982
 
 
2983
 
 
2984
class ViewsNotSupported(BzrError):
 
2985
    """Views are not supported by a tree format.
 
2986
    """
 
2987
 
 
2988
    _fmt = ("Views are not supported by %(tree)s;"
 
2989
            " use 'bzr upgrade' to change your tree to a later format.")
 
2990
 
 
2991
    def __init__(self, tree):
 
2992
        self.tree = tree
 
2993
 
 
2994
 
 
2995
class FileOutsideView(BzrError):
 
2996
 
 
2997
    _fmt = ('Specified file "%(file_name)s" is outside the current view: '
 
2998
            '%(view_str)s')
 
2999
 
 
3000
    def __init__(self, file_name, view_files):
 
3001
        self.file_name = file_name
 
3002
        self.view_str = ", ".join(view_files)
 
3003
 
 
3004
 
 
3005
class UnresumableWriteGroup(BzrError):
 
3006
 
 
3007
    _fmt = ("Repository %(repository)s cannot resume write group "
 
3008
            "%(write_groups)r: %(reason)s")
 
3009
 
 
3010
    internal_error = True
 
3011
 
 
3012
    def __init__(self, repository, write_groups, reason):
 
3013
        self.repository = repository
 
3014
        self.write_groups = write_groups
 
3015
        self.reason = reason
 
3016
 
 
3017
 
 
3018
class UnsuspendableWriteGroup(BzrError):
 
3019
 
 
3020
    _fmt = ("Repository %(repository)s cannot suspend a write group.")
 
3021
 
 
3022
    internal_error = True
 
3023
 
 
3024
    def __init__(self, repository):
 
3025
        self.repository = repository