~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2012-01-18 14:09:19 UTC
  • mto: This revision was merged to the branch mainline in revision 6468.
  • Revision ID: v.ladeuil+lp@free.fr-20120118140919-rlvdrhpc0nq1lbwi
Change set/remove to require a lock for the branch config files.

This means that tests (or any plugin for that matter) do not requires an
explicit lock on the branch anymore to change a single option. This also
means the optimisation becomes "opt-in" and as such won't be as
spectacular as it may be and/or harder to get right (nothing fails
anymore).

This reduces the diff by ~300 lines.

Code/tests that were updating more than one config option is still taking
a lock to at least avoid some IOs and demonstrate the benefits through
the decreased number of hpss calls.

The duplication between BranchStack and BranchOnlyStack will be removed
once the same sharing is in place for local config files, at which point
the Stack class itself may be able to host the changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2008 Canonical Ltd
 
1
# Copyright (C) 2007-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
20
20
than once for each place that needs to take it into account.
21
21
"""
22
22
 
23
 
from bzrlib import errors, trace
 
23
from __future__ import absolute_import
 
24
 
 
25
from bzrlib import (
 
26
    errors,
 
27
    trace,
 
28
    transport,
 
29
    )
24
30
from bzrlib.config import AuthenticationConfig, GlobalConfig
25
 
from bzrlib.transport import get_transport
26
 
 
 
31
from bzrlib.i18n import gettext
27
32
 
28
33
LAUNCHPAD_BASE = 'https://launchpad.net/'
29
34
 
58
63
        auth_username = _get_auth_user(auth)
59
64
        # Auto-upgrading
60
65
        if auth_username is None:
61
 
            trace.note('Setting ssh/sftp usernames for launchpad.net.')
 
66
            trace.note(gettext('Setting ssh/sftp usernames for launchpad.net.'))
62
67
            _set_auth_user(username, auth)
63
68
        elif auth_username != username:
64
69
            raise MismatchedUsernames()
97
102
    uploaded SSH keys.
98
103
    """
99
104
    if _transport is None:
100
 
        _transport = get_transport(LAUNCHPAD_BASE)
 
105
        _transport = transport.get_transport_from_url(LAUNCHPAD_BASE)
101
106
 
102
107
    try:
103
108
        data = _transport.get_bytes('~%s/+sshkeys' % username)