/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

  • Committer: Robert Collins
  • Date: 2010-05-06 11:08:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506110810-h3j07fh5gmw54s25
Cleaner matcher matching revised unlocking protocol.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2005-2010 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
680
680
 
681
681
    _fmt = 'Path "%(path)s" is not a child of path "%(base)s"%(extra)s'
682
682
 
683
 
    internal_error = False
 
683
    internal_error = True
684
684
 
685
685
    def __init__(self, path, base, extra=None):
686
686
        BzrError.__init__(self)
713
713
       self.bzrdir = bzrdir
714
714
       PathError.__init__(self, path=path)
715
715
 
716
 
    def __repr__(self):
717
 
        return '<%s %r>' % (self.__class__.__name__, self.__dict__)
718
 
 
719
716
    def _format(self):
720
717
        # XXX: Ideally self.detail would be a property, but Exceptions in
721
718
        # Python 2.4 have to be old-style classes so properties don't work.
726
723
                    self.bzrdir.open_repository()
727
724
                except NoRepositoryPresent:
728
725
                    self.detail = ''
729
 
                except Exception:
730
 
                    # Just ignore unexpected errors.  Raising arbitrary errors
731
 
                    # during str(err) can provoke strange bugs.  Concretely
732
 
                    # Launchpad's codehosting managed to raise NotBranchError
733
 
                    # here, and then get stuck in an infinite loop/recursion
734
 
                    # trying to str() that error.  All this error really cares
735
 
                    # about that there's no working repository there, and if
736
 
                    # open_repository() fails, there probably isn't.
737
 
                    self.detail = ''
738
726
                else:
739
727
                    self.detail = ': location is a repository'
740
728
            else:
794
782
 
795
783
    _fmt = 'File "%(path)s" is not in branch %(branch_base)s.'
796
784
 
797
 
    # use PathNotChild instead
798
 
    @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 3, 0)))
799
785
    def __init__(self, branch, path):
800
786
        BzrError.__init__(self)
801
787
        self.branch = branch
961
947
    # original exception is available as e.original_error
962
948
    #
963
949
    # New code should prefer to raise specific subclasses
964
 
    def __init__(self, msg):
965
 
        self.msg = msg
 
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
966
955
 
967
956
 
968
957
class LockActive(LockError):
1052
1041
class LockContention(LockError):
1053
1042
 
1054
1043
    _fmt = 'Could not acquire lock "%(lock)s": %(msg)s'
 
1044
    # TODO: show full url for lock, combining the transport and relative
 
1045
    # bits?
1055
1046
 
1056
1047
    internal_error = False
1057
1048
 
1084
1075
        self.target = target
1085
1076
 
1086
1077
 
1087
 
class LockCorrupt(LockError):
1088
 
 
1089
 
    _fmt = ("Lock is apparently held, but corrupted: %(corruption_info)s\n"
1090
 
            "Use 'bzr break-lock' to clear it")
1091
 
 
1092
 
    internal_error = False
1093
 
 
1094
 
    def __init__(self, corruption_info, file_data=None):
1095
 
        self.corruption_info = corruption_info
1096
 
        self.file_data = file_data
1097
 
 
1098
 
 
1099
1078
class LockNotHeld(LockError):
1100
1079
 
1101
1080
    _fmt = "Lock not held: %(lock)s"
1201
1180
class InvalidRevisionSpec(BzrError):
1202
1181
 
1203
1182
    _fmt = ("Requested revision: '%(spec)s' does not exist in branch:"
1204
 
            " %(branch_url)s%(extra)s")
 
1183
            " %(branch)s%(extra)s")
1205
1184
 
1206
1185
    def __init__(self, spec, branch, extra=None):
1207
1186
        BzrError.__init__(self, branch=branch, spec=spec)
1208
 
        self.branch_url = getattr(branch, 'user_url', str(branch))
1209
1187
        if extra:
1210
1188
            self.extra = '\n' + str(extra)
1211
1189
        else:
1402
1380
 
1403
1381
class WeaveParentMismatch(WeaveError):
1404
1382
 
1405
 
    _fmt = "Parents are mismatched between two revisions. %(msg)s"
 
1383
    _fmt = "Parents are mismatched between two revisions. %(message)s"
1406
1384
 
1407
1385
 
1408
1386
class WeaveInvalidChecksum(WeaveError):
1409
1387
 
1410
 
    _fmt = "Text did not match its checksum: %(msg)s"
 
1388
    _fmt = "Text did not match it's checksum: %(message)s"
1411
1389
 
1412
1390
 
1413
1391
class WeaveTextDiffers(WeaveError):
1461
1439
 
1462
1440
class VersionedFileInvalidChecksum(VersionedFileError):
1463
1441
 
1464
 
    _fmt = "Text did not match its checksum: %(msg)s"
 
