~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2012-02-20 12:19:29 UTC
  • mfrom: (6437.23.11 2.5)
  • mto: (6581.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6582.
  • Revision ID: jelmer@samba.org-20120220121929-7ni2psvjoatm1yp4
Merge bzr/2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 
36
36
"""
37
37
 
 
38
from __future__ import absolute_import
 
39
 
38
40
# The XMLRPC server address can be overridden by setting the environment
39
41
# variable $BZR_LP_XMLRPC_URL
40
42
 
46
48
    ui,
47
49
    trace,
48
50
    )
 
51
from bzrlib.i18n import gettext
49
52
""")
50
53
 
51
54
from bzrlib import (
144
147
            try:
145
148
                b = _mod_branch.Branch.open_containing('.')[0]
146
149
            except NotBranchError:
147
 
                raise BzrCommandError('register-branch requires a public '
148
 
                    'branch url - see bzr help register-branch.')
 
150
                raise BzrCommandError(gettext(
 
151
                            'register-branch requires a public '
 
152
                            'branch url - see bzr help register-branch.'))
149
153
            public_url = b.get_public_branch()
150
154
            if public_url is None:
151
155
                raise NoPublicBranch(b)
152
156
        if product is not None:
153
157
            project = product
154
 
            trace.note('--product is deprecated; please use --project.')
 
158
            trace.note(gettext(
 
159
                '--product is deprecated; please use --project.'))
155
160
 
156
161
 
157
162
        rego = BranchRegistrationRequest(branch_url=public_url,
223
228
        if location is None:
224
229
            location = u'.'
225
230
        web_url = self._get_web_url(LaunchpadService(), location)
226
 
        trace.note('Opening %s in web browser' % web_url)
 
231
        trace.note(gettext('Opening %s in web browser') % web_url)
227
232
        if not dry_run:
228
233
            import webbrowser   # this import should not be lazy
229
234
                                # otherwise bzr.exe lacks this module
267
272
                if check_account:
268
273
                    account.check_lp_login(username)
269
274
                    if verbose:
270
 
                        self.outf.write(
271
 
                            "Launchpad user ID exists and has SSH keys.\n")
 
275
                        self.outf.write(gettext(
 
276
                            "Launchpad user ID exists and has SSH keys.\n"))
272
277
                self.outf.write(username + '\n')
273
278
            else:
274
 
                self.outf.write('No Launchpad user ID configured.\n')
 
279
                self.outf.write(gettext('No Launchpad user ID configured.\n'))
275
280
                return 1
276
281
        else:
277
282
            name = name.lower()
278
283
            if check_account:
279
284
                account.check_lp_login(name)
280
285
                if verbose:
281
 
                    self.outf.write(
282
 
                        "Launchpad user ID exists and has SSH keys.\n")
 
286
                    self.outf.write(gettext(
 
287
                        "Launchpad user ID exists and has SSH keys.\n"))
283
288
            account.set_lp_login(name)
284
289
            if verbose:
285
 
                self.outf.write("Launchpad user ID set to '%s'.\n" % (name,))
 
290
                self.outf.write(gettext("Launchpad user ID set to '%s'.\n") %
 
291
                                                                        (name,))
286
292
 
287
293
register_command(cmd_launchpad_login)
288
294
 
400
406
            revno = self._find_merged_revno(revision, b, pb)
401
407
            merged = self._find_proposals(revno, b, pb)
402
408
            if len(merged) == 0:
403
 
                raise BzrCommandError('No review found.')
404
 
            trace.note('%d proposals(s) found.' % len(merged))
 
409
                raise BzrCommandError(gettext('No review found.'))
 
410
            trace.note(gettext('%d proposals(s) found.') % len(merged))
405
411
            for mp in merged:
406
412
                webbrowser.open(lp_api.canonical_url(mp))
407
413
        finally:
411
417
    def _find_merged_revno(self, revision, b, pb):
412
418
        if revision is None:
413
419
            return b.revno()
414
 
        pb.update('Finding revision-id')
 
420
        pb.update(gettext('Finding revision-id'))
415
421
        revision_id = revision[0].as_revision_id(b)
416
422
        # a revno spec is necessarily on the mainline.
417
423
        if self._is_revno_spec(revision[0]):
418
424
            merging_revision = revision_id
419
425
        else:
420
426
            graph = b.repository.get_graph()
421
 
            pb.update('Finding merge')
 
427
            pb.update(gettext('Finding merge'))
422
428
            merging_revision = graph.find_lefthand_merger(
423
429
                revision_id, b.last_revision())
424
430
            if merging_revision is None:
425
431
                raise InvalidRevisionSpec(revision[0].user_spec, b)
426
 
        pb.update('Finding revno')
 
432
        pb.update(gettext('Finding revno'))
427
433
        return b.revision_id_to_revno(merging_revision)
428
434
 
429
435
    def _find_proposals(self, revno, b, pb):
430
436
        launchpad = lp_api.login(lp_registration.LaunchpadService())
431
 
        pb.update('Finding Launchpad branch')
 
437
        pb.update(gettext('Finding Launchpad branch'))
432
438
        lpb = lp_api.LaunchpadBranch.from_bzr(launchpad, b,
433
439
                                              create_missing=False)
434
 
        pb.update('Finding proposals')
 
440
        pb.update(gettext('Finding proposals'))
435
441
        return list(lpb.lp.getMergeProposals(status=['Merged'],
436
442
                                             merged_revnos=[revno]))
437
443