/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 bzrlib/errors.py

Merge from bzr.dev, resolving the worst of the semantic conflicts, but there's
still a little bit of breakage.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
132
132
    # readable explanation
133
133
 
134
134
    def __init__(self, *args, **kwds):
135
 
        # XXX: Use the underlying BzrError to always generate the args attribute
136
 
        # if it doesn't exist.  We can't use super here, because exceptions are
137
 
        # old-style classes in python2.4 (but new in 2.5).  --bmc, 20060426
 
135
        # XXX: Use the underlying BzrError to always generate the args
 
136
        # attribute if it doesn't exist.  We can't use super here, because
 
137
        # exceptions are old-style classes in python2.4 (but new in 2.5).
 
138
        # --bmc, 20060426
138
139
        symbol_versioning.warn('BzrNewError was deprecated in bzr 0.13; '
139
 
             'please convert %s to use BzrError instead' 
 
140
             'please convert %s to use BzrError instead'
140
141
             % self.__class__.__name__,
141
142
             DeprecationWarning,
142
143
             stacklevel=2)
234
235
 
235
236
class InventoryModified(BzrError):
236
237
 
237
 
    _fmt = ("The current inventory for the tree %(tree)r has been modified, "
238
 
            "so a clean inventory cannot be read without data loss.")
 
238
    _fmt = ("The current inventory for the tree %(tree)r has been modified,"
 
239
            " so a clean inventory cannot be read without data loss.")
239
240
 
240
241
    internal_error = True
241
242
 
353
354
    """Used when renaming and both source and dest exist."""
354
355
 
355
356
    _fmt = ("Could not rename %(source)s => %(dest)s because both files exist."
356
 
         "%(extra)s")
 
357
            "%(extra)s")
357
358
 
358
359
    def __init__(self, source, dest, extra=None):
359
360
        BzrError.__init__(self)
436
437
 
437
438
class ShortReadvError(PathError):
438
439
 
439
 
    _fmt = "readv() read %(actual)s bytes rather than %(length)s bytes at %(offset)s for %(path)s%(extra)s"
 
440
    _fmt = ("readv() read %(actual)s bytes rather than %(length)s bytes"
 
441
            " at %(offset)s for %(path)s%(extra)s")
440
442
 
441
443
    internal_error = True
442
444
 
480
482
       self.path = urlutils.unescape_for_display(path, 'ascii')
481
483
 
482
484
 
 
485
class NoSubmitBranch(PathError):
 
486
 
 
487
    _fmt = 'No submit branch available for branch "%(path)s"'
 
488
 
 
489
    def __init__(self, branch):
 
490
       import bzrlib.urlutils as urlutils
 
491
       self.path = urlutils.unescape_for_display(branch.base, 'ascii')
 
492
 
 
493
 
483
494
class AlreadyBranchError(PathError):
484
495
 
485
496
    _fmt = "Already a branch: %(path)s."
493
504
 
494
505
class AtomicFileAlreadyClosed(PathError):
495
506
 
496
 
    _fmt = "'%(function)s' called on an AtomicFile after it was closed: %(path)s"
 
507
    _fmt = ("'%(function)s' called on an AtomicFile after it was closed:"
 
508
            " %(path)s")
497
509
 
498
510
    def __init__(self, path, function):
499
511
        PathError.__init__(self, path=path, extra=None)
502
514
 
503
515
class InaccessibleParent(PathError):
504
516
 
505
 
    _fmt = "Parent not accessible given base %(base)s and relative path %(path)s"
 
517
    _fmt = ("Parent not accessible given base %(base)s and"
 
518
            " relative path %(path)s")
506
519
 
507
520
    def __init__(self, path, base):
508
521
        PathError.__init__(self, path)
563
576
    _fmt = "%(context_info)s%(path)s is already versioned"
564
577
 
565
578
    def __init__(self, path, context_info=None):
566
 
        """Construct a new NotVersionedError.
 
579
        """Construct a new AlreadyVersionedError.
567
580
 
568
581
        :param path: This is the path which is versioned,
