/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-08-10 15:00:17 UTC
  • mfrom: (7490.40.99 work)
  • mto: This revision was merged to the branch mainline in revision 7521.
  • Revision ID: jelmer@jelmer.uk-20200810150017-vs7xnrd1vat4iktg
Merge lp:brz/3.1.

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"
583
563
        self.format = format
584
564
 
585
565
 
586
 
class LineEndingError(BzrError):
587
 
 
588
 
    _fmt = ("Line ending corrupted for file: %(file)s; "
589
 
            "Maybe your files got corrupted in transport?")
590
 
 
591
 
    def __init__(self, file):
592
 
        self.file = file
593
 
 
594
 
 
595
566
class IncompatibleFormat(BzrError):
596
567
 
597
568
    _fmt = "Format %(format)s is not compatible with .bzr version %(controldir)s."
959
930
        self.revision_id = revision_id
960
931
 
961
932
 
962
 
class InvalidRevisionSpec(BzrError):
963
 
 
964
 
    _fmt = ("Requested revision: '%(spec)s' does not exist in branch:"
965
 
            " %(branch_url)s%(extra)s")
966
 
 
967
 
    def __init__(self, spec, branch, extra=None):
968
 
        BzrError.__init__(self, branch=branch, spec=spec)
969
 
        self.branch_url = getattr(branch, 'user_url', str(branch))
970
 
        if extra:
971
 
            self.extra = '\n' + str(extra)
972
 
        else:
973
 
            self.extra = ''
974
 
 
975
 
 
976
933
class AppendRevisionsOnlyViolation(BzrError):
977
934
 
978
935
    _fmt = ('Operation denied because it would change the main history,'
1323
1280
        TransportError.__init__(self, msg, orig_error=orig_error)
1324
1281
 
1325
1282
 
 
1283
class UnexpectedHttpStatus(InvalidHttpResponse):
 
1284
 
 
1285
    _fmt = "Unexpected HTTP status %(code)d for %(path)s: %(extra)s"
 
1286
 
 
1287
    def __init__(self, path, code, extra=None):
 
1288
        self.path = path
 
1289
        self.code = code
 
1290
        self.extra = extra or ''
 
1291
        full_msg = 'status code %d unexpected' % code
 
1292
        if extra is not None:
 
1293
            full_msg += ': ' + extra
 
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
 
1326
1308
class InvalidHttpRange(InvalidHttpResponse):
1327
1309
 
1328
1310
    _fmt = "Invalid http range %(range)r for %(path)s: %(msg)s"
1508
1490
    _fmt = "Parameter %(param)s is neither unicode nor utf8."
1509
1491
 
1510
1492
 
1511
 
class CantMoveRoot(BzrError):
1512
 
 
1513
 
    _fmt = "Moving the root directory is not supported at this time"
1514
 
 
1515
 
 
1516
 
class TransformRenameFailed(BzrError):
1517
 
 
1518
 
    _fmt = "Failed to rename %(from_path)s to %(to_path)s: %(why)s"
1519
 
 
1520
 
    def __init__(self, from_path, to_path, why, errno):
1521
 
        self.from_path = from_path
1522
 
        self.to_path = to_path
1523
 
        self.why = why
1524
 
        self.errno = errno
1525
 
 
1526
 
 
1527
1493
class BzrMoveFailedError(BzrError):
1528
1494
 
1529
1495
    _fmt = ("Could not move %(from_path)s%(operator)s %(to_path)s"