550
550
self.bzrdir = bzrdir_format
553
class IncompatibleRepositories(BzrError):
555
_fmt = "Repository %(target)s is not compatible with repository"\
558
def __init__(self, source, target):
559
BzrError.__init__(self, target=target, source=source)
553
562
class IncompatibleRevision(BzrError):
555
564
_fmt = "Revision is not compatible with %(repo_format)s"
1285
1294
InvalidHttpResponse.__init__(self, path, msg)
1297
class RedirectRequested(TransportError):
1299
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1301
def __init__(self, source, target, is_permament=False, qual_proto=None):
1302
self.source = source
1303
self.target = target
1305
self.permanently = ' permanently'
1307
self.permanently = ''
1308
self.is_permament = is_permament
1309
self._qualified_proto = qual_proto
1310
TransportError.__init__(self)
1312
def _requalify_url(self, url):
1313
"""Restore the qualified proto in front of the url"""
1314
# When this exception is raised, source and target are in
1315
# user readable format. But some transports may use a
1316
# different proto (http+urllib:// will present http:// to
1317
# the user. If a qualified proto is specified, the code
1318
# trapping the exception can get the qualified urls to
1319
# properly handle the redirection themself (creating a
1320
# new transport object from the target url for example).
1321
# But checking that the scheme of the original and
1322
# redirected urls are the same can be tricky. (see the
1323
# FIXME in BzrDir.open_from_transport for the unique use
1325
if self._qualified_proto is None:
1328
# The TODO related to NotBranchError mention that doing
1329
# that kind of manipulation on the urls may not be the
1330
# exception object job. On the other hand, this object is
1331
# the interface between the code and the user so
1332
# presenting the urls in different ways is indeed its
1335
proto, netloc, path, query, fragment = urlparse.urlsplit(url)
1336
return urlparse.urlunsplit((self._qualified_proto, netloc, path,
1339
def get_source_url(self):
1340
return self._requalify_url(self.source)
1342
def get_target_url(self):
1343
return self._requalify_url(self.target)
1346
class TooManyRedirections(TransportError):
1348
_fmt = "Too many redirections"
1288
1350
class ConflictsInTree(BzrError):
1290
1352
_fmt = "Working tree has conflicts."