~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: Vincent Ladeuil
  • Date: 2010-10-08 10:50:51 UTC
  • mfrom: (5050.17.31 2.2.2-dev)
  • mto: This revision was merged to the branch mainline in revision 5474.
  • Revision ID: v.ladeuil+lp@free.fr-20101008105051-xd4knkrohzclffic
Merge 2.2 into trunk including fixes for bug #651706 and bug #646133

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)
782
782
 
783
783
    _fmt = 'File "%(path)s" is not in branch %(branch_base)s.'
784
784
 
 
785
    # use PathNotChild instead
 
786
    @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 3, 0)))
785
787
    def __init__(self, branch, path):
786
788
        BzrError.__init__(self)
787
789
        self.branch = branch
947
949
    # original exception is available as e.original_error
948
950
    #
949
951
    # 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
 
952
    def __init__(self, msg):
 
953
        self.msg = msg
955
954
 
956
955
 
957
956
class LockActive(LockError):
1041
1040
class LockContention(LockError):
1042
1041
 
1043
1042
    _fmt = 'Could not acquire lock "%(lock)s": %(msg)s'
1044
 
    # TODO: show full url for lock, combining the transport and relative
1045
 
    # bits?
1046
1043
 
1047
1044
    internal_error = False
1048
1045
 
1075
1072
        self.target = target
1076
1073
 
1077
1074
 
 
1075
class LockCorrupt(LockError):
 
1076
 
 
1077
    _fmt = ("Lock is apparently held, but corrupted: %(corruption_info)s\n"
 
1078
            "Use 'bzr break-lock' to clear it")
 
1079
 
 
1080
    internal_error = False
 
1081
 
 
1082
    def __init__(self, corruption_info, file_data=None):
 
1083
        self.corruption_info = corruption_info
 
1084
        self.file_data = file_data
 
1085
 
 
1086
 
1078
1087
class LockNotHeld(LockError):
1079
1088
 
1080
1089
    _fmt = "Lock not held: %(lock)s"
1180
1189
class InvalidRevisionSpec(BzrError):
1181
1190
 
1182
1191
    _fmt = ("Requested revision: '%(spec)s' does not exist in branch:"
1183
 
            " %(branch)s%(extra)s")
 
1192
            " %(branch_url)s%(extra)s")
1184
1193
 
1185
1194
    def __init__(self, spec, branch, extra=None):
1186
1195
        BzrError.__init__(self, branch=branch, spec=spec)
 
1196
        self.branch_url = getattr(branch, 'user_url', str(branch))
1187
1197
        if extra:
1188
1198
            self.extra = '\n' + str(extra)
1189
1199
        else:
1380
1390
 
1381
1391
class WeaveParentMismatch(WeaveError):
1382
1392
 
1383
 
    _fmt = "Parents are mismatched between two revisions. %(message)s"
 
1393
    _fmt = "Parents are mismatched between two revisions. %(msg)s"
1384
1394
 
1385
1395
 
1386
1396
class WeaveInvalidChecksum(WeaveError):
1387
1397
 
1388
 
    _fmt = "Text did not match it's checksum: %(message)s"
 
1398
    _fmt = "Text did not match its checksum: %(msg)s"
1389
1399
 
1390
1400
 
1391
1401
class WeaveTextDiffers(WeaveError):
1439
1449
 
1440
1450
class VersionedFileInvalidChecksum(VersionedFileError):
1441
1451
 
1442
 
    _fmt = "Text did not match its checksum: %(message)s"
 
1452
    _fmt = "Text did not match its checksum: %(msg)s"
1443
1453
 
1444
1454
 
1445
1455
class KnitError(InternalBzrError):
1925
1935
    _fmt = "Moving the root directory is not supported at this time"
1926
1936
 
1927
1937
 
 
1938
class TransformRenameFailed(BzrError):
 
1939
 
 
1940
    _fmt = "Failed to rename %(from_path)s to %(to_path)s: %(why)s"
 
1941
 
 
1942
    def __init__(self, from_path, to_path, why, errno):
 
1943
        self.from_path = from_path
 
1944
        self.to_path = to_path
 
1945
        self.why = why
 
1946
        self.errno = errno
 
1947
 
 
1948
 
1928
1949
class BzrMoveFailedError(BzrError):
1929
1950
 
1930
1951
    _fmt = "Could not move %(from_path)s%(operator)s %(to_path)s%(extra)s"
1975
1996
        "Use --keep to not delete them, or --force to delete them regardless.")
1976
1997
 
1977
1998
    def __init__(self, tree_delta):
 
1999
        symbol_versioning.warn(symbol_versioning.deprecated_in((2, 3, 0)) %
 
2000
            "BzrRemoveChangedFilesError", DeprecationWarning, stacklevel=2)
1978
2001
        BzrError.__init__(self)
1979
2002
        self.changes_as_text = tree_delta.get_changes_as_text()
1980
2003
        #self.paths_as_string = '\n'.join(changed_files)
2834
2857
        else:
2835
2858
            more = ' ' + more
2836
2859
        import bzrlib.urlutils as urlutils
2837
 
        display_url = urlutils.unescape_for_display(
2838
 
            tree.user_url, 'ascii')
 
2860
        user_url = getattr(tree, "user_url", None)
 
2861
        if user_url is None:
 
2862
            display_url = str(tree)
 
2863
        else:
 
2864
            display_url = urlutils.unescape_for_display(user_url, 'ascii')
2839
2865
        BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2840
2866
 
2841
2867
 
 
2868
class ShelvedChanges(UncommittedChanges):
 
2869
 
 
2870
    _fmt = ('Working tree "%(display_url)s" has shelved changes'
 
2871
            ' (See bzr shelve --list).%(more)s')
 
2872
 
 
2873
 
2842
2874
class MissingTemplateVariable(BzrError):
2843
2875
 
2844
2876
    _fmt = 'Variable {%(name)s} is not available.'
3134
3166
    def __init__(self, bzrdir):
3135
3167
        self.bzrdir = bzrdir
3136
3168
 
 
3169
 
 
3170
class NoWhoami(BzrError):
 
3171
 
 
3172
    _fmt = ('Unable to determine your name.\n'
 
3173
        "Please, set your name with the 'whoami' command.\n"
 
3174
        'E.g. bzr whoami "Your Name <name@example.com>"')
 
3175
 
 
3176
 
 
3177
class InvalidPattern(BzrError):
 
3178
 
 
3179
    _fmt = ('Invalid pattern(s) found. %(msg)s')
 
3180
 
 
3181
    def __init__(self, msg):
 
3182
        self.msg = msg
 
3183
 
 
3184
 
 
3185
class RecursiveBind(BzrError):
 
3186
 
 
3187
    _fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
 
3188
        'Please use `bzr unbind` to fix.')
 
3189
 
 
3190
    def __init__(self, branch_url):
 
3191
        self.branch_url = branch_url
 
3192