569
582
        which should be in a user friendly form.
632
645
 
633
646
class BadFileKindError(BzrError):
634
647
 
635
 
    _fmt = "Cannot operate on %(filename)s of unsupported kind %(kind)s"
 
648
    _fmt = 'Cannot operate on "%(filename)s" of unsupported kind "%(kind)s"'
 
649
 
 
650
    def __init__(self, filename, kind):
 
651
        BzrError.__init__(self, filename=filename, kind=kind)
636
652
 
637
653
 
638
654
class ForbiddenControlFileError(BzrError):
655
671
        self.message = message
656
672
 
657
673
 
 
674
class LockActive(LockError):
 
675
 
 
676
    _fmt = "The lock for '%(lock_description)s' is in use and cannot be broken."
 
677
 
 
678
    internal_error = False
 
679
 
 
680
    def __init__(self, lock_description):
 
681
        self.lock_description = lock_description
 
682
 
 
683
 
658
684
class CommitNotPossible(LockError):
659
685
 
660
686
    _fmt = "A commit was attempted but we do not have a write lock open."
675
701
 
676
702
    _fmt = "A write attempt was made in a read only transaction on %(obj)s"
677
703
 
 
704
    # TODO: There should also be an error indicating that you need a write
 
705
    # lock and don't have any lock at all... mbp 20070226
 
706
 
678
707
    def __init__(self, obj):
679
708
        self.obj = obj
680
709
 
681
710
 
682
711
class OutSideTransaction(BzrError):
683
712
 
684
 
    _fmt = "A transaction related operation was attempted after the transaction finished."
 
713
    _fmt = ("A transaction related operation was attempted after"
 
714
            " the transaction finished.")
685
715
 
686
716
 
687
717
class ObjectNotLocked(LockError):
725
755
 
726
756
class LockBroken(LockError):
727
757
 
728
 
    _fmt = "Lock was broken while still open: %(lock)s - check storage consistency!"
 
758
    _fmt = ("Lock was broken while still open: %(lock)s"
 
759
            " - check storage consistency!")
729
760
 
730
761
    internal_error = False
731
762
 
735
766
 
736
767
class LockBreakMismatch(LockError):
737
768
 
738
 
    _fmt = "Lock was released and re-acquired before being broken: %(lock)s: held by %(holder)r, wanted to break %(target)r"
 
769
    _fmt = ("Lock was released and re-acquired before being broken:"
 
770
            " %(lock)s: held by %(holder)r, wanted to break %(target)r")
739
771
 
740
772
    internal_error = False
741
773
 
812
844
 
813
845
class NotLeftParentDescendant(BzrError):
814
846
 
815
 
    _fmt = "Revision %(old_revision)s is not the left parent of"\
816
 
        " %(new_revision)s, but branch %(branch_location)s expects this"
 
847
    _fmt = ("Revision %(old_revision)s is not the left parent of"
 
848
            " %(new_revision)s, but branch %(branch_location)s expects this")
817
849
 
818
850
    internal_error = True
819
851
 
831
863
        BzrError.__init__(self, spec=spec)
832
864
 
833
865
 
 
866
class NoSuchRevisionInTree(NoSuchRevision):
 
867
    """When using Tree.revision_tree, and the revision is not accessible."""
 
868
    
 
869
    _fmt = "The revision id %(revision_id)s is not present in the tree %(tree)s."
 
870
 
 
871
    def __init__(self, tree, revision_id):
 
872
        BzrError.__init__(self)
 
873
        self.tree = tree
 
874
        self.revision_id = revision_id
 
875
 
 
876
 
834
877
class InvalidRevisionSpec(BzrError):
835
878
 
836
 
    _fmt = "Requested revision: %(spec)r does not exist in branch: %(branch)s%(extra)s"
 
879
    _fmt = ("Requested revision: %(spec)r does not exist in branch:"
 
880
            " %(branch)s%(extra)s")
837
881
 
838
882
    def __init__(self, spec, branch, extra=None):
839
883
        BzrError.__init__(self, branch=branch, spec=spec)
