~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-09-01 08:02:42 UTC
  • mfrom: (5390.3.3 faster-revert-593560)
  • Revision ID: pqm@pqm.ubuntu.com-20100901080242-esg62ody4frwmy66
(spiv) Avoid repeatedly calling self.target.all_file_ids() in
 InterTree.iter_changes. (Andrew Bennetts)

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
23
from bzrlib 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 bzrlib.config import AuthenticationConfig, GlobalConfig
 
29
 
32
30
 
33
31
LAUNCHPAD_BASE = 'https://launchpad.net/'
34
32
 
55
53
        disagree about username.
56
54
    """
57
55
    if _config is None:
58
 
        _config = GlobalStack()
 
56
        _config = GlobalConfig()
59
57
 
60
 
    username = _config.get('launchpad_username')
 
58
    username = _config.get_user_option('launchpad_username')
61
59
    if username is not None:
62
60
        auth = AuthenticationConfig()
63
61
        auth_username = _get_auth_user(auth)
64
62
        # Auto-upgrading
65
63
        if auth_username is None:
66
 
            trace.note(gettext('Setting ssh/sftp usernames for launchpad.net.'))
 
64
            trace.note('Setting ssh/sftp usernames for launchpad.net.')
67
65
            _set_auth_user(username, auth)
68
66
        elif auth_username != username:
69
67
            raise MismatchedUsernames()
72
70
 
73
71
def _set_global_option(username, _config=None):
74
72
    if _config is None:
75
 
        _config = GlobalStack()
76
 
    _config.set('launchpad_username', username)
 
73
        _config = GlobalConfig()
 
74
    _config.set_user_option('launchpad_username', username)
77
75
 
78
76
 
79
77
def set_lp_login(username, _config=None):
102
100
    uploaded SSH keys.
103
101
    """
104
102
    if _transport is None:
105
 
        _transport = transport.get_transport_from_url(LAUNCHPAD_BASE)
 
103
        _transport = transport.get_transport(LAUNCHPAD_BASE)
106
104
 
107
105
    try:
108
106
        data = _transport.get_bytes('~%s/+sshkeys' % username)