~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugins/launchpad/account.py

Merge in bzr.dev 3801, resolve NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
    username = _config.get_user_option('launchpad_username')
55
55
    if username is not None:
56
56
        auth = AuthenticationConfig()
57
 
        auth_usernames = _get_auth_user(auth)
58
 
        for auth_username in auth_usernames.values():
59
 
            if auth_username is not None and auth_username != username:
60
 
                raise MismatchedUsernames()
 
57
        auth_username = _get_auth_user(auth)
61
58
        # Auto-upgrading
62
 
        if None in auth_usernames.values():
 
59
        if auth_username is None:
63
60
            trace.note('Setting ssh/sftp usernames for launchpad.net.')
64
61
            _set_auth_user(username, auth)
 
62
        elif auth_username != username:
 
63
            raise MismatchedUsernames()
65
64
    return username
66
65
 
67
66
 
80
79
def _get_auth_user(auth=None):
81
80
    if auth is None:
82
81
        auth = AuthenticationConfig()
83
 
    return {'production': auth.get_user('ssh', 'bazaar.launchpad.net'),
84
 
            'staging': auth.get_user('ssh', 'bazaar.staging.launchpad.net'),}
 
82
    return auth.get_user('ssh', '.launchpad.net')
85
83
 
86
84
def _set_auth_user(username, auth=None):
87
85
    if auth is None:
88
86
        auth = AuthenticationConfig()
89
87
    auth.set_credentials(
90
 
        'Launchpad', 'bazaar.launchpad.net', username, 'ssh')
91
 
    auth.set_credentials(
92
 
        'Launchpad Staging', 'bazaar.staging.launchpad.net', username, 'ssh')
 
88
        'Launchpad', '.launchpad.net', username, 'ssh')
93
89
 
94
90
 
95
91
def check_lp_login(username, _transport=None):