0.4.1
by Martin Pool
Start lp-register command |
1 |
# Copyright (C) 2006 by Canonical Ltd
|
2 |
#
|
|
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.
|
|
7 |
#
|
|
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.
|
|
12 |
#
|
|
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
|
|
16 |
||
17 |
"""Launchpad.net branch registration plugin for bzr
|
|
18 |
||
19 |
This adds commands that tell launchpad about newly-created branches, etc.
|
|
20 |
||
21 |
To install this file, put the 'bzr_lp' directory, or a symlink to it,
|
|
22 |
in your ~/.bazaar/plugins/ directory.
|
|
23 |
"""
|
|
24 |
||
0.4.17
by Martin Pool
Allow xmlrpc service url to be overridden by $BZR_LP_XMLRPC_URL |
25 |
# The XMLRPC server address can be overridden by setting the environment
|
26 |
# variable $BZR_LP_XMLRPL_URL
|
|
27 |
||
0.4.9
by Martin Pool
Don't transmit non-standard xmlrpc <nil> value. |
28 |
# see http://bazaar-vcs.org/Specs/BranchRegistrationTool
|
29 |
||
0.4.1
by Martin Pool
Start lp-register command |
30 |
from bzrlib.commands import Command, Option, register_command |
31 |
||
0.4.4
by Martin Pool
Start forming xmlrpc requests |
32 |
|
33 |
||
0.4.2
by Martin Pool
Rename command to 'register-branch' |
34 |
class cmd_register_branch(Command): |
35 |
"""Register a branch with launchpad.net.
|
|
0.4.1
by Martin Pool
Start lp-register command |
36 |
|
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.
|
|
40 |
|
|
0.4.15
by Martin Pool
(register-branch) Add command-line options |
41 |
Before using this command you must register the product to which the
|
0.4.1
by Martin Pool
Start lp-register command |
42 |
branch belongs, and create an account for yourself on launchpad.net.
|
0.4.3
by Martin Pool
More command line processing |
43 |
|
44 |
arguments:
|
|
45 |
branch_url: The publicly visible url for the branch.
|
|
46 |
This must be an http or https url, not a local file
|
|
47 |
path.
|
|
48 |
||
49 |
example:
|
|
0.4.15
by Martin Pool
(register-branch) Add command-line options |
50 |
bzr register-branch http://foo.com/bzr/fooproduct.mine \\
|
51 |
--product fooproduct
|
|
0.4.1
by Martin Pool
Start lp-register command |
52 |
"""
|
0.4.3
by Martin Pool
More command line processing |
53 |
takes_args = ['branch_url'] |
0.4.15
by Martin Pool
(register-branch) Add command-line options |
54 |
takes_options = \ |
55 |
[Option('product', |
|
56 |
'launchpad product short name to associate with the branch', |
|
57 |
unicode), |
|
58 |
Option('branch-name', |
|
59 |
'short name for the branch; '
|
|
60 |
'by default taken from the last component of the url', |
|
61 |
unicode), |
|
62 |
Option('branch-title', |
|
63 |
'one-sentence description of the branch', |
|
64 |
unicode), |
|
65 |
Option('branch-description', |
|
66 |
'longer description of the purpose or contents of the branch', |
|
67 |
unicode), |
|
0.4.16
by Martin Pool
(register-branch) Add --author option and respect --dry-run |
68 |
Option('author', |
69 |
'email of the branch\'s author, if not yourself', |
|
70 |
unicode), |
|
0.4.19
by test at canonical
add possibility to link to a bug when registering a branch. factor out some common functionality from BranchRegistrationRequest. |
71 |
Option('link-bug', |
72 |
'the bug this branch fixes', |
|
73 |
int), |
|
0.4.15
by Martin Pool
(register-branch) Add command-line options |
74 |
Option('dry-run', |
75 |
'prepare the request but don\'t actually send it') |
|
76 |
]
|
|
77 |
||
78 |
||
79 |
def run(self, |
|
80 |
branch_url, |
|
1668.1.12
by Martin Pool
(launchpad plugin) Improved --dry-run that uses a dummy xmlrpc service. |
81 |
product='', |
0.4.15
by Martin Pool
(register-branch) Add command-line options |
82 |
branch_name='', |
83 |
branch_title='', |
|
84 |
branch_description='', |
|
0.4.16
by Martin Pool
(register-branch) Add --author option and respect --dry-run |
85 |
author='', |
0.4.19
by test at canonical
add possibility to link to a bug when registering a branch. factor out some common functionality from BranchRegistrationRequest. |
86 |
link_bug=None, |
0.4.15
by Martin Pool
(register-branch) Add command-line options |
87 |
dry_run=False): |
0.4.19
by test at canonical
add possibility to link to a bug when registering a branch. factor out some common functionality from BranchRegistrationRequest. |
88 |
from lp_registration import ( |
1668.1.12
by Martin Pool
(launchpad plugin) Improved --dry-run that uses a dummy xmlrpc service. |
89 |
LaunchpadService, BranchRegistrationRequest, BranchBugLinkRequest, |
90 |
DryRunLaunchpadService) |
|
91 |
rego = BranchRegistrationRequest(branch_url=branch_url, |
|
0.4.15
by Martin Pool
(register-branch) Add command-line options |
92 |
branch_name=branch_name, |
93 |
branch_title=branch_title, |
|
94 |
branch_description=branch_description, |
|
95 |
product_name=product, |
|
0.4.16
by Martin Pool
(register-branch) Add --author option and respect --dry-run |
96 |
author_email=author, |
0.4.15
by Martin Pool
(register-branch) Add command-line options |
97 |
)
|
0.4.19
by test at canonical
add possibility to link to a bug when registering a branch. factor out some common functionality from BranchRegistrationRequest. |
98 |
linko = BranchBugLinkRequest(branch_url=branch_url, |
99 |
bug_id=link_bug) |
|
1668.1.12
by Martin Pool
(launchpad plugin) Improved --dry-run that uses a dummy xmlrpc service. |
100 |
if not dry_run: |
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
|
|
106 |
# well.
|
|
107 |
else: |
|
108 |
# Run on service entirely in memory
|
|
109 |
service = DryRunLaunchpadService() |
|
0.4.19
by test at canonical
add possibility to link to a bug when registering a branch. factor out some common functionality from BranchRegistrationRequest. |
110 |
service.gather_user_credentials() |
1668.1.12
by Martin Pool
(launchpad plugin) Improved --dry-run that uses a dummy xmlrpc service. |
111 |
branch_object_url = rego.submit(service) |
112 |
if link_bug: |
|
113 |
link_bug_url = linko.submit(service) |
|
114 |
print 'Branch registered.' |
|
0.4.1
by Martin Pool
Start lp-register command |
115 |
|
0.4.2
by Martin Pool
Rename command to 'register-branch' |
116 |
register_command(cmd_register_branch) |
0.4.1
by Martin Pool
Start lp-register command |
117 |
|
118 |
def test_suite(): |
|
119 |
"""Called by bzrlib to fetch tests for this plugin"""
|
|
120 |
from unittest import TestSuite, TestLoader |
|
121 |
import test_register |
|
122 |
return TestLoader().loadTestsFromModule(test_register) |