/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

  • Committer: Andrew Bennetts
  • Date: 2008-12-18 05:56:17 UTC
  • mfrom: (3910 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3922.
  • Revision ID: andrew.bennetts@canonical.com-20081218055617-f128x46i6rjjbrx9
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

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