~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Aaron Bentley
  • Date: 2010-01-22 03:32:55 UTC
  • mto: This revision was merged to the branch mainline in revision 5049.
  • Revision ID: aaron@aaronbentley.com-20100122033255-sc1s015e6zp9x66q
Add lp-submit, get working.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
        Option,
 
39
        register_command,
 
40
)
36
41
from bzrlib.directory_service import directories
37
42
from bzrlib.errors import (
38
43
    BzrCommandError,
42
47
    NotBranchError,
43
48
    )
44
49
from bzrlib.help_topics import topic_registry
 
50
from bzrlib.option import (
 
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_submit(Command):
 
289
    """Submit the specified branch to Launchpad for merging."""
 
290
 
 
291
    takes_options = [Option('staging',
 
292
                            help='Propose the merge on staging.'),
 
293
                     Option('message', short_name='m', type=unicode,
 
294
                            help='Commit message.'),
 
295
                     ListOption('review', short_name='R', type=unicode,
 
296
                            help='Requested reviewer and optional type.')]
 
297
 
 
298
    takes_args = ['submit_branch?']
 
299
 
 
300
    def run(self, submit_branch=None, review=None, staging=False,
 
301
            message=None):
 
302
        from bzrlib.plugins.launchpad import lp_submit
 
303
        tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
 
304
            '.')
 
305
        if review is None:
 
306
            reviews = None
 
307
        else:
 
308
            reviews = []
 
309
            for review in review:
 
310
                if '=' in review:
 
311
                    reviews.append(review.split('=', 2))
 
312
                else:
 
313
                    reviews.append((review, ''))
 
314
            if submit_branch is None:
 
315
                submit_branch = branch.get_submit_branch()
 
316
        if submit_branch is None:
 
317
            target = None
 
318
        else:
 
319
            target = _mod_branch.Branch.open(submit_branch)
 
320
        submitter = lp_submit.Submitter(tree, branch, target, message,
 
321
                                        reviews, staging)
 
322
        submitter.check_submission()
 
323
        submitter.submit()
 
324
 
 
325
 
 
326
register_command(cmd_lp_submit)
 
327
 
 
328
 
280
329
def _register_directory():
281
330
    directories.register_lazy('lp:', 'bzrlib.plugins.launchpad.lp_directory',
282
331
                              'LaunchpadDirectory',