/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: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-07-28 02:47:10 UTC
  • mfrom: (7519.1.1 merge-3.1)
  • Revision ID: breezy.the.bot@gmail.com-20200728024710-a2ylds219f1lsl62
Merge lp:brz/3.1.

Merged from https://code.launchpad.net/~jelmer/brz/merge-3.1/+merge/388173

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
 
 
22
 
from .sixish import (
23
 
    PY3,
24
 
    )
25
20
 
26
21
# TODO: is there any value in providing the .args field used by standard
27
22
# python exceptions?   A list of values with no names seems less useful
108
103
               getattr(self, '_fmt', None),
109
104
               err)
110
105
 
111
 
    if PY3:
112
 
        __str__ = _format
113
 
    else:
114
 
        def __str__(self):
115
 
            return self._format().encode('utf-8')
116
 
 
117
 
        __unicode__ = _format
 
106
    __str__ = _format
118
107
 
119
108
    def __repr__(self):
120
109
        return '%s(%s)' % (self.__class__.__name__, str(self))
182
171
        self.transport = transport
183
172
 
184
173
 
185
 
class InvalidEntryName(InternalBzrError):
186
 
 
187
 
    _fmt = "Invalid entry name: %(name)s"
188
 
 
189
 
    def __init__(self, name):
190
 
        BzrError.__init__(self)
191
 
        self.name = name
192
 
 
193
 
 
194
174
class InvalidRevisionNumber(BzrError):
195
175
 
196
176
    _fmt = "Invalid revision number %(revno)s"
250
230
    _fmt = "The branch '%(branch)s' is not stacked."
251
231
 
252
232
 
253
 
class InventoryModified(InternalBzrError):
254
 
 
255
 
    _fmt = ("The current inventory for the tree %(tree)r has been modified,"
256
 
            " so a clean inventory cannot be read without data loss.")
257
 
 
258
 
    def __init__(self, tree):
259
 
        self.tree = tree
260
 
 
261
 
 
262
233
class NoWorkingTree(BzrError):
263
234
 
264
235
    _fmt = 'No WorkingTree exists for "%(base)s".'
291
262
            'E.g. brz whoami "Your Name <name@example.com>"')
292
263
 
293
264
 
294
 
class BzrCommandError(BzrError):
 
265
class CommandError(BzrError):
295
266
    """Error from user command"""
296
267
 
297
268
    # Error from malformed user command; please avoid raising this as a
299
270
    #
300
271
    # I think it's a waste of effort to differentiate between errors that
301
272
    # are not intended to be caught anyway.  UI code need not subclass
302
 
    # BzrCommandError, and non-UI code should not throw a subclass of
303
 
    # BzrCommandError.  ADHB 20051211
 
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
304
279
 
305
280
 
306
281
class NotWriteLocked(BzrError):
402
377
    _fmt = 'Permission denied: "%(path)s"%(extra)s'
403
378
 
404
379
 
405
 
class UnavailableRepresentation(InternalBzrError):
406
 
 
407
 
    _fmt = ("The encoding '%(wanted)s' is not available for key %(key)s which "
408
 
            "is encoded as '%(native)s'.")
409
 
 
410
 
    def __init__(self, key, wanted, native):
411
 
        InternalBzrError.__init__(self)
412
 
        self.wanted = wanted
413
 
        self.native = native
414
 
        self.key = key
415
 
 
416
 
 
417
380
class UnsupportedProtocol(PathError):
418
381
 
419
382
    _fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'
600
563
        self.format = format
601
564
 
602
565
 
603
 
class LineEndingError(BzrError):
604
 
 
605
 
    _fmt = ("Line ending corrupted for file: %(file)s; "
606
 
            "Maybe your files got corrupted in transport?")
607
 
 
608
 
    def __init__(self, file):
609
 
        self.file = file
610
 
 
611
 
 
612
566
class IncompatibleFormat(BzrError):
613
567
 
614
568
    _fmt = "Format %(format)s is not compatible with .bzr version %(controldir)s."
976
930
        self.revision_id = revision_id
977
931
 
978
932
 
979
 
class InvalidRevisionSpec(BzrError):
980
 
 
981
 
    _fmt = ("Requested revision: '%(spec)s' does not exist in branch:"
982
 
            " %(branch_url)s%(extra)s")
983
 
 
984
 
    def __init__(self, spec, branch, extra=None):
985
 
        BzrError.__init__(self, branch=branch, spec=spec)
986
 
        self.branch_url = getattr(branch, 'user_url', str(branch))
987
 
        if extra:
988
 
            self.extra = '\n' + str(extra)
989
 
        else:
990
 
            self.extra = ''
991
 
 
992
 
 
993
933
class AppendRevisionsOnlyViolation(BzrError):
994
934
 
