~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: Martin Pool
  • Date: 2010-12-16 06:24:14 UTC
  • mfrom: (5538.2.4 bzr-docs-textfixes)
  • mto: This revision was merged to the branch mainline in revision 5572.
  • Revision ID: mbp@sourcefrog.net-20101216062414-y14p9t3otmmbtpsw
merge uppercasing of acronyms

Show diffs side-by-side

added added

removed removed

Lines of Context:
680
680
 
681
681
    _fmt = 'Path "%(path)s" is not a child of path "%(base)s"%(extra)s'
682
682
 
683
 
    internal_error = True
 
683
    internal_error = False
684
684
 
685
685
    def __init__(self, path, base, extra=None):
686
686
        BzrError.__init__(self)
723
723
                    self.bzrdir.open_repository()
724
724
                except NoRepositoryPresent:
725
725
                    self.detail = ''
 
726
                except Exception:
 
727
                    # Just ignore unexpected errors.  Raising arbitrary errors
 
728
                    # during str(err) can provoke strange bugs.  Concretely
 
729
                    # Launchpad's codehosting managed to raise NotBranchError
 
730
                    # here, and then get stuck in an infinite loop/recursion
 
731
                    # trying to str() that error.  All this error really cares
 
732
                    # about that there's no working repository there, and if
 
733
                    # open_repository() fails, there probably isn't.
 
734
                    self.detail = ''
726
735
                else:
727
736
                    self.detail = ': location is a repository'
728
737
            else:
782
791
 
783
792
    _fmt = 'File "%(path)s" is not in branch %(branch_base)s.'
784
793
 
 
794
    # use PathNotChild instead
 
795
    @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 3, 0)))
785
796
    def __init__(self, branch, path):
786
797
        BzrError.__init__(self)
787
798
        self.branch = branch
947
958
    # original exception is available as e.original_error
948
959
    #
949
960
    # New code should prefer to raise specific subclasses
950
 
    def __init__(self, message):
951
 
        # Python 2.5 uses a slot for StandardError.message,
952
 
        # so use a different variable name.  We now work around this in
953
 
        # BzrError.__str__, but this member name is kept for compatability.
954
 
        self.msg = message
 
961
    def __init__(self, msg):
 
962
        self.msg = msg
955
963
 
956
964
 
957
965
class LockActive(LockError):
1041
1049
class LockContention(LockError):
1042
1050
 
1043
1051
    _fmt = 'Could not acquire lock "%(lock)s": %(msg)s'
1044
 
    # TODO: show full url for lock, combining the transport and relative
1045
 
    # bits?
1046
1052
 
1047
1053
    internal_error = False
1048
1054
 
1075
1081
        self.target = target
1076
1082
 
1077
1083
 
 
1084
class LockCorrupt(LockError):
 
1085
 
 
1086
    _fmt = ("Lock is apparently held, but corrupted: %(corruption_info)s\n"
 
1087
            "Use 'bzr break-lock' to clear it")
 
1088
 
 
1089
    internal_error = False
 
1090
 
 
1091
    def __init__(self, corruption_info, file_data=None):
 
1092
        self.corruption_info = corruption_info
 
1093
        self.file_data = file_data
 
1094
 
 
1095
 
1078
1096
class LockNotHeld(LockError):
1079
1097
 
1080
1098
    _fmt = "Lock not held: %(lock)s"
1180
1198
class InvalidRevisionSpec(BzrError):
1181
1199
 
1182
1200
    _fmt = ("Requested revision: '%(spec)s' does not exist in branch:"
1183
 
            " %(branch)s%(extra)s")
 
1201
            " %(branch_url)s%(extra)s")
1184
1202
 
1185
1203
    def __init__(self, spec, branch, extra=None):
1186
1204
        BzrError.__init__(self, branch=branch, spec=spec)
 
1205
        self.branch_url = getattr(branch, 'user_url', str(branch))
1187
1206
        if extra:
1188
1207
            self.extra = '\n' + str(extra)
1189
1208
        else:
1380
1399
 
1381
1400
class WeaveParentMismatch(WeaveError):
1382
1401
 
1383
 
    _fmt = "Parents are mismatched between two revisions. %(message)s"
 
1402
    _fmt = "Parents are mismatched between two revisions. %(msg)s"
1384
1403
 
1385
1404
 
1386
1405
class WeaveInvalidChecksum(WeaveError):
1387
1406
 
1388
 
    _fmt = "Text did not match it's checksum: %(message)s"
 
1407
    _fmt = "Text did not match its checksum: %(msg)s"
1389
1408
 
1390
1409
 
