/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 breezy/errors.py

  • Committer: Jelmer Vernooij
  • Date: 2020-02-13 23:57:28 UTC
  • mfrom: (7490 work)
  • mto: This revision was merged to the branch mainline in revision 7492.
  • Revision ID: jelmer@jelmer.uk-20200213235728-m6ds0mm3mbs4y182
Merge trunk.

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
from __future__ import absolute_import
 
21
 
20
22
 
21
23
# TODO: is there any value in providing the .args field used by standard
22
24
# python exceptions?   A list of values with no names seems less useful
230
232
    _fmt = "The branch '%(branch)s' is not stacked."
231
233
 
232
234
 
 
235
class InventoryModified(InternalBzrError):
 
236
 
 
237
    _fmt = ("The current inventory for the tree %(tree)r has been modified,"
 
238
            " so a clean inventory cannot be read without data loss.")
 
239
 
 
240
    def __init__(self, tree):
 
241
        self.tree = tree
 
242
 
 
243
 
233
244
class NoWorkingTree(BzrError):
234
245
 
235
246
    _fmt = 'No WorkingTree exists for "%(base)s".'
262
273
            'E.g. brz whoami "Your Name <name@example.com>"')
263
274
 
264
275
 
265
 
class CommandError(BzrError):
 
276
class BzrCommandError(BzrError):
266
277
    """Error from user command"""
267
278
 
268
279
    # Error from malformed user command; please avoid raising this as a
270
281
    #
271
282
    # I think it's a waste of effort to differentiate between errors that
272
283
    # are not intended to be caught anyway.  UI code need not subclass
273
 
    # CommandError, and non-UI code should not throw a subclass of
274
 
    # CommandError.  ADHB 20051211
275
 
 
276
 
 
277
 
# Provide the old name as backup, for the moment.
278
 
BzrCommandError = CommandError
 
284
    # BzrCommandError, and non-UI code should not throw a subclass of
 
285
    # BzrCommandError.  ADHB 20051211
279
286
 
280
287
 
281
288
class NotWriteLocked(BzrError):
377
384
    _fmt = 'Permission denied: "%(path)s"%(extra)s'
378
385
 
379
386
 
 
387
class UnavailableRepresentation(InternalBzrError):
 
388
 
 
389
    _fmt = ("The encoding '%(wanted)s' is not available for key %(key)s which "
 
390
            "is encoded as '%(native)s'.")
 
391
 
 
392
    def __init__(self, key, wanted, native):
 
393
        InternalBzrError.__init__(self)
 
394
        self.wanted = wanted
 
395
        self.native = native
 
396
        self.key = key
 
397
 
 
398
 
380
399
class UnsupportedProtocol(PathError):
381
400
 
382
401
    _fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'
563
582
        self.format = format
564
583
 
565
584
 
 
585
class LineEndingError(BzrError):
 
586
 
 
587
    _fmt = ("Line ending corrupted for file: %(file)s; "
 
588
            "Maybe your files got corrupted in transport?")
 
589
 
 
590
    def __init__(self, file):
 
591
        self.file = file
 
592
 
 
593
 
566
594
class IncompatibleFormat(BzrError):
567
595
 
568
596
    _fmt = "Format %(format)s is not compatible with .bzr version %(controldir)s."
930
958
        self.revision_id = revision_id
931
959
 
932
960
 
 
961
class InvalidRevisionSpec(BzrError):
 
962
 
 
963
    _fmt = ("Requested revision: '%(spec)s' does not exist in branch:"
 
964
            " %(branch_url)s%(extra)s")
 
965
 
 
966
    def __init__(self, spec, branch, extra=None):
 
967
        BzrError.__init__(self, branch=branch, spec=spec)
 
968
        self.branch_url = getattr(branch, 'user_url', str(branch))
 
969
        if extra:
 
970
            self.extra = '\n' + str(extra)
 
971
        else:
 