850
894
 
851
895
class AppendRevisionsOnlyViolation(BzrError):
852
896
 
853
 
    _fmt = 'Operation denied because it would change the main history, '\
854
 
           'which is not permitted by the append_revisions_only setting on'\
855
 
           ' branch "%(location)s".'
 
897
    _fmt = ('Operation denied because it would change the main history,'
 
898
           ' which is not permitted by the append_revisions_only setting on'
 
899
           ' branch "%(location)s".')
856
900
 
857
901
    def __init__(self, location):
858
902
       import bzrlib.urlutils as urlutils
861
905
 
862
906
 
863
907
class DivergedBranches(BzrError):
864
 
    
865
 
    _fmt = "These branches have diverged.  Use the merge command to reconcile them."""
 
908
 
 
909
    _fmt = ("These branches have diverged."
 
910
            " Use the merge command to reconcile them.")
866
911
 
867
912
    internal_error = False
868
913
 
883
928
 
884
929
class UnrelatedBranches(BzrError):
885
930
 
886
 
    _fmt = "Branches have no common ancestor, and no merge base revision was specified."
 
931
    _fmt = ("Branches have no common ancestor, and"
 
932
            " no merge base revision was specified.")
887
933
 
888
934
    internal_error = False
889
935
 
899
945
 
900
946
class NoCommonRoot(BzrError):
901
947
 
902
 
    _fmt = "Revisions are not derived from the same root: " \
903
 
           "%(revision_a)s %(revision_b)s."
 
948
    _fmt = ("Revisions are not derived from the same root: "
 
949
           "%(revision_a)s %(revision_b)s.")
904
950
 
905
951
    def __init__(self, revision_a, revision_b):
906
952
        BzrError.__init__(self, revision_a=revision_a, revision_b=revision_b)
929
975
    def __init__(self, bases):
930
976
        warn("BzrError AmbiguousBase has been deprecated as of bzrlib 0.8.",
931
977
                DeprecationWarning)
932
 
        msg = "The correct base is unclear, because %s are all equally close" %\
933
 
            ", ".join(bases)
 
978
        msg = ("The correct base is unclear, because %s are all equally close"
 
979
                % ", ".join(bases))
934
980
        BzrError.__init__(self, msg)
935
981
        self.bases = bases
936
982
 
958
1004
 
959
1005
class BoundBranchOutOfDate(BzrError):
960
1006
 
961
 
    _fmt = "Bound branch %(branch)s is out of date with master branch %(master)s."
 
1007
    _fmt = ("Bound branch %(branch)s is out of date"
 
1008
            " with master branch %(master)s.")
962
1009
 
963
1010
    def __init__(self, branch, master):
964
1011
        BzrError.__init__(self)
968
1015
        
969
1016
class CommitToDoubleBoundBranch(BzrError):
970
1017
 
971
 
    _fmt = "Cannot commit to branch %(branch)s. It is bound to %(master)s, which is bound to %(remote)s."
 
1018
    _fmt = ("Cannot commit to branch %(branch)s."
 
1019
            " It is bound to %(master)s, which is bound to %(remote)s.")
972
1020
 
973
1021
    def __init__(self, branch, master, remote):
974
1022
        BzrError.__init__(self)
988
1036
 
989
1037
class BoundBranchConnectionFailure(BzrError):
990
1038
 
991
 
    _fmt = "Unable to connect to target of bound branch %(branch)s => %(target)s: %(error)s"
 
1039
    _fmt = ("Unable to connect to target of bound branch %(branch)s"
 
1040
            " => %(target)s: %(error)s")
992
1041
 
993
1042
    def __init__(self, branch, target, error):
994
1043
        BzrError.__init__(self)
1048
1097
 
1049
1098
class WeaveTextDiffers(WeaveError):
1050
1099
 
1051
 
    _fmt = "Weaves differ on text content. Revision: {%(revision_id)s}, %(weave_a)s, %(weave_b)s"
 