1391
1410
class WeaveTextDiffers(WeaveError):
1439
1458
 
1440
1459
class VersionedFileInvalidChecksum(VersionedFileError):
1441
1460
 
1442
 
    _fmt = "Text did not match its checksum: %(message)s"
 
1461
    _fmt = "Text did not match its checksum: %(msg)s"
1443
1462
 
1444
1463
 
1445
1464
class KnitError(InternalBzrError):
1925
1944
    _fmt = "Moving the root directory is not supported at this time"
1926
1945
 
1927
1946
 
 
1947
class TransformRenameFailed(BzrError):
 
1948
 
 
1949
    _fmt = "Failed to rename %(from_path)s to %(to_path)s: %(why)s"
 
1950
 
 
1951
    def __init__(self, from_path, to_path, why, errno):
 
1952
        self.from_path = from_path
 
1953
        self.to_path = to_path
 
1954
        self.why = why
 
1955
        self.errno = errno
 
1956
 
 
1957
 
1928
1958
class BzrMoveFailedError(BzrError):
1929
1959
 
1930
1960
    _fmt = "Could not move %(from_path)s%(operator)s %(to_path)s%(extra)s"
1975
2005
        "Use --keep to not delete them, or --force to delete them regardless.")
1976
2006
 
1977
2007
    def __init__(self, tree_delta):
 
2008
        symbol_versioning.warn(symbol_versioning.deprecated_in((2, 3, 0)) %
 
2009
            "BzrRemoveChangedFilesError", DeprecationWarning, stacklevel=2)
1978
2010
        BzrError.__init__(self)
1979
2011
        self.changes_as_text = tree_delta.get_changes_as_text()
1980
2012
        #self.paths_as_string = '\n'.join(changed_files)
2834
2866
        else:
2835
2867
            more = ' ' + more
2836
2868
        import bzrlib.urlutils as urlutils
2837
 
        display_url = urlutils.unescape_for_display(
2838
 
            tree.user_url, 'ascii')
 
2869
        user_url = getattr(tree, "user_url", None)
 
2870
        if user_url is None:
 
2871
            display_url = str(tree)
 
2872
        else:
 
2873
            display_url = urlutils.unescape_for_display(user_url, 'ascii')
2839
2874
        BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2840
2875
 
2841
2876
 
 
2877
class ShelvedChanges(UncommittedChanges):
 
2878
 
 
2879
    _fmt = ('Working tree "%(display_url)s" has shelved changes'
 
2880
            ' (See bzr shelve --list).%(more)s')
 
2881
 
 
2882
 
2842
2883
class MissingTemplateVariable(BzrError):
2843
2884
 
2844
2885
    _fmt = 'Variable {%(name)s} is not available.'
2913
2954
        self.user_encoding = osutils.get_user_encoding()
2914
2955
 
2915
2956
 
 
2957
class NoSuchConfig(BzrError):
 
2958
 
 
2959
    _fmt = ('The "%(config_id)s" configuration does not exist.')
 
2960
 
 
2961
    def __init__(self, config_id):
 
2962
        BzrError.__init__(self, config_id=config_id)
 
2963
 
 
2964
 
 
2965
class NoSuchConfigOption(BzrError):
 
2966
 
 
2967
    _fmt = ('The "%(option_name)s" configuration option does not exist.')
 
2968
 
 
2969
    def __init__(self, option_name):
 
2970
        BzrError.__init__(self, option_name=option_name)
 
2971
 
 
2972
 
2916
2973
class NoSuchAlias(BzrError):
2917
2974
 
2918
2975
    _fmt = ('The alias "%(alias_name)s" does not exist.')
3134
3191
    def __init__(self, bzrdir):
3135
3192
        self.bzrdir = bzrdir
3136
3193
 
 
3194
 
 
3195
class NoWhoami(BzrError):
 
3196
 
 
3197
    _fmt = ('Unable to determine your name.\n'
 
3198
        "Please, set your name with the 'whoami' command.\n"
 
3199
        'E.g. bzr whoami "Your Name <name@example.com>"')
 
3200
 
 
3201
 
 
3202
class InvalidPattern(BzrError):
 
3203
 
 
3204
    _fmt = ('Invalid pattern(s) found. %(msg)s')
 
3205
 
 
3206
    def __init__(self, msg):
 
3207
        self.msg = msg
 
3208
 
 
3209
 
 
3210
class RecursiveBind(BzrError):
 
3211
 
 
3212
    _fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
 
3213
        'Please use `bzr unbind` to fix.')
 
3214
 
 
3215
    def __init__(self, branch_url):
 
3216
        self.branch_url = branch_url
 
3217