/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: Gustav Hartvigsson
  • Date: 2021-01-09 21:36:27 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20210109213627-h1xwcutzy9m7a99b
Added 'Case Preserving Working Tree Use Cases' from Canonical Wiki

* Addod a page from the Canonical Bazaar wiki
  with information on the scmeatics of case
  perserving filesystems an a case insensitive
  filesystem works.
  
  * Needs re-work, but this will do as it is the
    same inforamoton as what was on the linked
    page in the currint documentation.

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".'
284
255
        self.base = base
285
256
 
286
257
 
287
 
class BzrCommandError(BzrError):
 
258
class NoWhoami(BzrError):
 
259
 
 
260
    _fmt = ('Unable to determine your name.\n'
 
261
            "Please, set your name with the 'whoami' command.\n"
 
262
            'E.g. brz whoami "Your Name <name@example.com>"')
 
263
 
 
264
 
 
265
class CommandError(BzrError):
288
266
    """Error from user command"""
289
267
 
290
268
    # Error from malformed user command; please avoid raising this as a
292
270
    #
293
271
    # I think it's a waste of effort to differentiate between errors that
294
272
    # are not intended to be caught anyway.  UI code need not subclass
295
 
    # BzrCommandError, and non-UI code should not throw a subclass of
296
 
    # 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
297
279
 
298
280
 
299
281
class NotWriteLocked(BzrError):
395
377
    _fmt = 'Permission denied: "%(path)s"%(extra)s'
396
378
 
397
379
 
398
 
class UnavailableRepresentation(InternalBzrError):
399
 
 
400
 
    _fmt = ("The encoding '%(wanted)s' is not available for key %(key)s which "
401
 
            "is encoded as '%(native)s'.")
402
 
 
403
 
    def __init__(self, key, wanted, native):
404
 
        InternalBzrError.__init__(self)
405
 
        self.wanted = wanted
406
 
        self.native = native
407
 
        self.key = key
408
 
 
409
 
 
410
380
class UnsupportedProtocol(PathError):
411
381
 
412
382
    _fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'
593
563
        self.format = format
594
564
 
595
565
 
596
 
class LineEndingError(BzrError):
597
 
 
598
 
    _fmt = ("Line ending corrupted for file: %(file)s; "
599
 
            "Maybe your files got corrupted in transport?")
600
 
 
601
 
    def __init__(self, file):
602
 
        self.file = file
603
 
 
604
 
 
605
566
class IncompatibleFormat(BzrError):
606
567
 
607
568
    _fmt = "Format %(format)s is not compatible with .bzr version %(controldir)s."
969
930
        self.revision_id = revision_id
970
931
 
971
932
 
972
 
class InvalidRevisionSpec(BzrError):
973
 
 
974
 
    _fmt = ("Requested revision: '%(spec)s' does not exist in branch:"
975
 
            " %(branch_url)s%(extra)s")
976
 
 
977
 
    def __init__(self, spec, branch, extra=None):
978
 
        BzrError.__init__(self, branch=branch, spec=spec)
979
 
        self.branch_url = getattr(branch, 'user_url', str(branch))
980
 
        if extra:
981
 
            self.extra = '\n' + str(extra)
982
 
        else:
983
 
            self.extra = ''
984
 
 
985
 
 
986
933
class AppendRevisionsOnlyViolation(BzrError):
987
934
 
