19
19
from __future__ import absolute_import
22
22
branch as _mod_branch,
26
from ...commands import (
26
from bzrlib.commands import (
29
from ...errors import (
29
from bzrlib.errors import (
33
from ...i18n import gettext
34
from ...option import (
35
from bzrlib.i18n import gettext
36
from bzrlib.option import (
38
from ...sixish import (
42
class cmd_register_branch(Command):
43
__doc__ = """Register a branch with launchpad.net.
45
This command lists a bzr branch in the directory of branches on
46
launchpad.net. Registration allows the branch to be associated with
47
bugs or specifications.
49
Before using this command you must register the project to which the
50
branch belongs, and create an account for yourself on launchpad.net.
53
public_url: The publicly visible url for the branch to register.
54
This must be an http or https url (which Launchpad can read
55
from to access the branch). Local file urls, SFTP urls, and
56
bzr+ssh urls will not work.
57
If no public_url is provided, bzr will use the configured
58
public_url if there is one for the current branch, and
62
bzr register-branch http://foo.com/bzr/fooproject.mine \\
65
takes_args = ['public_url?']
68
'Launchpad project short name to associate with the branch.',
71
'Launchpad product short name to associate with the branch.',
75
'Short name for the branch; '
76
'by default taken from the last component of the url.',
78
Option('branch-title',
79
'One-sentence description of the branch.',
81
Option('branch-description',
82
'Longer description of the purpose or contents of the branch.',
85
"Branch author's email address, if not yourself.",
88
'The bug this branch fixes.',
91
'Prepare the request but don\'t actually send it.')
101
branch_description='',
105
from bzrlib.plugins.launchpad.lp_registration import (
106
BranchRegistrationRequest, BranchBugLinkRequest,
107
DryRunLaunchpadService, LaunchpadService)
108
if public_url is None:
110
b = _mod_branch.Branch.open_containing('.')[0]
111
except NotBranchError:
112
raise BzrCommandError(gettext(
113
'register-branch requires a public '
114
'branch url - see bzr help register-branch.'))
115
public_url = b.get_public_branch()
116
if public_url is None:
117
raise NoPublicBranch(b)
118
if product is not None:
121
'--product is deprecated; please use --project.'))
124
rego = BranchRegistrationRequest(branch_url=public_url,
125
branch_name=branch_name,
126
branch_title=branch_title,
127
branch_description=branch_description,
128
product_name=project,
131
linko = BranchBugLinkRequest(branch_url=public_url,
134
service = LaunchpadService()
135
# This gives back the xmlrpc url that can be used for future
136
# operations on the branch. It's not so useful to print to the
137
# user since they can't do anything with it from a web browser; it
138
# might be nice for the server to tell us about an html url as
141
# Run on service entirely in memory
142
service = DryRunLaunchpadService()
143
service.gather_user_credentials()
146
linko.submit(service)
147
self.outf.write('Branch registered.\n')
43
150
class cmd_launchpad_open(Command):
146
class cmd_launchpad_logout(Command):
147
__doc__ = """Unset the Launchpad user ID.
149
When communicating with Launchpad, some commands need to know your
150
Launchpad user ID. This command will log you out from Launchpad.
151
This means that communication with Launchpad will happen over
152
HTTPS, and will not require one of your SSH keys to be available.
154
aliases = ['lp-logout']
155
takes_options = ['verbose']
157
def run(self, verbose=False):
158
from . import account
159
old_username = account.get_lp_login()
160
if old_username is None:
161
self.outf.write(gettext('Not logged into Launchpad.\n'))
163
account.set_lp_login(None)
165
self.outf.write(gettext(
166
"Launchpad user ID %s logged out.\n") %
170
252
# XXX: cmd_launchpad_mirror is untested
171
253
class cmd_launchpad_mirror(Command):
172
254
__doc__ = """Ask Launchpad to mirror a branch now."""
209
291
takes_options = [Option('staging',
210
292
help='Propose the merge on staging.'),
211
Option('message', short_name='m', type=text_type,
293
Option('message', short_name='m', type=unicode,
212
294
help='Commit message.'),
213
295
Option('approve',
214
296
help=('Mark the proposal as approved immediately, '
215
297
'setting the approved revision to tip.')),
216
298
Option('fixes', 'The bug this proposal fixes.', str),
217
ListOption('review', short_name='R', type=text_type,
299
ListOption('review', short_name='R', type=unicode,
218
300
help='Requested reviewer and optional type.')]
220
302
takes_args = ['submit_branch?']
262
344
So, to find the merge proposal that reviewed line 1 of README::
264
brz lp-find-proposal -r mainline:annotate:README:1
346
bzr lp-find-proposal -r mainline:annotate:README:1
267
349
takes_options = ['revision']
269
351
def run(self, revision=None):
352
from bzrlib import ui
353
from bzrlib.plugins.launchpad import lp_api
272
354
import webbrowser
273
355
b = _mod_branch.Branch.open_containing('.')[0]
274
with ui.ui_factory.nested_progress_bar() as pb, b.lock_read():
356
pb = ui.ui_factory.nested_progress_bar()
275
359
if revision is None:
276
360
revision_id = b.last_revision()
282
366
trace.note(gettext('%d proposals(s) found.') % len(merged))
283
367
for mp in merged:
284
368
webbrowser.open(lp_api.canonical_url(mp))
286
373
def _find_proposals(self, revision_id, pb):
287
from . import (lp_api, lp_registration)
374
from bzrlib.plugins.launchpad import (lp_api, lp_registration)
288
375
# "devel" because branches.getMergeProposals is not part of 1.0 API.
289
376
launchpad = lp_api.login(lp_registration.LaunchpadService(),