145
146
b = _mod_branch.Branch.open_containing('.')[0]
146
147
except NotBranchError:
147
raise BzrCommandError('register-branch requires a public '
148
'branch url - see bzr help register-branch.')
148
raise BzrCommandError(gettext(
149
'register-branch requires a public '
150
'branch url - see bzr help register-branch.'))
149
151
public_url = b.get_public_branch()
150
152
if public_url is None:
151
153
raise NoPublicBranch(b)
152
154
if product is not None:
153
155
project = product
154
trace.note('--product is deprecated; please use --project.')
157
'--product is deprecated; please use --project.'))
157
160
rego = BranchRegistrationRequest(branch_url=public_url,
223
226
if location is None:
225
228
web_url = self._get_web_url(LaunchpadService(), location)
226
trace.note('Opening %s in web browser' % web_url)
229
trace.note(gettext('Opening %s in web browser') % web_url)
228
231
import webbrowser # this import should not be lazy
229
232
# otherwise bzr.exe lacks this module
267
270
if check_account:
268
271
account.check_lp_login(username)
271
"Launchpad user ID exists and has SSH keys.\n")
273
self.outf.write(gettext(
274
"Launchpad user ID exists and has SSH keys.\n"))
272
275
self.outf.write(username + '\n')
274
self.outf.write('No Launchpad user ID configured.\n')
277
self.outf.write(gettext('No Launchpad user ID configured.\n'))
277
280
name = name.lower()
278
281
if check_account:
279
282
account.check_lp_login(name)
282
"Launchpad user ID exists and has SSH keys.\n")
284
self.outf.write(gettext(
285
"Launchpad user ID exists and has SSH keys.\n"))
283
286
account.set_lp_login(name)
285
self.outf.write("Launchpad user ID set to '%s'.\n" % (name,))
288
self.outf.write(gettext("Launchpad user ID set to '%s'.\n") %
287
291
register_command(cmd_launchpad_login)
400
404
revno = self._find_merged_revno(revision, b, pb)
401
405
merged = self._find_proposals(revno, b, pb)
402
406
if len(merged) == 0:
403
raise BzrCommandError('No review found.')
404
trace.note('%d proposals(s) found.' % len(merged))
407
raise BzrCommandError(gettext('No review found.'))
408
trace.note(gettext('%d proposals(s) found.') % len(merged))
405
409
for mp in merged:
406
410
webbrowser.open(lp_api.canonical_url(mp))
411
415
def _find_merged_revno(self, revision, b, pb):
412
416
if revision is None:
414
pb.update('Finding revision-id')
418
pb.update(gettext('Finding revision-id'))
415
419
revision_id = revision[0].as_revision_id(b)
416
420
# a revno spec is necessarily on the mainline.
417
421
if self._is_revno_spec(revision[0]):
418
422
merging_revision = revision_id
420
424
graph = b.repository.get_graph()
421
pb.update('Finding merge')
425
pb.update(gettext('Finding merge'))
422
426
merging_revision = graph.find_lefthand_merger(
423
427
revision_id, b.last_revision())
424
428
if merging_revision is None:
425
429
raise InvalidRevisionSpec(revision[0].user_spec, b)
426
pb.update('Finding revno')
430
pb.update(gettext('Finding revno'))
427
431
return b.revision_id_to_revno(merging_revision)
429
433
def _find_proposals(self, revno, b, pb):
430
434
launchpad = lp_api.login(lp_registration.LaunchpadService())
431
pb.update('Finding Launchpad branch')
435
pb.update(gettext('Finding Launchpad branch'))
432
436
lpb = lp_api.LaunchpadBranch.from_bzr(launchpad, b,
433
437
create_missing=False)
434
pb.update('Finding proposals')
438
pb.update(gettext('Finding proposals'))
435
439
return list(lpb.lp.getMergeProposals(status=['Merged'],
436
440
merged_revnos=[revno]))