/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

Merge test-run support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
124
124
        fmt = getattr(self, '_fmt', None)
125
125
        if fmt is not None:
126
126
            from breezy.i18n import gettext
127
 
            return gettext(fmt)  # _fmt strings should be ascii
 
127
            return gettext(fmt) # _fmt strings should be ascii
128
128
 
129
129
    def __eq__(self, other):
130
130
        if self.__class__ is not other.__class__:
222
222
class RootMissing(InternalBzrError):
223
223
 
224
224
    _fmt = ("The root entry of a tree must be the first entry supplied to "
225
 
            "the commit builder.")
 
225
        "the commit builder.")
226
226
 
227
227
 
228
228
class NoPublicBranch(BzrError):
284
284
        self.base = base
285
285
 
286
286
 
287
 
class NoWhoami(BzrError):
288
 
 
289
 
    _fmt = ('Unable to determine your name.\n'
290
 
            "Please, set your name with the 'whoami' command.\n"
291
 
            'E.g. brz whoami "Your Name <name@example.com>"')
292
 
 
293
 
 
294
287
class BzrCommandError(BzrError):
295
288
    """Error from user command"""
296
289
 
405
398
class UnavailableRepresentation(InternalBzrError):
406
399
 
407
400
    _fmt = ("The encoding '%(wanted)s' is not available for key %(key)s which "
408
 
            "is encoded as '%(native)s'.")
 
401
        "is encoded as '%(native)s'.")
409
402
 
410
403
    def __init__(self, key, wanted, native):
411
404
        InternalBzrError.__init__(self)
435
428
class UnstackableRepositoryFormat(BzrError):
436
429
 
437
430
    _fmt = ("The repository '%(url)s'(%(format)s) is not a stackable format. "
438
 
            "You will need to upgrade the repository to permit branch stacking.")
 
431
        "You will need to upgrade the repository to permit branch stacking.")
439
432
 
440
433
    def __init__(self, format, url):
441
434
        BzrError.__init__(self)
491
484
    _fmt = 'Not a branch: "%(path)s"%(detail)s.'
492
485
 
493
486
    def __init__(self, path, detail=None, controldir=None):
494
 
        from . import urlutils
495
 
        path = urlutils.unescape_for_display(path, 'ascii')
496
 
        if detail is not None:
497
 
            detail = ': ' + detail
498
 
        self.detail = detail
499
 
        self.controldir = controldir
500
 
        PathError.__init__(self, path=path)
 
487
       from . import urlutils
 
488
       path = urlutils.unescape_for_display(path, 'ascii')
 
489
       if detail is not None:
 
490
           detail = ': ' + detail
 
491
       self.detail = detail
 
492
       self.controldir = controldir
 
493
       PathError.__init__(self, path=path)
501
494
 
502
495
    def __repr__(self):
503
496
        return '<%s %r>' % (self.__class__.__name__, self.__dict__)
505
498
    def _get_format_string(self):
506
499
        # GZ 2017-06-08: Not the best place to lazy fill detail in.
507
500
        if self.detail is None:
508
 
            self.detail = self._get_detail()
 
501
           self.detail = self._get_detail()
509
502
        return super(NotBranchError, self)._get_format_string()
510
503
 
511
504
    def _get_detail(self):
533
526
    _fmt = 'No submit branch available for branch "%(path)s"'
534
527
 
535
528
    def __init__(self, branch):
536
 
        from . import urlutils
537
 
        self.path = urlutils.unescape_for_display(branch.base, 'ascii')
 
529
       from . import urlutils
 
530
       self.path = urlutils.unescape_for_display(branch.base, 'ascii')
538
531
 
539
532
 
540
533
class AlreadyControlDirError(PathError):
567
560
(use brz checkout if you wish to build a working tree): "%(path)s"'
568
561
 
569
562
 
 
563
class AtomicFileAlreadyClosed(PathError):
 
564
 
 
565
    _fmt = ('"%(function)s" called on an AtomicFile after it was closed:'
 
566
            ' "%(path)s"')
 
567
 
 
568
    def __init__(self, path, function):
 
569
        PathError.__init__(self, path=path, extra=None)
 
570
        self.function = function
 
571
 
 
572
 
570
573
class InaccessibleParent(PathError):
571
574
 
