/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 bzr.dev and fully converted uses of new parents api.

Show diffs side-by-side

added added

removed removed

Lines of Context:
126
126
 
127
127
    def __str__(self):
128
128
        try:
129
 
            return self.__doc__ % self.__dict__
 
129
            # __str__() should always return a 'str' object
 
130
            # never a 'unicode' object.
 
131
            s = self.__doc__ % self.__dict__
 
132
            if isinstance(s, unicode):
 
133
                return s.encode('utf8')
 
134
            return s
130
135
        except (NameError, ValueError, KeyError), e:
131
136
            return 'Unprintable exception %s: %s' \
132
137
                % (self.__class__.__name__, str(e))
161
166
 
162
167
class InvalidRevisionId(BzrNewError):
163
168
    """Invalid revision-id {%(revision_id)s} in %(branch)s"""
 
169
 
164
170
    def __init__(self, revision_id, branch):
165
171
        # branch can be any string or object with __str__ defined
166
172
        BzrNewError.__init__(self)
197
203
    # BzrCommandError, and non-UI code should not throw a subclass of
198
204
    # BzrCommandError.  ADHB 20051211
199
205
    def __init__(self, msg):
200
 
        self.msg = msg
 
206
        # Object.__str__() must return a real string
 
207
        # returning a Unicode string is a python error.
 
208
        if isinstance(msg, unicode):
 
209
            self.msg = msg.encode('utf8')
 
210
        else:
 
211
            self.msg = msg
201
212
 
202
213
    def __str__(self):
203
214
        return self.msg
304
315
(use bzr checkout if you wish to build a working tree): %(path)s"""
305
316
 
306
317
 
 
318
class AtomicFileAlreadyClosed(PathError):
 
319
    """'%(function)s' called on an AtomicFile after it was closed: %(path)s"""
 
320
 
 
321
    def __init__(self, path, function):
 
322
        PathError.__init__(self, path=path, extra=None)
 
323
        self.function = function
 
324
 
 
325
 
 
326
class InaccessibleParent(PathError):
 
327
    """Parent not accessible given base %(base)s and relative path %(path)s"""
 
328
 
 
329
    def __init__(self, path, base):
 
330
        PathError.__init__(self, path)
 
331
        self.base = base
 
332
 
 
333
 
307
334
class NoRepositoryPresent(BzrNewError):
308
335
    """No repository present: %(path)r"""
309
336
    def __init__(self, bzrdir):
1045
1072
    """Not a bzr revision-bundle: %(text)r"""
1046
1073
 
1047
1074
    def __init__(self, text):
1048
 
        self.text = text
1049
 
 
1050
 
 
1051
 
class BadBundle(Exception): pass
1052
 
 
1053
 
 
1054
 
class MalformedHeader(BadBundle): pass
1055
 
 
1056
 
 
1057
 
class MalformedPatches(BadBundle): pass
1058
 
 
1059
 
 
1060
 
class MalformedFooter(BadBundle): pass
 
1075
        BzrNewError.__init__(self)
 
1076
        self.text = text
 
1077
 
 
1078
 
 
1079
class BadBundle(BzrNewError): 
 
1080
    """Bad bzr revision-bundle: %(text)r"""
 
1081
 
 
1082
    def __init__(self, text):
 
1083
        BzrNewError.__init__(self)
 
1084
        self.text = text
 
1085
 
 
1086
 
 
1087
class MalformedHeader(BadBundle): 
 
1088
    """Malformed bzr revision-bundle header: %(text)r"""
 
1089
 
 
1090
    def __init__(self, text):
 
1091
        BzrNewError.__init__(self)
 
1092
        self.text = text
 
1093
 
 
1094
 
 
1095
class MalformedPatches(BadBundle): 
 
1096
    """Malformed patches in bzr revision-bundle: %(text)r"""
 
1097
 
 
1098
    def __init__(self, text):
 
1099
        BzrNewError.__init__(self)
 
1100
        self.text = text
 
1101
 
 
1102
 
 
1103
class MalformedFooter(BadBundle): 
 
1104
    """Malformed footer in bzr revision-bundle: %(text)r"""
 
1105
 
 
1106
    def __init__(self, text):
 
1107
        BzrNewError.__init__(self)
 
1108
        self.text = text
 
1109
 
 
1110
 
 
1111
class UnsupportedEOLMarker(BadBundle):
 
1112
    """End of line marker was not \\n in bzr revision-bundle"""    
 
1113
 
 
1114
    def __init__(self):
 
1115
        BzrNewError.__init__(self)
 
1116
 
 
1117
 
 
1118
class GhostRevisionUnusableHere(BzrNewError):
 
1119
    """Ghost revision {%(revision_id)s} cannot be used here."""
 
1120
 
 
1121
    def __init__(self, revision_id):
 
1122
        BzrNewError.__init__(self)
 
1123
        self.revision_id = revision_id