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

  • Committer: Jelmer Vernooij
  • Date: 2017-07-23 22:06:41 UTC
  • mfrom: (6738 trunk)
  • mto: This revision was merged to the branch mainline in revision 6739.
  • Revision ID: jelmer@jelmer.uk-20170723220641-69eczax9bmv8d6kk
Merge trunk, address review comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
than once for each place that needs to take it into account.
21
21
"""
22
22
 
 
23
from __future__ import absolute_import
 
24
 
23
25
from ... import (
24
26
    errors,
25
27
    trace,
42
44
 
43
45
class MismatchedUsernames(errors.BzrError):
44
46
 
45
 
    _fmt = ('breezy.conf and authentication.conf disagree about launchpad'
 
47
    _fmt = ('bazaar.conf and authentication.conf disagree about launchpad'
46
48
            ' account name.  Please re-run launchpad-login.')
47
49
 
48
50
 
49
51
def get_lp_login(_config=None):
50
52
    """Return the user's Launchpad username.
51
53
 
52
 
    :raises: MismatchedUsername if authentication.conf and breezy.conf
 
54
    :raises: MismatchedUsername if authentication.conf and bazaar.conf
53
55
        disagree about username.
54
56
    """
55
57
    if _config is None:
71
73
def _set_global_option(username, _config=None):
72
74
    if _config is None:
73
75
        _config = GlobalStack()
74
 
    if username is None:
75
 
        _config.remove('launchpad_username')
76
 
    else:
77
 
        _config.set('launchpad_username', username)
 
76
    _config.set('launchpad_username', username)
78
77
 
79
78
 
80
79
def set_lp_login(username, _config=None):
81
80
    """Set the user's Launchpad username"""
82
81
    _set_global_option(username, _config)
83
 
    if username is not None:
84
 
        _set_auth_user(username)
 
82
    _set_auth_user(username)
85
83
 
86
84
 
87
85
def _get_auth_user(auth=None):
90
88
    username = auth.get_user('ssh', '.launchpad.net')
91
89
    return username
92
90
 
93
 
 
94
91
def _set_auth_user(username, auth=None):
95
92
    if auth is None:
96
93
        auth = AuthenticationConfig()