/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/plugins/launchpad/lp_indirect.py

  • Committer: Robert Collins
  • Date: 2008-02-06 04:06:42 UTC
  • mfrom: (3216 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3217.
  • Revision ID: robertc@robertcollins.net-20080206040642-2efx3l4iv5f95lxp
Merge up with bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
    def __init__(self, base):
59
59
        super(LaunchpadTransport, self).__init__(base)
60
60
        # We only support URLs without a netloc
61
 
        netloc = urlsplit(base)[1]
62
 
        if netloc != '':
 
61
        self.lp_instance = urlsplit(base)[1]
 
62
        if self.lp_instance == '':
 
63
            self.lp_instance = None
 
64
        elif self.lp_instance not in LaunchpadService.LAUNCHPAD_INSTANCE:
63
65
            raise errors.InvalidURL(path=base)
64
66
 
 
67
    def _requires_launchpad_login(self, scheme, netloc, path, query,
 
68
                                  fragment):
 
69
        """Does the URL require a Launchpad login in order to be reached?
 
70
 
 
71
        The URL is specified by its parsed components, as returned from
 
72
        urlsplit.
 
73
        """
 
74
        return (scheme in ('bzr+ssh', 'sftp')
 
75
                and (netloc.endswith('launchpad.net')
 
76
                     or netloc.endswith('launchpad.dev')))
 
77
 
65
78
    def _resolve(self, abspath,
66
79
                 _request_factory=ResolveLaunchpadPathRequest,
67
80
                 _lp_login=None):
69
82
        path = urlsplit(abspath)[2].lstrip('/')
70
83
        # Perform an XMLRPC request to resolve the path
71
84
        resolve = _request_factory(path)
72
 
        service = LaunchpadService()
 
85
        service = LaunchpadService(lp_instance=self.lp_instance)
73
86
        try:
74
87
            result = resolve.submit(service)
75
88
        except xmlrpclib.Fault, fault:
83
96
            _lp_login = get_lp_login()
84
97
        for url in result['urls']:
85
98
            scheme, netloc, path, query, fragment = urlsplit(url)
86
 
            if scheme == 'bzr+ssh' and (netloc.endswith('launchpad.net') or
87
 
                                        netloc.endswith('launchpad.dev')):
 
99
            if self._requires_launchpad_login(scheme, netloc, path, query,
 
100
                                              fragment):
88
101
                # Only accept launchpad.net bzr+ssh URLs if we know
89
102
                # the user's Launchpad login:
90
103
                if _lp_login is None: