1
# Copyright (C) 2006 by Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
"""Launchpad.net branch registration plugin for bzr
19
This adds commands that tell launchpad about newly-created branches, etc.
21
To install this file, put the 'bzr_lp' directory, or a symlink to it,
22
in your ~/.bazaar/plugins/ directory.
25
# The XMLRPC server address can be overridden by setting the environment
26
# variable $BZR_LP_XMLRPL_URL
28
# see http://bazaar-vcs.org/Specs/BranchRegistrationTool
30
from bzrlib.commands import Command, Option, register_command
34
class cmd_register_branch(Command):
35
"""Register a branch with launchpad.net.
37
This command lists a bzr branch in the directory of branches on
38
launchpad.net. Registration allows the bug to be associated with
39
bugs or specifications.
41
Before using this command you must register the product to which the
42
branch belongs, and create an account for yourself on launchpad.net.
45
branch_url: The publicly visible url for the branch.
46
This must be an http or https url, not a local file
50
bzr register-branch http://foo.com/bzr/fooproduct.mine \\
53
takes_args = ['branch_url']
56
'launchpad product short name to associate with the branch',
59
'short name for the branch; '
60
'by default taken from the last component of the url',
62
Option('branch-title',
63
'one-sentence description of the branch',
65
Option('branch-description',
66
'longer description of the purpose or contents of the branch',
69
'email of the branch\'s author, if not yourself',
72
'the bug this branch fixes',
75
'prepare the request but don\'t actually send it')
84
branch_description='',
88
from lp_registration import (
89
LaunchpadService, BranchRegistrationRequest, BranchBugLinkRequest,
90
DryRunLaunchpadService)
91
rego = BranchRegistrationRequest(branch_url=branch_url,
92
branch_name=branch_name,
93
branch_title=branch_title,
94
branch_description=branch_description,
98
linko = BranchBugLinkRequest(branch_url=branch_url,
101
service = LaunchpadService()
102
# This gives back the xmlrpc url that can be used for future
103
# operations on the branch. It's not so useful to print to the
104
# user since they can't do anything with it from a web browser; it
105
# might be nice for the server to tell us about an html url as
108
# Run on service entirely in memory
109
service = DryRunLaunchpadService()
110
service.gather_user_credentials()
111
branch_object_url = rego.submit(service)
113
link_bug_url = linko.submit(service)
114
print 'Branch registered.'
116
register_command(cmd_register_branch)
119
"""Called by bzrlib to fetch tests for this plugin"""
120
from unittest import TestSuite, TestLoader
122
return TestLoader().loadTestsFromModule(test_register)