572
575
    _fmt = ('Parent not accessible given base "%(base)s" and'
580
583
class NoRepositoryPresent(BzrError):
581
584
 
582
585
    _fmt = 'No repository present: "%(path)s"'
583
 
 
584
586
    def __init__(self, controldir):
585
587
        BzrError.__init__(self)
586
588
        self.path = controldir.transport.clone('..').base
600
602
        self.format = format
601
603
 
602
604
 
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
605
class IncompatibleFormat(BzrError):
613
606
 
614
607
    _fmt = "Format %(format)s is not compatible with .bzr version %(controldir)s."
640
633
    """
641
634
 
642
635
    _fmt = "%(target)s\n" \
643
 
        "is not compatible with\n" \
644
 
        "%(source)s\n" \
645
 
        "%(details)s"
 
636
            "is not compatible with\n" \
 
637
            "%(source)s\n" \
 
638
            "%(details)s"
646
639
 
647
640
    def __init__(self, source, target, details=None):
648
641
        if details is None:
993
986
class AppendRevisionsOnlyViolation(BzrError):
994
987
 
995
988
    _fmt = ('Operation denied because it would change the main history,'
996
 
            ' which is not permitted by the append_revisions_only setting on'
997
 
            ' branch "%(location)s".')
 
989
           ' which is not permitted by the append_revisions_only setting on'
 
990
           ' branch "%(location)s".')
998
991
 
999
992
    def __init__(self, location):
1000
 
        import breezy.urlutils as urlutils
1001
 
        location = urlutils.unescape_for_display(location, 'ascii')
1002
 
        BzrError.__init__(self, location=location)
 
993
       import breezy.urlutils as urlutils
 
994
       location = urlutils.unescape_for_display(location, 'ascii')
 
995
       BzrError.__init__(self, location=location)
1003
996
 
1004
997
 
1005
998
class DivergedBranches(BzrError):
1045
1038
class NoCommonRoot(BzrError):
1046
1039
 
1047
1040
    _fmt = ("Revisions are not derived from the same root: "
1048
 
            "%(revision_a)s %(revision_b)s.")
 
1041
           "%(revision_a)s %(revision_b)s.")
1049
1042
 
1050
1043
    def __init__(self, revision_a, revision_b):
1051
1044
        BzrError.__init__(self, revision_a=revision_a, revision_b=revision_b)
1057
1050
 
1058
1051
    def __init__(self, rev_id, not_ancestor_id):
1059
1052
        BzrError.__init__(self, rev_id=rev_id,
1060
 
                          not_ancestor_id=not_ancestor_id)
 
1053
            not_ancestor_id=not_ancestor_id)
1061
1054
 
1062
1055
 
1063
1056
class NoCommits(BranchError):
1071
1064
        BzrError.__init__(self, "Store %s is not listable" % store)
1072
1065
 
1073
1066
 
 
1067
 
1074
1068
class UnlistableBranch(BzrError):
1075
1069
 
1076
1070
    def __init__(self, br):
1218
1212
        if orig_error is None:
1219
1213
            orig_error = ''
1220
1214
        if msg is None:
1221
 
            msg = ''
 
1215
            msg =  ''
1222
1216
        self.msg = msg
1223
1217
        self.orig_error = orig_error
1224
1218
        BzrError.__init__(self)
1269
1263
        self.exc_type, self.exc_value, self.exc_tb = exc_info
1270
1264
        self.exc_info = exc_info
1271
1265
        traceback_strings = traceback.format_exception(
1272
 
            self.exc_type, self.exc_value, self.exc_tb)
 
1266
                self.exc_type, self.exc_value, self.exc_tb)
1273
1267
        self.traceback_text = ''.join(traceback_strings)
1274
1268
 
1275
1269
 
1413
1407
        BzrError.__init__(self, basedir=tree.basedir)
1414
1408
 
1415
1409
 
 
1410
class CantReprocessAndShowBase(BzrError):
 
1411
 
 
1412
    _fmt = ("Can't reprocess and show base, because reprocessing obscures "
 
1413
           "the relationship of conflicting lines to the base")
 
1414
 
 
1415
 
1416
1416
class GraphCycleError(BzrError):
1417
1417
 
1418
1418
    _fmt = "Cycle in graph %(graph)r"
1576
1576
class BzrMoveFailedError(BzrError):
1577
1577
 
1578
1578
    _fmt = ("Could not move %(from_path)s%(operator)s %(to_path)s"
1579
 
            "%(_has_extra)s%(extra)s")
 
1579
        "%(_has_extra)s%(extra)s")
1580
1580
 
1581
1581
    def __init__(self, from_path='', to_path='', extra=None):
1582
1582
        from breezy.osutils import splitpath
1612
1612
class BzrRenameFailedError(BzrMoveFailedError):
1613
1613
 
1614
1614
    _fmt = ("Could not rename %(from_path)s%(operator)s %(to_path)s"
1615
 
            "%(_has_extra)s%(extra)s")
 
1615
        "%(_has_extra)s%(extra)s")
1616
1616
 
1617
1617
    def __init__(self, from_path, to_path, extra=None):
1618
1618
        BzrMoveFailedError.__init__(self, from_path, to_path, extra)
1664
1664
class BadConversionTarget(BzrError):
1665
1665
 
1666
1666
    _fmt = "Cannot convert from format %(from_format)s to format %(format)s." \
1667
 
        "    %(problem)s"
 
1667
            "    %(problem)s"
1668
1668
 
1669
1669
    def __init__(self, problem, format, from_format=None):
1670
1670
        BzrError.__init__(self)
1715
1715
    keep, and delete it when you are done."""
1716
1716
 
1717
1717
    def __init__(self, limbo_dir):
1718
 
        BzrError.__init__(self)
1719
 
        self.limbo_dir = limbo_dir
 
1718
       BzrError.__init__(self)
 
1719
       self.limbo_dir = limbo_dir
1720
1720
 
1721
1721
 
1722
1722
class ExistingPendingDeletion(BzrError):
1726
1726
    wish to keep, and delete it when you are done."""
1727
1727
 
1728
1728
    def __init__(self, pending_deletion):
1729
 
        BzrError.__init__(self, pending_deletion=pending_deletion)
 
1729
       BzrError.__init__(self, pending_deletion=pending_deletion)
1730
1730
 
1731
1731
 
1732
1732
class ImmortalLimbo(BzrError):
1736
1736
    keep, and delete it when you are done."""
1737
1737
 
1738
1738
    def __init__(self, limbo_dir):
1739
 
        BzrError.__init__(self)
1740
 
        self.limbo_dir = limbo_dir
 
1739
       BzrError.__init__(self)
 
1740
       self.limbo_dir = limbo_dir
1741
1741
 
1742
1742
 
1743
1743
class ImmortalPendingDeletion(BzrError):
1744
1744
 
1745
1745
    _fmt = ("Unable to delete transform temporary directory "
1746
 
            "%(pending_deletion)s.  Please examine %(pending_deletion)s to see if it "
1747
 
            "contains any files you wish to keep, and delete it when you are done.")
 
1746
    "%(pending_deletion)s.  Please examine %(pending_deletion)s to see if it "
 
1747
    "contains any files you wish to keep, and delete it when you are done.")