988
935
    _fmt = ('Operation denied because it would change the main history,'
1333
1280
        TransportError.__init__(self, msg, orig_error=orig_error)
1334
1281
 
1335
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
 
1336
1308
class InvalidHttpRange(InvalidHttpResponse):
1337
1309
 
1338
1310
    _fmt = "Invalid http range %(range)r for %(path)s: %(msg)s"
1488
1460
        self.file_id = file_id
1489
1461
 
1490
1462
 
1491
 
class DuplicateFileId(BzrError):
1492
 
 
1493
 
    _fmt = "File id {%(file_id)s} already exists in inventory as %(entry)s"
1494
 
 
1495
 
    def __init__(self, file_id, entry):
1496
 
        BzrError.__init__(self)
1497
 
        self.file_id = file_id
1498
 
        self.entry = entry
1499
 
 
1500
 
 
1501
1463
class DuplicateKey(BzrError):
1502
1464
 
1503
1465
    _fmt = "Key %(key)s is already present in map"
1511
1473
        self.prefix = prefix
1512
1474
 
1513
1475
 
1514
 
class MalformedTransform(InternalBzrError):
1515
 
 
1516
 
    _fmt = "Tree transform is malformed %(conflicts)r"
1517
 
 
1518
 
 
1519
 
class NoFinalPath(BzrError):
1520
 
 
1521
 
    _fmt = ("No final name for trans_id %(trans_id)r\n"
1522
 
            "file-id: %(file_id)r\n"
1523
 
            "root trans-id: %(root_trans_id)r\n")
1524
 
 
1525
 
    def __init__(self, trans_id, transform):
1526
 
        self.trans_id = trans_id
1527
 
        self.file_id = transform.final_file_id(trans_id)
1528
 
        self.root_trans_id = transform.root
1529
 
 
1530
 
 
1531
1476
class BzrBadParameter(InternalBzrError):
1532
1477
 
1533
1478
    _fmt = "Bad parameter: %(param)r"
1545
1490
    _fmt = "Parameter %(param)s is neither unicode nor utf8."
1546
1491
 
1547
1492
 
1548
 
class ReusingTransform(BzrError):
1549
 
 
1550
 
    _fmt = "Attempt to reuse a transform that has already been applied."
1551
 
 
1552
 
 
1553
 
class CantMoveRoot(BzrError):
1554
 
 
1555
 
    _fmt = "Moving the root directory is not supported at this time"
1556
 
 
1557
 
 
1558
 
class TransformRenameFailed(BzrError):
1559
 
 
1560
 
    _fmt = "Failed to rename %(from_path)s to %(to_path)s: %(why)s"
1561
 
 
1562
 
    def __init__(self, from_path, to_path, why, errno):
1563
 
        self.from_path = from_path
1564
 
        self.to_path = to_path
1565
 
        self.why = why
1566
 
        self.errno = errno
1567
 
 
1568
 
 
1569
1493
class BzrMoveFailedError(BzrError):
1570
1494
 
1571
1495
    _fmt = ("Could not move %(from_path)s%(operator)s %(to_path)s"
1695
1619
    _fmt = "Diff3 is not installed on this machine."
1696
1620
 
1697
1621
 
1698
 
class ExistingContent(BzrError):
1699
 
    # Added in breezy 0.92, used by VersionedFile.add_lines.
1700
 
 
1701
 
    _fmt = "The content being inserted is already present."
1702
 
 
1703
 
 
1704
1622
class ExistingLimbo(BzrError):
1705
1623
 
1706
1624
    _fmt = """This tree contains left-over files from a failed operation.
1722
1640
        BzrError.__init__(self, pending_deletion=pending_deletion)
1723
1641
 
1724
1642
 
1725
 
class ImmortalLimbo(BzrError):
1726
 
 
1727
 
    _fmt = """Unable to delete transform temporary directory %(limbo_dir)s.
1728
 
    Please examine %(limbo_dir)s to see if it contains any files you wish to
1729
 
    keep, and delete it when you are done."""
1730
 
 
1731
 
    def __init__(self, limbo_dir):
1732
 
        BzrError.__init__(self)
1733
 
        self.limbo_dir = limbo_dir
1734
 
 
1735
 
 
1736
1643
class ImmortalPendingDeletion(BzrError):
1737
1644
 
1738
1645
    _fmt = ("Unable to delete transform temporary directory "
1865
1772
    """
1866
1773
 
1867
1774
 
 
1775
class SharedRepositoriesUnsupported(UnsupportedOperation):
 
1776
    _fmt = "Shared repositories are not supported by %(format)r."
 
1777
 
 
1778
    def __init__(self, format):
 
1779
        BzrError.__init__(self, format=format)
 
1780
 
 
1781
 
1868
1782
class GhostTagsNotSupported(BzrError):
1869
1783
 
1870
1784
    _fmt = "Ghost tags not supported by format %(format)r."
1952
1866
        self.other = other
1953
1867
 
1954
1868
 
1955
 
class BadInventoryFormat(BzrError):
1956
 
 
1957
 
    _fmt = "Root class for inventory serialization errors"
1958
 
 
1959
 
 
1960
 
class UnexpectedInventoryFormat(BadInventoryFormat):
1961
 
 
1962
 
    _fmt = "The inventory was not in the expected format:\n %(msg)s"
1963
 
 
1964
 
    def __init__(self, msg):
1965
 
        BadInventoryFormat.__init__(self, msg=msg)
1966
 
 
1967
 
 
1968
1869
class RootNotRich(BzrError):
1969
1870
 
1970
1871
    _fmt = """This operation requires rich root data storage"""
2013
1914
        self.revision_id = revision_id
2014
1915
 
2015
1916
 
2016
 
class IllegalUseOfScopeReplacer(InternalBzrError):
2017
 
 
2018
 
    _fmt = ("ScopeReplacer object %(name)r was used incorrectly:"
2019
 
            " %(msg)s%(extra)s")
2020
 
 
2021
 
    def __init__(self, name, msg, extra=None):
2022
 
        BzrError.__init__(self)
2023
 
        self.name = name
2024
 
        self.msg = msg
2025
 
        if extra:
2026
 
            self.extra = ': ' + str(extra)
2027
 
        else:
2028
 
            self.extra = ''
2029
 
 
2030
 
 
2031
 
class InvalidImportLine(InternalBzrError):
2032
 
 
2033
 
    _fmt = "Not a valid import statement: %(msg)\n%(text)s"
2034
 
 
2035
 
    def __init__(self, text, msg):
2036
 
        BzrError.__init__(self)
2037
 
        self.text = text
2038
 
        self.msg = msg
2039
 
 
2040
 
 
2041
 
class ImportNameCollision(InternalBzrError):
2042
 
 
2043
 
    _fmt = ("Tried to import an object to the same name as"
2044
 
            " an existing object. %(name)s")
2045
 
 
2046
 
    def __init__(self, name):
2047
 
        BzrError.__init__(self)
2048
 
        self.name = name
2049
 
 
2050
 
 
2051
1917
class NotAMergeDirective(BzrError):
2052
1918
    """File starting with %(firstline)r is not a merge directive"""
2053
1919
 
2062
1928
        " branch location."
2063
1929
 
2064
1930
 
2065
 
class IllegalMergeDirectivePayload(BzrError):
2066
 
    """A merge directive contained something other than a patch or bundle"""
2067
 
 
2068
 
    _fmt = "Bad merge directive payload %(start)r"
2069
 
 
2070
 
    def __init__(self, start):
2071
 
        BzrError(self)
2072
 
        self.start = start
2073
 
 
2074
 
 
2075
1931
class PatchVerificationFailed(BzrError):
2076
1932
    """A patch from a merge directive could not be verified"""
2077
1933
 
2101
1957
        self.location = location
2102
1958
 
2103
1959
 
2104
 
class UnsupportedInventoryKind(BzrError):
2105
 
 
2106
 
    _fmt = """Unsupported entry kind %(kind)s"""
2107
 
 
2108
 
    def __init__(self, kind):
2109
 
        self.kind = kind
2110
 
 
2111
 
 
2112
1960
class BadSubsumeSource(BzrError):
2113
1961
 
2114
1962
    _fmt = "Can't subsume %(other_tree)s into %(tree)s. %(reason)s"
2138
1986
class TagsNotSupported(BzrError):
2139
1987
 
2140
1988
    _fmt = ("Tags not supported by %(branch)s;"
2141
 
            " you may be able to use brz upgrade.")
 
1989
            " you may be able to use 'brz upgrade %(branch_url)s'.")
2142
1990
 
2143
1991
    def __init__(self, branch):
2144
1992
        self.branch = branch
 
1993
        self.branch_url = branch.user_url
2145
1994
 
2146
1995
 
2147
1996
class TagAlreadyExists(BzrError):
2303
2152
            ' (See brz shelve --list).%(more)s')
