~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-02-18 04:59:30 UTC
  • mfrom: (4969.2.20 lpsubmit)
  • Revision ID: pqm@pqm.ubuntu.com-20100218045930-ycl34opyvhowbskr
(abentley, jml) provide propose-merge command.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 - 2008 Canonical Ltd
 
1
# Copyright (C) 2006 - 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
32
32
    )
33
33
""")
34
34
 
35
 
from bzrlib.commands import Command, Option, register_command
 
35
from bzrlib import bzrdir
 
36
from bzrlib.commands import (
 
37
        Command,
 
38
        register_command,
 
39
)
36
40
from bzrlib.directory_service import directories
37
41
from bzrlib.errors import (
38
42
    BzrCommandError,
42
46
    NotBranchError,
43
47
    )
44
48
from bzrlib.help_topics import topic_registry
 
49
from bzrlib.option import (
 
50
        Option,
 
51
        ListOption,
 
52
)
45
53
 
46
54
 
47
55
class cmd_register_branch(Command):
277
285
register_command(cmd_launchpad_mirror)
278
286
 
279
287
 
 
288
class cmd_lp_propose_merge(Command):
 
289
    """Propose merging a branch on Launchpad.
 
290
 
 
291
    This will open your usual editor to provide the initial comment.  When it
 
292
    has created the proposal, it will open it in your default web browser.
 
293
 
 
294
    The branch will be proposed to merge into SUBMIT_BRANCH.  If SUBMIT_BRANCH
 
295
    is not supplied, the remembered submit branch will be used.  If no submit
 
296
    branch is remembered, the development focus will be used.
 
297
 
 
298
    By default, the SUBMIT_BRANCH's review team will be requested to review
 
299
    the merge proposal.  This can be overriden by specifying --review (-R).
 
300
    The parameter the launchpad account name of the desired reviewer.  This
 
301
    may optionally be followed by '=' and the review type.  For example:
 
302
 
 
303
      bzr lp-propose-merge --review jrandom --review review-team=qa
 
304
 
 
305
    This will propose a merge,  request "jrandom" to perform a review of
 
306
    unspecified type, and request "review-team" to perform a "qa" review.
 
307
    """
 
308
 
 
309
    takes_options = [Option('staging',
 
310
                            help='Propose the merge on staging.'),
 
311
                     Option('message', short_name='m', type=unicode,
 
312
                            help='Commit message.'),
 
313
                     ListOption('review', short_name='R', type=unicode,
 
314
                            help='Requested reviewer and optional type.')]
 
315
 
 
316
    takes_args = ['submit_branch?']
 
317
 
 
318
    aliases = ['lp-submit', 'lp-propose']
 
319
 
 
320
    def run(self, submit_branch=None, review=None, staging=False,
 
321
            message=None):
 
322
        from bzrlib.plugins.launchpad import lp_propose
 
323
        tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
 
324
            '.')
 
325
        if review is None:
 
326
            reviews = None
 
327
        else:
 
328
            reviews = []
 
329
            for review in review:
 
330
                if '=' in review:
 
331
                    reviews.append(review.split('=', 2))
 
332
                else:
 
333
                    reviews.append((review, ''))
 
334
            if submit_branch is None:
 
335
                submit_branch = branch.get_submit_branch()
 
336
        if submit_branch is None:
 
337
            target = None
 
338
        else:
 
339
            target = _mod_branch.Branch.open(submit_branch)
 
340
        proposer = lp_propose.Proposer(tree, branch, target, message,
 
341
                                       reviews, staging)
 
342
        proposer.check_proposal()
 
343
        proposer.create_proposal()
 
344
 
 
345
 
 
346
register_command(cmd_lp_propose_merge)
 
347
 
 
348
 
280
349
def _register_directory():
281
350
    directories.register_lazy('lp:', 'bzrlib.plugins.launchpad.lp_directory',
282
351
                              'LaunchpadDirectory',