/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: Breezy landing bot
  • Author(s): Colin Watson
  • Date: 2020-11-16 21:47:08 UTC
  • mfrom: (7521.1.1 remove-lp-workaround)
  • Revision ID: breezy.the.bot@gmail.com-20201116214708-jos209mgxi41oy15
Remove breezy.git workaround for bazaar.launchpad.net.

Merged from https://code.launchpad.net/~cjwatson/brz/remove-lp-workaround/+merge/393710

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
 
 
25
 
from bzrlib import (
 
23
from ... import (
26
24
    errors,
27
25
    trace,
28
26
    transport,
29
27
    )
30
 
from bzrlib.config import AuthenticationConfig, GlobalStack
31
 
from bzrlib.i18n import gettext
 
28
from ...config import AuthenticationConfig, GlobalStack
 
29
from ...i18n import gettext
32
30
 
33
31
LAUNCHPAD_BASE = 'https://launchpad.net/'
34
32
 
44
42
 
45
43
class MismatchedUsernames(errors.BzrError):
46
44
 
47
 
    _fmt = ('bazaar.conf and authentication.conf disagree about launchpad'
 
45
    _fmt = ('breezy.conf and authentication.conf disagree about launchpad'
48
46
            ' account name.  Please re-run launchpad-login.')
49
47
 
50
48
 
51
49
def get_lp_login(_config=None):
52
50
    """Return the user's Launchpad username.
53
51
 
54
 
    :raises: MismatchedUsername if authentication.conf and bazaar.conf
 
52
    :raises: MismatchedUsername if authentication.conf and breezy.conf
55
53
        disagree about username.
56
54
    """
57
55
    if _config is None:
73
71
def _set_global_option(username, _config=None):
74
72
    if _config is None:
75
73
        _config = GlobalStack()
76
 
    _config.set('launchpad_username', username)
 
74
    if username is None:
 
75
        _config.remove('launchpad_username')
 
76
    else:
 
77
        _config.set('launchpad_username', username)
77
78
 
78
79
 
79
80
def set_lp_login(username, _config=None):
80
81
    """Set the user's Launchpad username"""
81
82
    _set_global_option(username, _config)
82
 
    _set_auth_user(username)
 
83
    if username is not None:
 
84
        _set_auth_user(username)
83
85
 
84
86
 
85
87
def _get_auth_user(auth=None):
88
90
    username = auth.get_user('ssh', '.launchpad.net')
89
91
    return username
90
92
 
 
93
 
91
94
def _set_auth_user(username, auth=None):
92
95
    if auth is None:
93
96
        auth = AuthenticationConfig()