1100
    _fmt = ("Weaves differ on text content. Revision:"
 
1101
            " {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
1052
1102
 
1053
1103
    def __init__(self, revision_id, weave_a, weave_b):
1054
1104
        WeaveError.__init__(self)
1059
1109
 
1060
1110
class WeaveTextDiffers(WeaveError):
1061
1111
 
1062
 
    _fmt = "Weaves differ on text content. Revision: {%(revision_id)s}, %(weave_a)s, %(weave_b)s"
 
1112
    _fmt = ("Weaves differ on text content. Revision:"
 
1113
            " {%(revision_id)s}, %(weave_a)s, %(weave_b)s")
1063
1114
 
1064
1115
    def __init__(self, revision_id, weave_a, weave_b):
1065
1116
        WeaveError.__init__(self)
1162
1213
 
1163
1214
class TooManyConcurrentRequests(BzrError):
1164
1215
 
1165
 
    _fmt = ("The medium '%(medium)s' has reached its concurrent request limit. "
1166
 
            "Be sure to finish_writing and finish_reading on the "
1167
 
            "current request that is open.")
 
1216
    _fmt = ("The medium '%(medium)s' has reached its concurrent request limit."
 
1217
            " Be sure to finish_writing and finish_reading on the"
 
1218
            " current request that is open.")
1168
1219
 
1169
1220
    internal_error = True
1170
1221
 
1297
1348
 
1298
1349
class CantReprocessAndShowBase(BzrError):
1299
1350
 
1300
 
    _fmt = "Can't reprocess and show base, because reprocessing obscures " \
1301
 
           "the relationship of conflicting lines to the base"
 
1351
    _fmt = ("Can't reprocess and show base, because reprocessing obscures "
 
1352
           "the relationship of conflicting lines to the base")
1302
1353
 
1303
1354
 
1304
1355
class GraphCycleError(BzrError):
1353
1404
 
1354
1405
 
1355
1406
class MustUseDecorated(Exception):
1356
 
    
1357
 
    _fmt = """A decorating function has requested its original command be used."""
1358
 
    
 
1407
 
 
1408
    _fmt = "A decorating function has requested its original command be used."
 
1409
 
1359
1410
 
1360
1411
class NoBundleFound(BzrError):
1361
1412
 
1378
1429
 
1379
1430
class MissingText(BzrError):
1380
1431
 
1381
 
    _fmt = "Branch %(base)s is missing revision %(text_revision)s of %(file_id)s"
 
1432
    _fmt = ("Branch %(base)s is missing revision"
 
1433
            " %(text_revision)s of %(file_id)s")
1382
1434
 
1383
1435
    def __init__(self, branch, text_revision, file_id):
1384
1436
        BzrError.__init__(self)
1388
1440
        self.file_id = file_id
1389
1441
 
1390
1442
 
 
1443
class DuplicateFileId(BzrError):
 
1444
 
 
1445
    _fmt = "File id {%(file_id)s} already exists in inventory as %(entry)s"
 
1446
 
 
1447
    def __init__(self, file_id, entry):
 
1448
        BzrError.__init__(self)
 
1449
        self.file_id = file_id
 
1450
        self.entry = entry
 
1451
 
 
1452
 
1391
1453
class DuplicateKey(BzrError):
1392
1454
 
1393
1455
    _fmt = "Key %(key)s is already present in map"
1491
1553
 
1492
1554
class BzrBadParameterUnicode(BzrBadParameter):
1493
1555
 
1494
 
    _fmt = "Parameter %(param)s is unicode but only byte-strings are permitted."
 
1556
    _fmt = ("Parameter %(param)s is unicode but"
 
1557
            " only byte-strings are permitted.")
1495
1558
 
1496
1559
 
1497
1560
class BzrBadParameterContainsNewline(BzrBadParameter):
1583
1646
        self.tree = tree
1584
1647
 
1585
1648
 
 
1649
class PublicBranchOutOfDate(BzrError):
 
1650
 
 
1651
    _fmt = 'Public branch "%(public_location)s" lacks revision '\
 
1652
        '"%(revstring)s".'
 
1653
 
 
1654
    def __init__(self, public_location, revstring):
 
1655
        import bzrlib.urlutils as urlutils
 
1656
        public_location = urlutils.unescape_for_display(public_location,
 
1657
                                                        'ascii')
 
1658
        BzrError.__init__(self, public_location=public_location,
 
1659
                          revstring=revstring)
 
1660
 
 
1661
 
1586
1662
class MergeModifiedFormatError(BzrError):
1587
1663
 
1588
1664
    _fmt = "Error in merge modified format"
1595
1671
 
1596
1672
class CorruptRepository(BzrError):
1597
1673
 
1598
 
    _fmt = """An error has been detected in the repository %(repo_path)s.
1599
 
Please run bzr reconcile on this repository."""
 
1674
    _fmt = ("An error has been detected in the repository %(repo_path)s.\n"
 
1675
            "Please run bzr reconcile on this repository.")
1600
1676
 
1601
1677
    def __init__(self, repo):
1602
1678
        BzrError.__init__(self)
1624
1700
 
1625
1701
class InvalidProgressBarType(BzrError):
1626
1702
 
1627
 
    _fmt = """Environment variable BZR_PROGRESS_BAR='%(bar_type)s is not a supported type
1628
 
Select one of: %(valid_types)s"""
 
1703
    _fmt = ("Environment variable BZR_PROGRESS_BAR='%(bar_type)s"
 
1704
            " is not a supported type Select one of: %(valid_types)s")
1629
1705
 
1630
1706
    def __init__(self, bar_type, valid_types):
1631
1707
        BzrError.__init__(self, bar_type=bar_type, valid_types=valid_types)
1633
1709
 
1634
1710
class UnsupportedOperation(BzrError):
1635
1711
 
1636
 
    _fmt = "The method %(mname)s is not supported on objects of type %(tname)s."
 
1712
    _fmt = ("The method %(mname)s is not supported on"
 
1713
            " objects of type %(tname)s.")
1637
1714
 
1638
1715
    def __init__(self, method, method_self):
1639
1716
        self.method = method
1646
1723
 
1647
1724
 
1648
1725
class NonAsciiRevisionId(UnsupportedOperation):
1649
 
    """Raised when a commit is attempting to set a non-ascii revision id but cant."""
 
1726
    """Raised when a commit is attempting to set a non-ascii revision id
 
1727
       but cant.
 
1728
    """
1650
1729
 
1651
1730
 
1652
1731
class BinaryFile(BzrError):
1665
1744
 
1666
1745
class TestamentMismatch(BzrError):
1667
1746
 
1668
 
    _fmt = """Testament did not match expected value.  
1669
 
       For revision_id {%(revision_id)s}, expected {%(expected)s}, measured 
 
1747
    _fmt = """Testament did not match expected value.
 
1748
       For revision_id {%(revision_id)s}, expected {%(expected)s}, measured
1670
1749
       {%(measured)s}"""
1671
1750
 
1672
1751
    def __init__(self, revision_id, expected, measured):
1741
1820
        BadInventoryFormat.__init__(self, msg=msg)
1742
1821
 
1743
1822
 
 
1823
class RootNotRich(BzrError):
 
1824
 
 
1825
    _fmt = """This operation requires rich root data storage"""
 
1826
 
 
1827
 
1744
1828
class NoSmartMedium(BzrError):
1745
1829
 
1746
1830
    _fmt = "The transport '%(transport)s' cannot tunnel the smart protocol."
 
1831
 
1747
1832
    internal_error = True
1748
1833
 
1749
1834
    def __init__(self, transport):
1767
1852
        self.vendor = vendor
1768
1853
 
1769
1854
 
 
1855
class SSHVendorNotFound(BzrError):
 
1856
 
 
1857
    _fmt = ("Don't know how to handle SSH connections."
 
1858
            " Please set BZR_SSH environment variable.")
 
1859
 
 
1860
 
1770
1861
class GhostRevisionUnusableHere(BzrError):
1771
1862
 
1772
1863
    _fmt = "Ghost revision {%(revision_id)s} cannot be used here."
1778
1869
 
1779
1870
class IllegalUseOfScopeReplacer(BzrError):
1780
1871
 
1781
 
    _fmt = "ScopeReplacer object %(name)r was used incorrectly: %(msg)s%(extra)s"
 
1872
    _fmt = ("ScopeReplacer object %(name)r was used incorrectly:"
 
1873
            " %(msg)s%(extra)s")
1782
1874
 
1783
1875
    internal_error = True
1784
1876
 
1806
1898
 
1807
1899
class ImportNameCollision(BzrError):
1808
1900
 
1809
 
    _fmt = "Tried to import an object to the same name as an existing object. %(name)s"
 
1901
    _fmt = ("Tried to import an object to the same name as"
 
1902
            " an existing object. %(name)s")
1810
1903
 
1811
1904
    internal_error = True
1812
1905
 
1813
1906
    def __init__(self, name):
1814
1907
        BzrError.__init__(self)
1815
1908
        self.name = name
 
1909
 
 
1910
 
 
1911
class NoMergeSource(BzrError):
 
1912
    """Raise if no merge source was specified for a merge directive"""
 
1913
 
 
1914
    _fmt = "A merge directive must provide either a bundle or a public"\
 
1915
        " branch location."
 
1916
 
 
1917
 
 
1918
class PatchMissing(BzrError):
 
1919
    """Raise a patch type was specified but no patch supplied"""
 
1920
 
 
1921
    _fmt = "patch_type was %(patch_type)s, but no patch was supplied."
 
1922
 
 
1923
    def __init__(self, patch_type):
 
1924
        BzrError.__init__(self)
 
1925
        self.patch_type = patch_type
 
1926
 
 
1927
 
 
1928
class UnsupportedInventoryKind(BzrError):
 
1929
    
 
1930
    _fmt = """Unsupported entry kind %(kind)s"""
 
1931
 
 
1932
    def __init__(self, kind):
 
1933
        self.kind = kind
 
1934
 
 
1935
 
 
1936
class BadSubsumeSource(BzrError):
 
1937
 
 
1938
    _fmt = """Can't subsume %(other_tree)s into %(tree)s.  %(reason)s"""
 
1939
 
 
1940
    def __init__(self, tree, other_tree, reason):
 
1941
        self.tree = tree
 
1942
        self.other_tree = other_tree
 
1943
        self.reason = reason
 
1944
 
 
1945
 
 
1946
class SubsumeTargetNeedsUpgrade(BzrError):
 
1947
    
 
1948
    _fmt = """Subsume target %(other_tree)s needs to be upgraded."""
 
1949
 
 
1950
    def __init__(self, other_tree):
 
1951
        self.other_tree = other_tree
 
1952
 
 
1953
 
 
1954
class BadReferenceTarget(BzrError):
 
1955
 
 
1956
    _fmt = "Can't add reference to %(other_tree)s into %(tree)s.  %(reason)s"
 
1957
 
 
1958
    internal_error = True
 
1959
 
 
1960
    def __init__(self, tree, other_tree, reason):
 
1961
        self.tree = tree
 
1962
        self.other_tree = other_tree
 
1963
        self.reason = reason
 
1964
 
 
1965
 
 
1966
class NoSuchTag(BzrError):
 
1967
 
 
1968
    _fmt = "No such tag: %(tag_name)s"
 
1969
 
 
1970
    def __init__(self, tag_name):
 
1971
        self.tag_name = tag_name
 
1972
 
 
1973
 
 
1974
class TagsNotSupported(BzrError):
 
1975
 
 
1976
    _fmt = ("Tags not supported by %(branch)s;"
 
1977
            " you may be able to use bzr upgrade.")
 
1978
 
 
1979
    def __init__(self, branch):
 
1980
        self.branch = branch
 
1981
 
 
1982
        
 
1983
class TagAlreadyExists(BzrError):
 
1984
 
 
1985
    _fmt = "Tag %(tag_name)s already exists."
 
1986
 
 
1987
    def __init__(self, tag_name):
 
1988
        self.tag_name = tag_name