135
137
account.set_lp_login(name)
137
139
self.outf.write(gettext("Launchpad user ID set to '%s'.\n") %
141
class cmd_launchpad_logout(Command):
142
__doc__ = """Unset the Launchpad user ID.
144
When communicating with Launchpad, some commands need to know your
145
Launchpad user ID. This command will log you out from Launchpad.
146
This means that communication with Launchpad will happen over
147
HTTPS, and will not require one of your SSH keys to be available.
143
# XXX: cmd_launchpad_mirror is untested
144
class cmd_launchpad_mirror(Command):
145
__doc__ = """Ask Launchpad to mirror a branch now."""
147
aliases = ['lp-mirror']
148
takes_args = ['location?']
150
def run(self, location='.'):
152
from .lp_registration import LaunchpadService
153
branch, _ = _mod_branch.Branch.open_containing(location)
154
service = LaunchpadService()
155
launchpad = lp_api.login(service)
156
lp_branch = lp_api.LaunchpadBranch.from_bzr(launchpad, branch,
157
create_missing=False)
158
lp_branch.lp.requestMirror()
161
class cmd_lp_propose_merge(Command):
162
__doc__ = """Propose merging a branch on Launchpad.
164
This will open your usual editor to provide the initial comment. When it
165
has created the proposal, it will open it in your default web browser.
167
The branch will be proposed to merge into SUBMIT_BRANCH. If SUBMIT_BRANCH
168
is not supplied, the remembered submit branch will be used. If no submit
169
branch is remembered, the development focus will be used.
171
By default, the SUBMIT_BRANCH's review team will be requested to review
172
the merge proposal. This can be overriden by specifying --review (-R).
173
The parameter the launchpad account name of the desired reviewer. This
174
may optionally be followed by '=' and the review type. For example:
176
brz lp-propose-merge --review jrandom --review review-team=qa
178
This will propose a merge, request "jrandom" to perform a review of
179
unspecified type, and request "review-team" to perform a "qa" review.
149
aliases = ['lp-logout']
150
takes_options = ['verbose']
152
def run(self, verbose=False):
153
from . import account
154
old_username = account.get_lp_login()
155
if old_username is None:
156
self.outf.write(gettext('Not logged into Launchpad.\n'))
158
account.set_lp_login(None)
160
self.outf.write(gettext(
161
"Launchpad user ID %s logged out.\n") %
182
takes_options = [Option('staging',
183
help='Propose the merge on staging.'),
184
Option('message', short_name='m', type=unicode,
185
help='Commit message.'),
187
help=('Mark the proposal as approved immediately, '
188
'setting the approved revision to tip.')),
189
Option('fixes', 'The bug this proposal fixes.', str),
190
ListOption('review', short_name='R', type=unicode,
191
help='Requested reviewer and optional type.')]
193
takes_args = ['submit_branch?']
195
aliases = ['lp-submit', 'lp-propose']
197
def run(self, submit_branch=None, review=None, staging=False,
198
message=None, approve=False, fixes=None):
199
from . import lp_propose
200
tree, branch, relpath = controldir.ControlDir.open_containing_tree_or_branch(
206
for review in review:
208
reviews.append(review.split('=', 2))
210
reviews.append((review, ''))
211
if submit_branch is None:
212
submit_branch = branch.get_submit_branch()
213
if submit_branch is None:
216
target = _mod_branch.Branch.open(submit_branch)
217
proposer = lp_propose.Proposer(tree, branch, target, message,
218
reviews, staging, approve=approve,
220
proposer.check_proposal()
221
proposer.create_proposal()
165
224
class cmd_lp_find_proposal(Command):
185
244
from . import lp_api
186
245
import webbrowser
187
246
b = _mod_branch.Branch.open_containing('.')[0]
188
with ui.ui_factory.nested_progress_bar() as pb, b.lock_read():
247
pb = ui.ui_factory.nested_progress_bar()
189
250
if revision is None:
190
251
revision_id = b.last_revision()
192
253
revision_id = revision[0].as_revision_id(b)
193
254
merged = self._find_proposals(revision_id, pb)
194
255
if len(merged) == 0:
195
raise CommandError(gettext('No review found.'))
256
raise BzrCommandError(gettext('No review found.'))
196
257
trace.note(gettext('%d proposals(s) found.') % len(merged))
197
258
for mp in merged:
198
259
webbrowser.open(lp_api.canonical_url(mp))
200
264
def _find_proposals(self, revision_id, pb):
201
from launchpadlib import uris
265
from . import (lp_api, lp_registration)
203
266
# "devel" because branches.getMergeProposals is not part of 1.0 API.
204
lp_base_url = uris.LPNET_SERVICE_ROOT
205
launchpad = lp_api.connect_launchpad(lp_base_url, version='devel')
267
launchpad = lp_api.login(lp_registration.LaunchpadService(),
206
269
pb.update(gettext('Finding proposals'))
207
270
return list(launchpad.branches.getMergeProposals(
208
merged_revision=revision_id.decode('utf-8')))
271
merged_revision=revision_id))