/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: John Arbash Meinel
  • Date: 2011-04-20 09:46:28 UTC
  • mfrom: (5609.33.4 2.3)
  • mto: (5609.33.5 2.3)
  • mto: This revision was merged to the branch mainline in revision 5811.
  • Revision ID: john@arbash-meinel.com-20110420094628-l0bafq1lwb6ib1v2
Merge lp:bzr/2.3 @ 5640 so we can update the release notes (aka NEWS)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005-2011 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 = True
 
683
    internal_error = False
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
 
716
719
    def _format(self):
717
720
        # XXX: Ideally self.detail would be a property, but Exceptions in
718
721
        # Python 2.4 have to be old-style classes so properties don't work.
723
726
                    self.bzrdir.open_repository()
724
727
                except NoRepositoryPresent:
725
728
                    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 = ''
726
738
                else:
727
739
                    self.detail = ': location is a repository'
728
740
            else:
782
794
 
783
795
    _fmt = 'File "%(path)s" is not in branch %(branch_base)s.'
784
796
 
 
797
    # use PathNotChild instead
 
798
    @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 3, 0)))
785
799
    def __init__(self, branch, path):
786
800
        BzrError.__init__(self)
787
801
        self.branch = branch
947
961
    # original exception is available as e.original_error
948
962
    #
949
963
    # 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
 
964
    def __init__(self, msg):
 
965
        self.msg = msg
955
966
 
956
967
 
957
968
class LockActive(LockError):
1041
1052
class LockContention(LockError):
1042
1053
 
1043
1054
    _fmt = 'Could not acquire lock "%(lock)s": %(msg)s'
1044
 
    # TODO: show full url for lock, combining the transport and relative
1045
 
    # bits?
1046
1055
 
1047
1056
    internal_error = False
1048
1057
 
1191
1200
 
1192
1201
class InvalidRevisionSpec(BzrError):
1193
1202
 
1194
 
    _fmt = ("Requested revision: %(spec)r does not exist in branch:"
1195
 
            " %(branch)s%(extra)s")
 
1203
    _fmt = ("Requested revision: '%(spec)s' does not exist in branch:"
 
1204
            " %(branch_url)s%(extra)s")
1196
1205
 
1197
1206
    def __init__(self, spec, branch, extra=None):
1198
1207
        BzrError.__init__(self, branch=branch, spec=spec)
 
1208
        self.branch_url = getattr(branch, 'user_url', str(branch))
1199
1209
        if extra:
1200
1210
            self.extra = '\n' + str(extra)
1201
1211
        else:
1309
1319
class BoundBranchOutOfDate(BzrError):
1310
1320
 
1311
1321
    _fmt = ("Bound branch %(branch)s is out of date with master branch"
1312
 
            " %(master)s.")
 
1322
            " %(master)s.%(extra_help)s")
1313
1323
 
1314
1324
    def __init__(self, branch, master):
1315
1325
        BzrError.__init__(self)
1316
1326
        self.branch = branch
1317
1327
        self.master = master
 
1328
        self.extra_help = ''
1318
1329
 
1319
1330
 
1320
1331
class CommitToDoubleBoundBranch(BzrError):
1391
1402
 
1392
1403
class WeaveParentMismatch(WeaveError):
1393
1404
 
1394
 
    _fmt = "Parents are mismatched between two revisions. %(message)s"
 
1405
    _fmt = "Parents are mismatched between two revisions. %(msg)s"
1395
1406
 
1396
1407
 
1397
1408
class WeaveInvalidChecksum(WeaveError):
1398
1409
 
1399
 
    _fmt = "Text did not match it's checksum: %(message)s"
 
1410
    _fmt = "Text did not match its checksum: %(msg)s"
1400
1411
 
1401
1412
 
1402
1413
class WeaveTextDiffers(WeaveError):
1450
1461
 
1451
1462
class VersionedFileInvalidChecksum(VersionedFileError):
1452
1463
 
1453
 
    _fmt = "Text did not match its checksum: %(message)s"
 
1464
    _fmt = "Text did not match its checksum: %(msg)s"
1454
1465
 
1455
1466
 
1456
1467
class KnitError(InternalBzrError):
1936
1947
    _fmt = "Moving the root directory is not supported at this time"
1937
1948
 
1938
1949
 
 
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
 
1939
1961
class BzrMoveFailedError(BzrError):
1940
1962
 
1941
1963
    _fmt = "Could not move %(from_path)s%(operator)s %(to_path)s%(extra)s"
1986
2008
        "Use --keep to not delete them, or --force to delete them regardless.")
1987
2009
 
1988
2010
    def __init__(self, tree_delta):
 
2011
        symbol_versioning.warn(symbol_versioning.deprecated_in((2, 3, 0)) %
 
2012
            "BzrRemoveChangedFilesError", DeprecationWarning, stacklevel=2)
1989
2013
        BzrError.__init__(self)
1990
2014
        self.changes_as_text = tree_delta.get_changes_as_text()
1991
2015
        #self.paths_as_string = '\n'.join(changed_files)
1999
2023
 
2000
2024
class BzrBadParameterMissing(BzrBadParameter):
2001
2025
 
2002
 
    _fmt = "Parameter $(param)s is required but not present."
 
2026
    _fmt = "Parameter %(param)s is required but not present."
2003
2027
 
2004
2028
 
2005
2029
class BzrBadParameterUnicode(BzrBadParameter):
2187
2211
 
2188
2212
    def __init__(self, repo):
2189
2213
        BzrError.__init__(self)
2190
 
        self.repo_path = repo.bzrdir.root_transport.base
 
2214
        self.repo_path = repo.user_url
2191
2215
 
2192
2216
 
2193
2217
class InconsistentDelta(BzrError):
2765
2789
 
2766
2790
    def __init__(self, bzrdir):
2767
2791
        import bzrlib.urlutils as urlutils
2768
 
        display_url = urlutils.unescape_for_display(bzrdir.root_transport.base,
 
2792
        display_url = urlutils.unescape_for_display(bzrdir.user_url,
2769
2793
                                                    'ascii')
2770
2794
        BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url)
2771
2795
 
2845
2869
        else:
2846
2870
            more = ' ' + more
2847
2871
        import bzrlib.urlutils as urlutils
2848
 
        display_url = urlutils.unescape_for_display(
2849
 
            tree.bzrdir.root_transport.base, 'ascii')
 
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')
2850
2877
        BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2851
2878
 
2852
2879
 
 
2880
class ShelvedChanges(UncommittedChanges):
 
2881
 
 
2882
    _fmt = ('Working tree "%(display_url)s" has shelved changes'
 
2883
            ' (See bzr shelve --list).%(more)s')
 
2884
 
 
2885
 
2853
2886
class MissingTemplateVariable(BzrError):
2854
2887
 
2855
2888
    _fmt = 'Variable {%(name)s} is not available.'
2924
2957
        self.user_encoding = osutils.get_user_encoding()
2925
2958
 
2926
2959
 
 
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
 
2927
2976
class NoSuchAlias(BzrError):
2928
2977
 
2929
2978
    _fmt = ('The alias "%(alias_name)s" does not exist.')
3136
3185
 
3137
3186
    def __init__(self, path):
3138
3187
        self.path = path
 
3188
 
 
3189
 
 
3190
class NoColocatedBranchSupport(BzrError):
 
3191
 
 
3192
    _fmt = ("%(bzrdir)r does not support co-located branches.")
 
3193
 
 
3194
    def __init__(self, bzrdir):
 
3195
        self.bzrdir = bzrdir
 
3196
 
 
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