175
175
self.message = message
178
class DisabledMethod(BzrError):
180
_fmt = "The smart server method '%(class_name)s' is disabled."
182
internal_error = True
184
def __init__(self, class_name):
185
BzrError.__init__(self)
186
self.class_name = class_name
178
189
class InvalidEntryName(BzrError):
180
191
_fmt = "Invalid entry name: %(name)s"
550
561
self.bzrdir = bzrdir_format
564
class IncompatibleRepositories(BzrError):
566
_fmt = "Repository %(target)s is not compatible with repository"\
569
def __init__(self, source, target):
570
BzrError.__init__(self, target=target, source=source)
553
573
class IncompatibleRevision(BzrError):
555
575
_fmt = "Revision is not compatible with %(repo_format)s"
1306
1326
InvalidHttpResponse.__init__(self, path, msg)
1329
class RedirectRequested(TransportError):
1331
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1333
def __init__(self, source, target, is_permament=False, qual_proto=None):
1334
self.source = source
1335
self.target = target
1337
self.permanently = ' permanently'
1339
self.permanently = ''
1340
self.is_permament = is_permament
1341
self._qualified_proto = qual_proto
1342
TransportError.__init__(self)
1344
def _requalify_url(self, url):
1345
"""Restore the qualified proto in front of the url"""
1346
# When this exception is raised, source and target are in
1347
# user readable format. But some transports may use a
1348
# different proto (http+urllib:// will present http:// to
1349
# the user. If a qualified proto is specified, the code
1350
# trapping the exception can get the qualified urls to
1351
# properly handle the redirection themself (creating a
1352
# new transport object from the target url for example).
1353
# But checking that the scheme of the original and
1354
# redirected urls are the same can be tricky. (see the
1355
# FIXME in BzrDir.open_from_transport for the unique use
1357
if self._qualified_proto is None:
1360
# The TODO related to NotBranchError mention that doing
1361
# that kind of manipulation on the urls may not be the
1362
# exception object job. On the other hand, this object is
1363
# the interface between the code and the user so
1364
# presenting the urls in different ways is indeed its
1367
proto, netloc, path, query, fragment = urlparse.urlsplit(url)
1368
return urlparse.urlunsplit((self._qualified_proto, netloc, path,
1371
def get_source_url(self):
1372
return self._requalify_url(self.source)
1374
def get_target_url(self):
1375
return self._requalify_url(self.target)
1378
class TooManyRedirections(TransportError):
1380
_fmt = "Too many redirections"
1309
1382
class ConflictsInTree(BzrError):
1311
1384
_fmt = "Working tree has conflicts."