1442
    _fmt = "Text did not match its checksum: %(message)s"
1465
1443
 
1466
1444
 
1467
1445
class KnitError(InternalBzrError):
1947
1925
    _fmt = "Moving the root directory is not supported at this time"
1948
1926
 
1949
1927
 
1950
 
class TransformRenameFailed(BzrError):
1951
 
 
1952
 
    _fmt = "Failed to rename %(from_path)s to %(to_path)s: %(why)s"
1953
 
 
1954
 
    def __init__(self, from_path, to_path, why, errno):
1955
 
        self.from_path = from_path
1956
 
        self.to_path = to_path
1957
 
        self.why = why
1958
 
        self.errno = errno
1959
 
 
1960
 
 
1961
1928
class BzrMoveFailedError(BzrError):
1962
1929
 
1963
1930
    _fmt = "Could not move %(from_path)s%(operator)s %(to_path)s%(extra)s"
2008
1975
        "Use --keep to not delete them, or --force to delete them regardless.")
2009
1976
 
2010
1977
    def __init__(self, tree_delta):
2011
 
        symbol_versioning.warn(symbol_versioning.deprecated_in((2, 3, 0)) %
2012
 
            "BzrRemoveChangedFilesError", DeprecationWarning, stacklevel=2)
2013
1978
        BzrError.__init__(self)
2014
1979
        self.changes_as_text = tree_delta.get_changes_as_text()
2015
1980
        #self.paths_as_string = '\n'.join(changed_files)
2023
1988
 
2024
1989
class BzrBadParameterMissing(BzrBadParameter):
2025
1990
 
2026
 
    _fmt = "Parameter %(param)s is required but not present."
 
1991
    _fmt = "Parameter $(param)s is required but not present."
2027
1992
 
2028
1993
 
2029
1994
class BzrBadParameterUnicode(BzrBadParameter):
2869
2834
        else:
2870
2835
            more = ' ' + more
2871
2836
        import bzrlib.urlutils as urlutils
2872
 
        user_url = getattr(tree, "user_url", None)
2873
 
        if user_url is None:
2874
 
            display_url = str(tree)
2875
 
        else:
2876
 
            display_url = urlutils.unescape_for_display(user_url, 'ascii')
 
2837
        display_url = urlutils.unescape_for_display(
 
2838
            tree.user_url, 'ascii')
2877
2839
        BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2878
2840
 
2879
2841
 
2880
 
class ShelvedChanges(UncommittedChanges):
2881
 
 
2882
 
    _fmt = ('Working tree "%(display_url)s" has shelved changes'
2883
 
            ' (See bzr shelve --list).%(more)s')
2884
 
 
2885
 
 
2886
2842
class MissingTemplateVariable(BzrError):
2887
2843
 
2888
2844
    _fmt = 'Variable {%(name)s} is not available.'
2957
2913
        self.user_encoding = osutils.get_user_encoding()
2958
2914
 
2959
2915
 
2960
 
class NoSuchConfig(BzrError):
2961
 
 
2962
 
    _fmt = ('The "%(config_id)s" configuration does not exist.')
2963
 
 
2964
 
    def __init__(self, config_id):
2965
 
        BzrError.__init__(self, config_id=config_id)
2966
 
 
2967
 
 
2968
 
class NoSuchConfigOption(BzrError):
2969
 
 
2970
 
    _fmt = ('The "%(option_name)s" configuration option does not exist.')
2971
 
 
2972
 
    def __init__(self, option_name):
2973
 
        BzrError.__init__(self, option_name=option_name)
2974
 
 
2975
 
 
2976
2916
class NoSuchAlias(BzrError):
2977
2917
 
2978
2918
    _fmt = ('The alias "%(alias_name)s" does not exist.')
3194
3134
    def __init__(self, bzrdir):
3195
3135
        self.bzrdir = bzrdir
3196
3136
 
3197
 
 
3198
 
class NoWhoami(BzrError):
3199
 
 
3200
 
    _fmt = ('Unable to determine your name.\n'
3201
 
        "Please, set your name with the 'whoami' command.\n"
3202
 
        'E.g. bzr whoami "Your Name <name@example.com>"')
3203
 
 
3204
 
 
3205
 
class InvalidPattern(BzrError):
3206
 
 
3207
 
    _fmt = ('Invalid pattern(s) found. %(msg)s')
3208
 
 
3209
 
    def __init__(self, msg):
3210
 
        self.msg = msg
3211
 
 
3212
 
 
3213
 
class RecursiveBind(BzrError):
3214
 
 
3215
 
    _fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
3216
 
        'Please use `bzr unbind` to fix.')
3217
 
 
3218
 
    def __init__(self, branch_url):
3219
 
        self.branch_url = branch_url
3220