/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-18 01:57:45 UTC
  • mto: This revision was merged to the branch mainline in revision 7493.
  • Revision ID: jelmer@jelmer.uk-20200218015745-q2ss9tsk74h4nh61
drop use of future.

Show diffs side-by-side

added added

removed removed

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