2304
2153
 
2305
2154
 
2306
 
class UnableCreateSymlink(BzrError):
2307
 
 
2308
 
    _fmt = 'Unable to create symlink %(path_str)son this platform'
2309
 
 
2310
 
    def __init__(self, path=None):
2311
 
        path_str = ''
2312
 
        if path:
2313
 
            try:
2314
 
                path_str = repr(str(path))
2315
 
            except UnicodeEncodeError:
2316
 
                path_str = repr(path)
2317
 
            path_str += ' '
2318
 
        self.path_str = path_str
2319
 
 
2320
 
 
2321
2155
class UnableEncodePath(BzrError):
2322
2156
 
2323
2157
    _fmt = ('Unable to encode %(kind)s path %(path)r in '
2448
2282
        self.format = format
2449
2283
 
2450
2284
 
2451
 
class ChangesAlreadyStored(BzrCommandError):
 
2285
class ChangesAlreadyStored(CommandError):
2452
2286
 
2453
2287
    _fmt = ('Cannot store uncommitted changes because this branch already'
2454
2288
            ' stores uncommitted changes.')
 
2289
 
 
2290
 
 
2291
class RevnoOutOfBounds(InternalBzrError):
 
2292
 
 
2293
    _fmt = ("The requested revision number %(revno)d is outside of the "
 
2294
            "expected boundaries (%(minimum)d <= %(maximum)d).")
 
2295
 
 
2296
    def __init__(self, revno, bounds):
 
2297
        InternalBzrError.__init__(
 
2298
            self, revno=revno, minimum=bounds[0], maximum=bounds[1])