972
            self.extra = ''
 
973
 
 
974
 
933
975
class AppendRevisionsOnlyViolation(BzrError):
934
976
 
935
977
    _fmt = ('Operation denied because it would change the main history,'
1280
1322
        TransportError.__init__(self, msg, orig_error=orig_error)
1281
1323
 
1282
1324
 
1283
 
class UnexpectedHttpStatus(InvalidHttpResponse):
1284
 
 
1285
 
    _fmt = "Unexpected HTTP status %(code)d for %(path)s"
1286
 
 
1287
 
    def __init__(self, path, code, msg=None):
1288
 
        self.path = path
1289
 
        self.code = code
1290
 
        self.msg = msg
1291
 
        full_msg = 'status code %d unexpected' % code
1292
 
        if msg is not None:
1293
 
            full_msg += ': ' + msg
1294
 
        InvalidHttpResponse.__init__(
1295
 
            self, path, full_msg)
1296
 
 
1297
 
 
1298
 
class BadHttpRequest(UnexpectedHttpStatus):
1299
 
 
1300
 
    _fmt = "Bad http request for %(path)s: %(reason)s"
1301
 
 
1302
 
    def __init__(self, path, reason):
1303
 
        self.path = path
1304
 
        self.reason = reason
1305
 
        TransportError.__init__(self, reason)
1306
 
 
1307
 
 
1308
1325
class InvalidHttpRange(InvalidHttpResponse):
1309
1326
 
1310
1327
    _fmt = "Invalid http range %(range)r for %(path)s: %(msg)s"
1460
1477
        self.file_id = file_id
1461
1478
 
1462
1479
 
 
1480
class DuplicateFileId(BzrError):
 
1481
 
 
1482
    _fmt = "File id {%(file_id)s} already exists in inventory as %(entry)s"
 
1483
 
 
1484
    def __init__(self, file_id, entry):
 
1485
        BzrError.__init__(self)
 
1486
        self.file_id = file_id
 
1487
        self.entry = entry
 
1488
 
 
1489
 
1463
1490
class DuplicateKey(BzrError):
1464
1491
 
1465
1492
    _fmt = "Key %(key)s is already present in map"
1473
1500
        self.prefix = prefix
1474
1501
 
1475
1502
 
 
1503
class MalformedTransform(InternalBzrError):
 
1504
 
 
1505
    _fmt = "Tree transform is malformed %(conflicts)r"
 
1506
 
 
1507
 
 
1508
class NoFinalPath(BzrError):
 
1509
 
 
1510
    _fmt = ("No final name for trans_id %(trans_id)r\n"
 
1511
            "file-id: %(file_id)r\n"
 
1512
            "root trans-id: %(root_trans_id)r\n")
 
1513
 
 
1514
    def __init__(self, trans_id, transform):
 
1515
        self.trans_id = trans_id
 
1516
        self.file_id = transform.final_file_id(trans_id)
 
1517
        self.root_trans_id = transform.root
 
1518
 
 
1519
 
1476
1520
class BzrBadParameter(InternalBzrError):
1477
1521
 
1478
1522
    _fmt = "Bad parameter: %(param)r"
1490
1534
    _fmt = "Parameter %(param)s is neither unicode nor utf8."
1491
1535
 
1492
1536
 
 
1537
class ReusingTransform(BzrError):
 
1538
 
 
1539
    _fmt = "Attempt to reuse a transform that has already been applied."
 
1540
 
 
1541
 
 
1542
class CantMoveRoot(BzrError):
 
1543
 
 
1544
    _fmt = "Moving the root directory is not supported at this time"
 
1545
 
 
1546
 
 
1547
class TransformRenameFailed(BzrError):
 
1548
 
 
1549
    _fmt = "Failed to rename %(from_path)s to %(to_path)s: %(why)s"
 
1550
 
 
1551
    def __init__(self, from_path, to_path, why, errno):
 
1552
        self.from_path = from_path
 
1553
        self.to_path = to_path
 
1554
        self.why = why
 
1555
        self.errno = errno
 
1556
 
 
1557
 
1493
1558
class BzrMoveFailedError(BzrError):
1494
1559
 
1495
1560
    _fmt = ("Could not move %(from_path)s%(operator)s %(to_path)s"
1619
1684
    _fmt = "Diff3 is not installed on this machine."
1620
1685
 
1621
1686
 
 
1687
class ExistingContent(BzrError):
 
1688
    # Added in breezy 0.92, used by VersionedFile.add_lines.
 
1689
 
 
1690
    _fmt = "The content being inserted is already present."
 
1691
 
 
1692
 
1622
1693
class ExistingLimbo(BzrError):
1623
1694
 
1624
1695
    _fmt = """This tree contains left-over files from a failed operation.
1640
1711
        BzrError.__init__(self, pending_deletion=pending_deletion)
1641
1712
 
1642
1713
 
 
1714
class ImmortalLimbo(BzrError):
 
1715
 
 
1716
    _fmt = """Unable to delete transform temporary directory %(limbo_dir)s.
 
1717
    Please examine %(limbo_dir)s to see if it contains any files you wish to
 
1718
    keep, and delete it when you are done."""
 
1719
 
 
1720
    def __init__(self, limbo_dir):
 
1721
        BzrError.__init__(self)
 
1722
        self.limbo_dir = limbo_dir
 
1723
 
 
1724
 
1643
1725
class ImmortalPendingDeletion(BzrError):
1644
1726
 
1645
1727
    _fmt = ("Unable to delete transform temporary directory "
1866
1948
        self.other = other
1867
1949
 
1868
1950
 
 
1951
class BadInventoryFormat(BzrError):
 
1952
 
 
1953
    _fmt = "Root class for inventory serialization errors"
 
1954
 
 
1955
 
 
1956
class UnexpectedInventoryFormat(BadInventoryFormat):
 
1957
 
 
1958
    _fmt = "The inventory was not in the expected format:\n %(msg)s"
 
1959
 
 
1960
    def __init__(self, msg):
 
1961
        BadInventoryFormat.__init__(self, msg=msg)
 
1962
 
 
1963
 
1869
1964
class RootNotRich(BzrError):
1870
1965
 
1871
1966
    _fmt = """This operation requires rich root data storage"""
1928
2023
        " branch location."
1929
2024
 
1930
2025
 
 
2026
class IllegalMergeDirectivePayload(BzrError):
 
2027
    """A merge directive contained something other than a patch or bundle"""
 
2028
 
 
2029
    _fmt = "Bad merge directive payload %(start)r"
 
2030
 
 
2031
    def __init__(self, start):
 
2032
        BzrError(self)
 
2033
        self.start = start
 
2034
 
 
2035
 
1931
2036
class PatchVerificationFailed(BzrError):
1932
2037
    """A patch from a merge directive could not be verified"""
1933
2038
 
1957
2062
        self.location = location
1958
2063
 
1959
2064
 
 
2065
class UnsupportedInventoryKind(BzrError):
 
2066
 
 
2067
    _fmt = """Unsupported entry kind %(kind)s"""
 
2068
 
 
2069
    def __init__(self, kind):
 
2070
        self.kind = kind
 
2071
 
 
2072
 
1960
2073
class BadSubsumeSource(BzrError):
1961
2074
 
1962
2075
    _fmt = "Can't subsume %(other_tree)s into %(tree)s. %(reason)s"
2282
2395
        self.format = format
2283
2396
 
2284
2397
 
2285
 
class ChangesAlreadyStored(CommandError):
 
2398
class ChangesAlreadyStored(BzrCommandError):
2286
2399
 
2287
2400
    _fmt = ('Cannot store uncommitted changes because this branch already'
2288
2401
            ' stores uncommitted changes.')