/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@3903

Show diffs side-by-side

added added

removed removed

Lines of Context:
1660
1660
 
1661
1661
    _fmt = '%(source)s is%(permanently)s redirected to %(target)s'
1662
1662
 
1663
 
    def __init__(self, source, target, is_permanent=False, qual_proto=None):
 
1663
    def __init__(self, source, target, is_permanent=False):
1664
1664
        self.source = source
1665
1665
        self.target = target
1666
1666
        if is_permanent:
1667
1667
            self.permanently = ' permanently'
1668
1668
        else:
1669
1669
            self.permanently = ''
1670
 
        self._qualified_proto = qual_proto
1671
1670
        TransportError.__init__(self)
1672
1671
 
1673
 
    def _requalify_url(self, url):
1674
 
        """Restore the qualified proto in front of the url"""
1675
 
        # When this exception is raised, source and target are in
1676
 
        # user readable format. But some transports may use a
1677
 
        # different proto (http+urllib:// will present http:// to
1678
 
        # the user. If a qualified proto is specified, the code
1679
 
        # trapping the exception can get the qualified urls to
1680
 
        # properly handle the redirection themself (creating a
1681
 
        # new transport object from the target url for example).
1682
 
        # But checking that the scheme of the original and
1683
 
        # redirected urls are the same can be tricky. (see the
1684
 
        # FIXME in BzrDir.open_from_transport for the unique use
1685
 
        # case so far).
1686
 
        if self._qualified_proto is None:
1687
 
            return url
1688
 
 
1689
 
        # The TODO related to NotBranchError mention that doing
1690
 
        # that kind of manipulation on the urls may not be the
1691
 
        # exception object job. On the other hand, this object is
1692
 
        # the interface between the code and the user so
1693
 
        # presenting the urls in different ways is indeed its
1694
 
        # job...
1695
 
        import urlparse
1696
 
        proto, netloc, path, query, fragment = urlparse.urlsplit(url)
1697
 
        return urlparse.urlunsplit((self._qualified_proto, netloc, path,
1698
 
                                   query, fragment))
1699
 
 
1700
 
    def get_source_url(self):
1701
 
        return self._requalify_url(self.source)
1702
 
 
1703
 
    def get_target_url(self):
1704
 
        return self._requalify_url(self.target)
1705
 
 
1706
1672
 
1707
1673
class TooManyRedirections(TransportError):
1708
1674