1748
1748
 
1749
1749
    def __init__(self, pending_deletion):
1750
 
        BzrError.__init__(self, pending_deletion=pending_deletion)
 
1750
       BzrError.__init__(self, pending_deletion=pending_deletion)
1751
1751
 
1752
1752
 
1753
1753
class OutOfDateTree(BzrError):
1839
1839
class RichRootUpgradeRequired(UpgradeRequired):
1840
1840
 
1841
1841
    _fmt = ("To use this feature you must upgrade your branch at %(path)s to"
1842
 
            " a format which supports rich roots.")
 
1842
           " a format which supports rich roots.")
1843
1843
 
1844
1844
 
1845
1845
class LocalRequiresBoundBranch(BzrError):
1872
1872
    """
1873
1873
 
1874
1874
 
1875
 
class SharedRepositoriesUnsupported(UnsupportedOperation):
1876
 
    _fmt = "Shared repositories are not supported by %(format)r."
1877
 
 
1878
 
    def __init__(self, format):
1879
 
        BzrError.__init__(self, format=format)
1880
 
 
1881
 
 
1882
1875
class GhostTagsNotSupported(BzrError):
1883
1876
 
1884
1877
    _fmt = "Ghost tags not supported by format %(format)r."
2027
2020
        self.revision_id = revision_id
2028
2021
 
2029
2022
 
 
2023
class IllegalUseOfScopeReplacer(InternalBzrError):
 
2024
 
 
2025
    _fmt = ("ScopeReplacer object %(name)r was used incorrectly:"
 
2026
            " %(msg)s%(extra)s")
 
2027
 
 
2028
    def __init__(self, name, msg, extra=None):
 
2029
        BzrError.__init__(self)
 
2030
        self.name = name
 
2031
        self.msg = msg
 
2032
        if extra:
 
2033
            self.extra = ': ' + str(extra)
 
2034
        else:
 
2035
            self.extra = ''
 
2036
 
 
2037
 
 
2038
class InvalidImportLine(InternalBzrError):
 
2039
 
 
2040
    _fmt = "Not a valid import statement: %(msg)\n%(text)s"
 
2041
 
 
2042
    def __init__(self, text, msg):
 
2043
        BzrError.__init__(self)
 
2044
        self.text = text
 
2045
        self.msg = msg
 
2046
 
 
2047
 
 
2048
class ImportNameCollision(InternalBzrError):
 
2049
 
 
2050
    _fmt = ("Tried to import an object to the same name as"
 
2051
            " an existing object. %(name)s")
 
2052
 
 
2053
    def __init__(self, name):
 
2054
        BzrError.__init__(self)
 
2055
        self.name = name
 
2056
 
 
2057
 
2030
2058
class NotAMergeDirective(BzrError):
2031
2059
    """File starting with %(firstline)r is not a merge directive"""
2032
 
 
2033
2060
    def __init__(self, firstline):
2034
2061
        BzrError.__init__(self, firstline=firstline)
2035
2062
 
2117
2144
class TagsNotSupported(BzrError):
2118
2145
 
2119
2146
    _fmt = ("Tags not supported by %(branch)s;"
2120
 
            " you may be able to use 'brz upgrade %(branch_url)s'.")
 
2147
            " you may be able to use brz upgrade.")
2121
2148
 
2122
2149
    def __init__(self, branch):
2123
2150
        self.branch = branch
2124
 
        self.branch_url = branch.user_url
2125
2151
 
2126
2152
 
2127
2153
class TagAlreadyExists(BzrError):
2283
2309
            ' (See brz shelve --list).%(more)s')
2284
2310
 
2285
2311
 
 
2312
class UnableCreateSymlink(BzrError):
 
2313
 
 
2314
    _fmt = 'Unable to create symlink %(path_str)son this platform'
 
2315
 
 
2316
    def __init__(self, path=None):
 
2317
        path_str = ''
 
2318
        if path:
 
2319
            try:
 
2320
                path_str = repr(str(path))
 
2321
            except UnicodeEncodeError:
 
2322
                path_str = repr(path)
 
2323
            path_str += ' '
 
2324
        self.path_str = path_str
 
2325
 
 
2326
 
2286
2327
class UnableEncodePath(BzrError):
2287
2328
 
2288
2329
    _fmt = ('Unable to encode %(kind)s path %(path)r in '
2310
2351
    def __init__(self, host, port, orig_error):
2311
2352
        # nb: in python2.4 socket.error doesn't have a useful repr
2312
2353
        BzrError.__init__(self, host=host, port=port,
2313
 
                          orig_error=repr(orig_error.args))
 
2354
            orig_error=repr(orig_error.args))
2314
2355
 
2315
2356
 
2316
2357
class TipChangeRejected(BzrError):
2395
2436
class RecursiveBind(BzrError):
2396
2437
 
2397
2438
    _fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
2398
 
            'Please use `brz unbind` to fix.')
 
2439
        'Please use `brz unbind` to fix.')
2399
2440
 
2400
2441
    def __init__(self, branch_url):
2401
2442
        self.branch_url = branch_url
2417
2458
 
2418
2459
    _fmt = ('Cannot store uncommitted changes because this branch already'
2419
2460
            ' stores uncommitted changes.')
2420
 
 
2421
 
 
2422
 
class RevnoOutOfBounds(InternalBzrError):
2423
 
 
2424
 
    _fmt = ("The requested revision number %(revno)d is outside of the "
2425
 
            "expected boundaries (%(minimum)d <= %(maximum)d).")
2426
 
 
2427
 
    def __init__(self, revno, bounds):
2428
 
        InternalBzrError.__init__(
2429
 
            self, revno=revno, minimum=bounds[0], maximum=bounds[1])