1497
1497
internal_error = True
1499
_fmt = ("Pack files have changed, reload and retry. %(orig_error)s")
1499
_fmt = ("Pack files have changed, reload and retry. context: %(context)s"
1501
def __init__(self, reload_occurred, exc_info):
1502
"""create a new RestartWithNewPacks error.
1502
def __init__(self, context, reload_occurred, exc_info):
1503
"""create a new RetryWithNewPacks error.
1504
1505
:param reload_occurred: Set to True if we know that the packs have
1505
1506
already been reloaded, and we are failing because of an in-memory
1518
1519
# RetryWithNewPacks also not being caught
1522
class RetryAutopack(RetryWithNewPacks):
1523
"""Raised when we are autopacking and we find a missing file.
1525
Meant as a signaling exception, to tell the autopack code it should try
1529
internal_error = True
1531
_fmt = ("Pack files have changed, reload and try autopack again."
1532
" context: %(context)s %(orig_error)s")
1521
1535
class NoSuchExportFormat(BzrError):
1523
1537
_fmt = "Export format %(format)r not supported"
1662
1676
_fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1664
def __init__(self, source, target, is_permanent=False, qual_proto=None):
1678
def __init__(self, source, target, is_permanent=False):
1665
1679
self.source = source
1666
1680
self.target = target
1667
1681
if is_permanent:
1668
1682
self.permanently = ' permanently'
1670
1684
self.permanently = ''
1671
self._qualified_proto = qual_proto
1672
1685
TransportError.__init__(self)
1674
def _requalify_url(self, url):
1675
"""Restore the qualified proto in front of the url"""
1676
# When this exception is raised, source and target are in
1677
# user readable format. But some transports may use a
1678
# different proto (http+urllib:// will present http:// to
1679
# the user. If a qualified proto is specified, the code
1680
# trapping the exception can get the qualified urls to
1681
# properly handle the redirection themself (creating a
1682
# new transport object from the target url for example).
1683
# But checking that the scheme of the original and
1684
# redirected urls are the same can be tricky. (see the
1685
# FIXME in BzrDir.open_from_transport for the unique use
1687
if self._qualified_proto is None:
1690
# The TODO related to NotBranchError mention that doing
1691
# that kind of manipulation on the urls may not be the
1692
# exception object job. On the other hand, this object is
1693
# the interface between the code and the user so
1694
# presenting the urls in different ways is indeed its
1697
proto, netloc, path, query, fragment = urlparse.urlsplit(url)
1698
return urlparse.urlunsplit((self._qualified_proto, netloc, path,
1701
def get_source_url(self):
1702
return self._requalify_url(self.source)
1704
def get_target_url(self):
1705
return self._requalify_url(self.target)
1708
1688
class TooManyRedirections(TransportError):