995
935
    _fmt = ('Operation denied because it would change the main history,'
1340
1280
        TransportError.__init__(self, msg, orig_error=orig_error)
1341
1281
 
1342
1282
 
 
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
 
1343
1308
class InvalidHttpRange(InvalidHttpResponse):
1344
1309
 
1345
1310
    _fmt = "Invalid http range %(range)r for %(path)s: %(msg)s"
1495
1460
        self.file_id = file_id
1496
1461
 
1497
1462
 
1498
 
class DuplicateFileId(BzrError):
1499
 
 
1500
 
    _fmt = "File id {%(file_id)s} already exists in inventory as %(entry)s"
1501
 
 
1502
 
    def __init__(self, file_id, entry):
1503
 
        BzrError.__init__(self)
1504
 
        self.file_id = file_id
1505
 
        self.entry = entry
1506
 
 
1507
 
 
1508
1463
class DuplicateKey(BzrError):
1509
1464
 
1510
1465
    _fmt = "Key %(key)s is already present in map"
1518
1473
        self.prefix = prefix
1519
1474
 
1520
1475
 
1521
 
class MalformedTransform(InternalBzrError):
1522
 
 
1523
 
    _fmt = "Tree transform is malformed %(conflicts)r"
1524
 
 
1525
 
 
1526
 
class NoFinalPath(BzrError):
1527
 
 
1528
 
    _fmt = ("No final name for trans_id %(trans_id)r\n"
1529
 
            "file-id: %(file_id)r\n"
1530
 
            "root trans-id: %(root_trans_id)r\n")
1531
 
 
1532
 
    def __init__(self, trans_id, transform):
1533
 
        self.trans_id = trans_id
1534
 
        self.file_id = transform.final_file_id(trans_id)
1535
 
        self.root_trans_id = transform.root
1536
 
 
1537
 
 
1538
1476
class BzrBadParameter(InternalBzrError):
1539
1477
 
1540
1478
    _fmt = "Bad parameter: %(param)r"
1552
1490
    _fmt = "Parameter %(param)s is neither unicode nor utf8."
1553
1491
 
1554
1492
 
1555
 
class ReusingTransform(BzrError):
1556
 
 
1557
 
    _fmt = "Attempt to reuse a transform that has already been applied."
1558
 
 
1559
 
 
1560
 
class CantMoveRoot(BzrError):
1561
 
 
1562
 
    _fmt = "Moving the root directory is not supported at this time"
1563
 
 
1564
 
 
1565
 
class TransformRenameFailed(BzrError):
1566
 
 
1567
 
    _fmt = "Failed to rename %(from_path)s to %(to_path)s: %(why)s"
1568
 
 
1569
 
    def __init__(self, from_path, to_path, why, errno):
1570
 
        self.from_path = from_path
1571
 
        self.to_path = to_path
1572
 
        self.why = why
1573
 
        self.errno = errno
1574
 
 
1575
 
 
1576
1493
class BzrMoveFailedError(BzrError):
1577
1494
 
1578
1495
    _fmt = ("Could not move %(from_path)s%(operator)s %(to_path)s"
1702
1619
    _fmt = "Diff3 is not installed on this machine."
1703
1620
 
1704
1621
 
1705
 
class ExistingContent(BzrError):
1706
 
    # Added in breezy 0.92, used by VersionedFile.add_lines.
1707
 
 
1708
 
    _fmt = "The content being inserted is already present."
1709
 
 
1710
 
 
1711
1622
class ExistingLimbo(BzrError):
1712
1623
 
1713
1624
    _fmt = """This tree contains left-over files from a failed operation.
1729
1640
        BzrError.__init__(self, pending_deletion=pending_deletion)
1730
1641
 
1731
1642
 
1732
 
class ImmortalLimbo(BzrError):
1733
 
 
1734
 
    _fmt = """Unable to delete transform temporary directory %(limbo_dir)s.
1735
 
    Please examine %(limbo_dir)s to see if it contains any files you wish to
1736
 
    keep, and delete it when you are done."""
1737
 
 
1738
 
    def __init__(self, limbo_dir):
1739
 
        BzrError.__init__(self)
1740
 
        self.limbo_dir = limbo_dir
1741
 
 
1742
 
 
1743
1643
class ImmortalPendingDeletion(BzrError):
1744
1644
 
1745
1645
    _fmt = ("Unable to delete transform temporary directory "
1966
1866
        self.other = other
1967
1867
 
1968
1868
 
1969
 
class BadInventoryFormat(BzrError):
1970
 
 
1971
 
    _fmt = "Root class for inventory serialization errors"
1972
 
 
1973
 
 
1974
 
class UnexpectedInventoryFormat(BadInventoryFormat):
1975
 
 
1976
 
    _fmt = "The inventory was not in the expected format:\n %(msg)s"
1977
 
 
1978
 
    def __init__(self, msg):
1979
 
        BadInventoryFormat.__init__(self, msg=msg)
1980
 
 
1981
 
 
1982
1869
class RootNotRich(BzrError):
1983
1870
 
1984
1871
    _fmt = """This operation requires rich root data storage"""
2041
1928
        " branch location."
2042
1929
 
2043
1930
 
2044
 
class IllegalMergeDirectivePayload(BzrError):
2045
 
    """A merge directive contained something other than a patch or bundle"""
2046
 
 
2047
 
    _fmt = "Bad merge directive payload %(start)r"
2048
 
 
2049
 
    def __init__(self, start):
2050
 
        BzrError(self)
2051
 
        self.start = start
2052
 
 
2053
 
 
2054
1931
class PatchVerificationFailed(BzrError):
2055
1932
    """A patch from a merge directive could not be verified"""
2056
1933
 
2080
1957
        self.location = location
2081
1958
 
2082
1959
 
2083
 
class UnsupportedInventoryKind(BzrError):
2084
 
 
2085
 
    _fmt = """Unsupported entry kind %(kind)s"""
2086
 
 
2087
 
    def __init__(self, kind):
2088
 
        self.kind = kind
2089
 
 
2090
 
 
2091
1960
class BadSubsumeSource(BzrError):
2092
1961
 
2093
1962
    _fmt = "Can't subsume %(other_tree)s into %(tree)s. %(reason)s"
2413
2282
        self.format = format
2414
2283
 
2415
2284
 
2416
 
class ChangesAlreadyStored(BzrCommandError):
 
2285
class ChangesAlreadyStored(CommandError):
2417
2286
 
2418
2287
    _fmt = ('Cannot store uncommitted changes because this branch already'
2419
2288
            ' stores uncommitted changes.')