~bzr-pqm/bzr/bzr.dev

4763.2.4 by John Arbash Meinel
merge bzr.2.1 in preparation for NEWS entry.
1
# Copyright (C) 2006-2010 Canonical Ltd
0.4.1 by Martin Pool
Start lp-register command
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
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
0.4.1 by Martin Pool
Start lp-register command
16
5459.3.1 by Neil Martinsen-Burrell
add more detailed help for Launchpad plugin
17
"""Launchpad.net integration plugin for Bazaar.
18
19
This plugin provides facilities for working with Bazaar branches that are
20
hosted on Launchpad (http://launchpad.net).  It provides a directory service 
5459.3.2 by Neil Martinsen-Burrell
address James Westbys review comments
21
for referring to Launchpad branches using the "lp:" prefix.  For example,
22
lp:bzr refers to the Bazaar's main development branch and
23
lp:~username/project/branch-name can be used to refer to a specific branch.
24
25
This plugin provides a bug tracker so that "bzr commit --fixes lp:1234" will
26
record that revision as fixing Launchpad's bug 1234.
27
28
The plugin also provides the following commands:
29
30
    launchpad-login: Show or set the Launchpad user ID
31
    launchpad-open: Open a Launchpad branch page in your web browser
32
    lp-propose-merge: Propose merging a branch on Launchpad
5459.3.1 by Neil Martinsen-Burrell
add more detailed help for Launchpad plugin
33
    register-branch: Register a branch with launchpad.net
34
    launchpad-mirror: Ask Launchpad to mirror a branch now
35
36
"""
0.4.1 by Martin Pool
Start lp-register command
37
0.4.17 by Martin Pool
Allow xmlrpc service url to be overridden by $BZR_LP_XMLRPC_URL
38
# The XMLRPC server address can be overridden by setting the environment
5053.1.1 by Martin Pool
Merge 2.1 back to trunk
39
# variable $BZR_LP_XMLRPC_URL
0.4.17 by Martin Pool
Allow xmlrpc service url to be overridden by $BZR_LP_XMLRPC_URL
40
0.4.9 by Martin Pool
Don't transmit non-standard xmlrpc <nil> value.
41
# see http://bazaar-vcs.org/Specs/BranchRegistrationTool
42
4283.3.1 by Vincent Ladeuil
Make built-in plugins display the same version than bzrlib.
43
# Since we are a built-in plugin we share the bzrlib version
44
from bzrlib import version_info
45
4031.2.11 by John Arbash Meinel
Turn a bunch of imports into lazy imports.
46
from bzrlib.lazy_import import lazy_import
47
lazy_import(globals(), """
48
from bzrlib import (
49
    branch as _mod_branch,
50
    trace,
51
    )
52
""")
53
4969.2.7 by Aaron Bentley
Add lp-submit, get working.
54
from bzrlib import bzrdir
55
from bzrlib.commands import (
56
        Command,
57
        register_command,
58
)
3251.4.1 by Aaron Bentley
Convert LP transport into directory service
59
from bzrlib.directory_service import directories
4031.2.5 by Jonathan Lange
Refactor the code so we don't do too many remote requests.
60
from bzrlib.errors import (
61
    BzrCommandError,
4505.6.25 by Jonathan Lange
Add a test to check what happens if launchpadlib not available.
62
    DependencyNotPresent,
4031.2.5 by Jonathan Lange
Refactor the code so we don't do too many remote requests.
63
    InvalidURL,
64
    NoPublicBranch,
65
    NotBranchError,
66
    )
2245.8.6 by Martin Pool
Documentation under 'help launchpad'
67
from bzrlib.help_topics import topic_registry
4969.2.7 by Aaron Bentley
Add lp-submit, get working.
68
from bzrlib.option import (
4969.2.10 by Aaron Bentley
Cleanup and docs.
69
        Option,
4969.2.7 by Aaron Bentley
Add lp-submit, get working.
70
        ListOption,
71
)
0.4.4 by Martin Pool
Start forming xmlrpc requests
72
73
0.4.2 by Martin Pool
Rename command to 'register-branch'
74
class cmd_register_branch(Command):
5131.2.1 by Martin
Permit bzrlib to run under python -OO by explictly assigning to __doc__ for user-visible docstrings
75
    __doc__ = """Register a branch with launchpad.net.
0.4.1 by Martin Pool
Start lp-register command
76
77
    This command lists a bzr branch in the directory of branches on
2400.2.4 by Robert Collins
(robertc) Typo in the help for ``register-branch`` fixed. (Robert Collins, #96770)
78
    launchpad.net.  Registration allows the branch to be associated with
0.4.1 by Martin Pool
Start lp-register command
79
    bugs or specifications.
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
80
4416.7.1 by Neil Martinsen-Burrell
Fix 238764 refer to projects rather than products in launchpad plugin
81
    Before using this command you must register the project to which the
0.4.1 by Martin Pool
Start lp-register command
82
    branch belongs, and create an account for yourself on launchpad.net.
0.4.3 by Martin Pool
More command line processing
83
84
    arguments:
3200.2.3 by Robert Collins
Tweak wording.
85
        public_url: The publicly visible url for the branch to register.
3200.2.1 by Robert Collins
* The ``register-branch`` command will now use the public url of the branch
86
                    This must be an http or https url (which Launchpad can read
87
                    from to access the branch). Local file urls, SFTP urls, and
88
                    bzr+ssh urls will not work.
89
                    If no public_url is provided, bzr will use the configured
3200.2.3 by Robert Collins
Tweak wording.
90
                    public_url if there is one for the current branch, and
91
                    otherwise error.
0.4.3 by Martin Pool
More command line processing
92
93
    example:
4416.7.1 by Neil Martinsen-Burrell
Fix 238764 refer to projects rather than products in launchpad plugin
94
        bzr register-branch http://foo.com/bzr/fooproject.mine \\
95
                --project fooproject
0.4.1 by Martin Pool
Start lp-register command
96
    """
3200.2.1 by Robert Collins
* The ``register-branch`` command will now use the public url of the branch
97
    takes_args = ['public_url?']
2598.1.1 by Martin Pool
Add test for and documentation of option style, fix up existing options to comply
98
    takes_options = [
4416.7.1 by Neil Martinsen-Burrell
Fix 238764 refer to projects rather than products in launchpad plugin
99
         Option('project',
100
                'Launchpad project short name to associate with the branch.',
0.4.15 by Martin Pool
(register-branch) Add command-line options
101
                unicode),
4416.7.3 by Neil Martinsen-Burrell
Retain --product options for register-branch, but deprecate it in favor of --project
102
         Option('product',
103
                'Launchpad product short name to associate with the branch.', 
104
                unicode,
105
                hidden=True),
0.4.15 by Martin Pool
(register-branch) Add command-line options
106
         Option('branch-name',
2598.1.1 by Martin Pool
Add test for and documentation of option style, fix up existing options to comply
107
                'Short name for the branch; '
108
                'by default taken from the last component of the url.',
0.4.15 by Martin Pool
(register-branch) Add command-line options
109
                unicode),
110
         Option('branch-title',
2598.1.1 by Martin Pool
Add test for and documentation of option style, fix up existing options to comply
111
                'One-sentence description of the branch.',
0.4.15 by Martin Pool
(register-branch) Add command-line options
112
                unicode),
113
         Option('branch-description',
2598.1.5 by Martin Pool
Fix one more option message.
114
                'Longer description of the purpose or contents of the branch.',
0.4.15 by Martin Pool
(register-branch) Add command-line options
115
                unicode),
2598.1.1 by Martin Pool
Add test for and documentation of option style, fix up existing options to comply
116
         Option('author',
117
                "Branch author's email address, if not yourself.",
0.4.16 by Martin Pool
(register-branch) Add --author option and respect --dry-run
118
                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.
119
         Option('link-bug',
2598.1.1 by Martin Pool
Add test for and documentation of option style, fix up existing options to comply
120
                'The bug this branch fixes.',
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.
121
                int),
0.4.15 by Martin Pool
(register-branch) Add command-line options
122
         Option('dry-run',
2598.1.1 by Martin Pool
Add test for and documentation of option style, fix up existing options to comply
123
                'Prepare the request but don\'t actually send it.')
0.4.15 by Martin Pool
(register-branch) Add command-line options
124
        ]
125
126
3200.2.1 by Robert Collins
* The ``register-branch`` command will now use the public url of the branch
127
    def run(self,
128
            public_url=None,
4416.7.1 by Neil Martinsen-Burrell
Fix 238764 refer to projects rather than products in launchpad plugin
129
            project='',
4416.7.3 by Neil Martinsen-Burrell
Retain --product options for register-branch, but deprecate it in favor of --project
130
            product=None,
0.4.15 by Martin Pool
(register-branch) Add command-line options
131
            branch_name='',
132
            branch_title='',
133
            branch_description='',
0.4.16 by Martin Pool
(register-branch) Add --author option and respect --dry-run
134
            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.
135
            link_bug=None,
0.4.15 by Martin Pool
(register-branch) Add command-line options
136
            dry_run=False):
2898.3.8 by James Henstridge
Get rid of relative imports in Launchpad plugin.
137
        from bzrlib.plugins.launchpad.lp_registration import (
4505.6.4 by Jonathan Lange
Remove unnecessary import.
138
            BranchRegistrationRequest, BranchBugLinkRequest,
4505.6.10 by Jonathan Lange
Move lp_registration imports into commands.
139
            DryRunLaunchpadService, LaunchpadService)
3200.2.1 by Robert Collins
* The ``register-branch`` command will now use the public url of the branch
140
        if public_url is None:
141
            try:
4031.2.11 by John Arbash Meinel
Turn a bunch of imports into lazy imports.
142
                b = _mod_branch.Branch.open_containing('.')[0]
3200.2.1 by Robert Collins
* The ``register-branch`` command will now use the public url of the branch
143
            except NotBranchError:
144
                raise BzrCommandError('register-branch requires a public '
145
                    'branch url - see bzr help register-branch.')
146
            public_url = b.get_public_branch()
147
            if public_url is None:
148
                raise NoPublicBranch(b)
4416.7.3 by Neil Martinsen-Burrell
Retain --product options for register-branch, but deprecate it in favor of --project
149
        if product is not None:
150
            project = product
151
            trace.note('--product is deprecated; please use --project.')
152
3200.2.1 by Robert Collins
* The ``register-branch`` command will now use the public url of the branch
153
154
        rego = BranchRegistrationRequest(branch_url=public_url,
0.4.15 by Martin Pool
(register-branch) Add command-line options
155
                                         branch_name=branch_name,
156
                                         branch_title=branch_title,
157
                                         branch_description=branch_description,
4416.7.1 by Neil Martinsen-Burrell
Fix 238764 refer to projects rather than products in launchpad plugin
158
                                         product_name=project,
0.4.16 by Martin Pool
(register-branch) Add --author option and respect --dry-run
159
                                         author_email=author,
0.4.15 by Martin Pool
(register-branch) Add command-line options
160
                                         )
3200.2.1 by Robert Collins
* The ``register-branch`` command will now use the public url of the branch
161
        linko = BranchBugLinkRequest(branch_url=public_url,
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.
162
                                     bug_id=link_bug)
1668.1.12 by Martin Pool
(launchpad plugin) Improved --dry-run that uses a dummy xmlrpc service.
163
        if not dry_run:
164
            service = LaunchpadService()
165
            # This gives back the xmlrpc url that can be used for future
166
            # operations on the branch.  It's not so useful to print to the
167
            # user since they can't do anything with it from a web browser; it
168
            # might be nice for the server to tell us about an html url as
169
            # well.
170
        else:
171
            # Run on service entirely in memory
172
            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.
173
        service.gather_user_credentials()
4505.6.21 by Jonathan Lange
Clean up flakes.
174
        rego.submit(service)
1668.1.12 by Martin Pool
(launchpad plugin) Improved --dry-run that uses a dummy xmlrpc service.
175
        if link_bug:
4505.6.21 by Jonathan Lange
Clean up flakes.
176
            linko.submit(service)
1668.1.12 by Martin Pool
(launchpad plugin) Improved --dry-run that uses a dummy xmlrpc service.
177
        print 'Branch registered.'
0.4.1 by Martin Pool
Start lp-register command
178
0.4.2 by Martin Pool
Rename command to 'register-branch'
179
register_command(cmd_register_branch)
2245.8.4 by Martin Pool
lp:/// indirection works
180
2898.3.3 by James Henstridge
Add launchpad-login command.
181
3955.3.5 by Jonathan Lange
Add an untested plugin, make the error handling a little nicer.
182
class cmd_launchpad_open(Command):
5131.2.1 by Martin
Permit bzrlib to run under python -OO by explictly assigning to __doc__ for user-visible docstrings
183
    __doc__ = """Open a Launchpad branch page in your web browser."""
3955.3.5 by Jonathan Lange
Add an untested plugin, make the error handling a little nicer.
184
185
    aliases = ['lp-open']
3955.3.7 by Jonathan Lange
Test the launchpad-open command. Fix up some minor bugs.
186
    takes_options = [
187
        Option('dry-run',
188
               'Do not actually open the browser. Just say the URL we would '
189
               'use.'),
190
        ]
3955.3.5 by Jonathan Lange
Add an untested plugin, make the error handling a little nicer.
191
    takes_args = ['location?']
192
4031.2.5 by Jonathan Lange
Refactor the code so we don't do too many remote requests.
193
    def _possible_locations(self, location):
194
        """Yield possible external locations for the branch at 'location'."""
195
        yield location
196
        try:
4867.2.1 by Neil Martinsen-Burrell
launchpad-open works from a subdirectory of a branch
197
            branch = _mod_branch.Branch.open_containing(location)[0]
4031.2.5 by Jonathan Lange
Refactor the code so we don't do too many remote requests.
198
        except NotBranchError:
199
            return
200
        branch_url = branch.get_public_branch()
201
        if branch_url is not None:
202
            yield branch_url
203
        branch_url = branch.get_push_location()
204
        if branch_url is not None:
205
            yield branch_url
206
207
    def _get_web_url(self, service, location):
4505.6.10 by Jonathan Lange
Move lp_registration imports into commands.
208
        from bzrlib.plugins.launchpad.lp_registration import (
209
            NotLaunchpadBranch)
4031.2.5 by Jonathan Lange
Refactor the code so we don't do too many remote requests.
210
        for branch_url in self._possible_locations(location):
211
            try:
212
                return service.get_web_url_from_branch_url(branch_url)
213
            except (NotLaunchpadBranch, InvalidURL):
214
                pass
215
        raise NotLaunchpadBranch(branch_url)
216
3955.3.7 by Jonathan Lange
Test the launchpad-open command. Fix up some minor bugs.
217
    def run(self, location=None, dry_run=False):
4505.6.10 by Jonathan Lange
Move lp_registration imports into commands.
218
        from bzrlib.plugins.launchpad.lp_registration import (
219
            LaunchpadService)
3955.3.5 by Jonathan Lange
Add an untested plugin, make the error handling a little nicer.
220
        if location is None:
221
            location = u'.'
4505.6.21 by Jonathan Lange
Clean up flakes.
222
        web_url = self._get_web_url(LaunchpadService(), location)
4031.2.11 by John Arbash Meinel
Turn a bunch of imports into lazy imports.
223
        trace.note('Opening %s in web browser' % web_url)
3955.3.7 by Jonathan Lange
Test the launchpad-open command. Fix up some minor bugs.
224
        if not dry_run:
4511.1.1 by Alexander Belchenko
launchpad plugin: import webbrowse should be explicit and never lazy, otherwise bzr.exe lacks this module.
225
            import webbrowser   # this import should not be lazy
226
                                # otherwise bzr.exe lacks this module
3955.3.7 by Jonathan Lange
Test the launchpad-open command. Fix up some minor bugs.
227
            webbrowser.open(web_url)
3955.3.5 by Jonathan Lange
Add an untested plugin, make the error handling a little nicer.
228
229
register_command(cmd_launchpad_open)
230
231
2898.3.3 by James Henstridge
Add launchpad-login command.
232
class cmd_launchpad_login(Command):
5131.2.1 by Martin
Permit bzrlib to run under python -OO by explictly assigning to __doc__ for user-visible docstrings
233
    __doc__ = """Show or set the Launchpad user ID.
2898.3.3 by James Henstridge
Add launchpad-login command.
234
235
    When communicating with Launchpad, some commands need to know your
236
    Launchpad user ID.  This command can be used to set or show the
237
    user ID that Bazaar will use for such communication.
238
239
    :Examples:
240
      Show the Launchpad ID of the current user::
241
242
          bzr launchpad-login
243
2898.3.9 by James Henstridge
* Add a simple NEWS item for the command.
244
      Set the Launchpad ID of the current user to 'bob'::
2898.3.3 by James Henstridge
Add launchpad-login command.
245
2898.3.9 by James Henstridge
* Add a simple NEWS item for the command.
246
          bzr launchpad-login bob
2898.3.3 by James Henstridge
Add launchpad-login command.
247
    """
248
    aliases = ['lp-login']
249
    takes_args = ['name?']
250
    takes_options = [
4505.1.2 by Jonathan Lange
Add many more tests, fix the actual bug.
251
        'verbose',
2898.3.4 by James Henstridge
Cleanups from mini-review by Tim.
252
        Option('no-check',
253
               "Don't check that the user name is valid."),
2898.3.3 by James Henstridge
Add launchpad-login command.
254
        ]
255
4505.1.2 by Jonathan Lange
Add many more tests, fix the actual bug.
256
    def run(self, name=None, no_check=False, verbose=False):
4505.6.13 by Jonathan Lange
Clarify the comment.
257
        # This is totally separate from any launchpadlib login system.
2898.3.8 by James Henstridge
Get rid of relative imports in Launchpad plugin.
258
        from bzrlib.plugins.launchpad import account
2898.3.3 by James Henstridge
Add launchpad-login command.
259
        check_account = not no_check
260
261
        if name is None:
262
            username = account.get_lp_login()
263
            if username:
2898.3.4 by James Henstridge
Cleanups from mini-review by Tim.
264
                if check_account:
265
                    account.check_lp_login(username)
4505.1.3 by Jonathan Lange
Add some extra untested verbosity.
266
                    if verbose:
267
                        self.outf.write(
268
                            "Launchpad user ID exists and has SSH keys.\n")
2898.3.3 by James Henstridge
Add launchpad-login command.
269
                self.outf.write(username + '\n')
270
            else:
271
                self.outf.write('No Launchpad user ID configured.\n')
2898.3.9 by James Henstridge
* Add a simple NEWS item for the command.
272
                return 1
2898.3.3 by James Henstridge
Add launchpad-login command.
273
        else:
4216.2.1 by Michael Hudson
well this is it
274
            name = name.lower()
2898.3.3 by James Henstridge
Add launchpad-login command.
275
            if check_account:
276
                account.check_lp_login(name)
4505.1.3 by Jonathan Lange
Add some extra untested verbosity.
277
                if verbose:
278
                    self.outf.write(
279
                        "Launchpad user ID exists and has SSH keys.\n")
2898.3.3 by James Henstridge
Add launchpad-login command.
280
            account.set_lp_login(name)
4505.1.2 by Jonathan Lange
Add many more tests, fix the actual bug.
281
            if verbose:
282
                self.outf.write("Launchpad user ID set to '%s'.\n" % (name,))
2898.3.3 by James Henstridge
Add launchpad-login command.
283
284
register_command(cmd_launchpad_login)
285
286
4505.6.9 by Jonathan Lange
Add some XXX comments based on the review.
287
# XXX: cmd_launchpad_mirror is untested
4505.6.6 by Jonathan Lange
Add a command to mirror Launchpad branches now.
288
class cmd_launchpad_mirror(Command):
5131.2.1 by Martin
Permit bzrlib to run under python -OO by explictly assigning to __doc__ for user-visible docstrings
289
    __doc__ = """Ask Launchpad to mirror a branch now."""
4505.6.6 by Jonathan Lange
Add a command to mirror Launchpad branches now.
290
291
    aliases = ['lp-mirror']
292
    takes_args = ['location?']
293
294
    def run(self, location='.'):
4505.6.25 by Jonathan Lange
Add a test to check what happens if launchpadlib not available.
295
        from bzrlib.plugins.launchpad import lp_api
4505.6.10 by Jonathan Lange
Move lp_registration imports into commands.
296
        from bzrlib.plugins.launchpad.lp_registration import LaunchpadService
4505.6.30 by Jonathan Lange
Add basic smoke tests to show that the command exists.
297
        branch = _mod_branch.Branch.open(location)
4505.6.6 by Jonathan Lange
Add a command to mirror Launchpad branches now.
298
        service = LaunchpadService()
299
        launchpad = lp_api.login(service)
300
        lp_branch = lp_api.load_branch(launchpad, branch)
301
        lp_branch.requestMirror()
302
303
4505.6.8 by Jonathan Lange
Always register the lp-mirror command. Only try to load launchpadlib if
304
register_command(cmd_launchpad_mirror)
4505.6.6 by Jonathan Lange
Add a command to mirror Launchpad branches now.
305
306
4969.2.16 by Aaron Bentley
Updates from review.
307
class cmd_lp_propose_merge(Command):
5131.2.1 by Martin
Permit bzrlib to run under python -OO by explictly assigning to __doc__ for user-visible docstrings
308
    __doc__ = """Propose merging a branch on Launchpad.
4969.2.16 by Aaron Bentley
Updates from review.
309
310
    This will open your usual editor to provide the initial comment.  When it
4969.2.19 by Aaron Bentley
Rename submit to propose everywhere.
311
    has created the proposal, it will open it in your default web browser.
4969.2.16 by Aaron Bentley
Updates from review.
312
313
    The branch will be proposed to merge into SUBMIT_BRANCH.  If SUBMIT_BRANCH
314
    is not supplied, the remembered submit branch will be used.  If no submit
315
    branch is remembered, the development focus will be used.
316
317
    By default, the SUBMIT_BRANCH's review team will be requested to review
318
    the merge proposal.  This can be overriden by specifying --review (-R).
319
    The parameter the launchpad account name of the desired reviewer.  This
320
    may optionally be followed by '=' and the review type.  For example:
321
322
      bzr lp-propose-merge --review jrandom --review review-team=qa
323
324
    This will propose a merge,  request "jrandom" to perform a review of
325
    unspecified type, and request "review-team" to perform a "qa" review.
326
    """
4969.2.7 by Aaron Bentley
Add lp-submit, get working.
327
328
    takes_options = [Option('staging',
329
                            help='Propose the merge on staging.'),
330
                     Option('message', short_name='m', type=unicode,
331
                            help='Commit message.'),
5244.1.3 by Robert Collins
Allow setting new proposals as approved immediately.
332
                     Option('approve',
333
                            help='Mark the proposal as approved immediately.'),
4969.2.7 by Aaron Bentley
Add lp-submit, get working.
334
                     ListOption('review', short_name='R', type=unicode,
335
                            help='Requested reviewer and optional type.')]
336
337
    takes_args = ['submit_branch?']
338
4969.2.16 by Aaron Bentley
Updates from review.
339
    aliases = ['lp-submit', 'lp-propose']
340
4969.2.7 by Aaron Bentley
Add lp-submit, get working.
341
    def run(self, submit_branch=None, review=None, staging=False,
5244.1.3 by Robert Collins
Allow setting new proposals as approved immediately.
342
            message=None, approve=False):
4969.2.19 by Aaron Bentley
Rename submit to propose everywhere.
343
        from bzrlib.plugins.launchpad import lp_propose
4969.2.7 by Aaron Bentley
Add lp-submit, get working.
344
        tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
345
            '.')
346
        if review is None:
347
            reviews = None
348
        else:
349
            reviews = []
350
            for review in review:
351
                if '=' in review:
352
                    reviews.append(review.split('=', 2))
353
                else:
354
                    reviews.append((review, ''))
355
            if submit_branch is None:
356
                submit_branch = branch.get_submit_branch()
357
        if submit_branch is None:
358
            target = None
359
        else:
360
            target = _mod_branch.Branch.open(submit_branch)
4969.2.19 by Aaron Bentley
Rename submit to propose everywhere.
361
        proposer = lp_propose.Proposer(tree, branch, target, message,
5244.1.3 by Robert Collins
Allow setting new proposals as approved immediately.
362
                                       reviews, staging, approve=approve)
4969.2.19 by Aaron Bentley
Rename submit to propose everywhere.
363
        proposer.check_proposal()
364
        proposer.create_proposal()
4969.2.7 by Aaron Bentley
Add lp-submit, get working.
365
366
4969.2.16 by Aaron Bentley
Updates from review.
367
register_command(cmd_lp_propose_merge)
4969.2.7 by Aaron Bentley
Add lp-submit, get working.
368
369
3251.4.2 by Aaron Bentley
Clean up Launchpad directory service code
370
def _register_directory():
3251.4.3 by Aaron Bentley
More renames and cleanups
371
    directories.register_lazy('lp:', 'bzrlib.plugins.launchpad.lp_directory',
3251.4.2 by Aaron Bentley
Clean up Launchpad directory service code
372
                              'LaunchpadDirectory',
373
                              'Launchpad-based directory service',)
5462.4.1 by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant
374
    directories.register_lazy(
375
        'debianlp:', 'bzrlib.plugins.launchpad.lp_directory',
376
        'LaunchpadDirectory',
377
        'debianlp: shortcut')
378
    directories.register_lazy(
379
        'ubuntu:', 'bzrlib.plugins.launchpad.lp_directory',
380
        'LaunchpadDirectory',
381
        'ubuntu: shortcut')
382
3251.4.2 by Aaron Bentley
Clean up Launchpad directory service code
383
_register_directory()
2245.8.5 by Martin Pool
Add short-form lp:PRODUCT url form
384
0.4.1 by Martin Pool
Start lp-register command
385
4776.2.2 by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers.
386
def load_tests(basic_tests, module, loader):
387
    testmod_names = [
388
        'test_account',
389
        'test_register',
4505.6.25 by Jonathan Lange
Add a test to check what happens if launchpadlib not available.
390
        'test_lp_api',
4776.2.2 by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers.
391
        'test_lp_directory',
392
        'test_lp_login',
393
        'test_lp_open',
394
        'test_lp_service',
395
        ]
396
    basic_tests.addTest(loader.loadTestsFromModuleNames(
397
            ["%s.%s" % (__name__, tmn) for tmn in testmod_names]))
398
    return basic_tests
2245.8.1 by Martin Pool
Start adding tests for launchpad indirection
399
2245.8.6 by Martin Pool
Documentation under 'help launchpad'
400
401
_launchpad_help = """Integration with Launchpad.net
402
403
Launchpad.net provides free Bazaar branch hosting with integrated bug and
404
specification tracking.
405
3031.1.1 by jml at canonical
Expand the documentation on lp:// URLs and mention the launchpad-login command.
406
The bzr client (through the plugin called 'launchpad') has special
2245.8.6 by Martin Pool
Documentation under 'help launchpad'
407
features to communicate with Launchpad:
408
3031.1.1 by jml at canonical
Expand the documentation on lp:// URLs and mention the launchpad-login command.
409
    * The launchpad-login command tells Bazaar your Launchpad user name. This
410
      is then used by the 'lp:' transport to download your branches using
411
      bzr+ssh://.
412
4258.1.1 by James Westby
Add "--fixes lp:" to the launchpad plugin documentation.
413
    * The 'lp:' transport uses Launchpad as a directory service: for example
414
      'lp:bzr' and 'lp:python' refer to the main branches of the relevant
415
      projects and may be branched, logged, etc. You can also use the 'lp:'
416
      transport to refer to specific branches, e.g. lp:~bzr/bzr/trunk.
417
418
    * The 'lp:' bug tracker alias can expand launchpad bug numbers to their
419
      URLs for use with 'bzr commit --fixes', e.g. 'bzr commit --fixes lp:12345'
420
      will record a revision property that marks that revision as fixing
4258.1.2 by Matt Nordhoff
Fix a typo in the launchpad plugin's help
421
      Launchpad bug 12345. When you push that branch to Launchpad it will
422
      automatically be linked to the bug report.
4258.1.1 by James Westby
Add "--fixes lp:" to the launchpad plugin documentation.
423
3031.1.1 by jml at canonical
Expand the documentation on lp:// URLs and mention the launchpad-login command.
424
    * The register-branch command tells Launchpad about the url of a
2245.8.6 by Martin Pool
Documentation under 'help launchpad'
425
      public branch.  Launchpad will then mirror the branch, display
3031.1.1 by jml at canonical
Expand the documentation on lp:// URLs and mention the launchpad-login command.
426
      its contents and allow it to be attached to bugs and other
2245.8.6 by Martin Pool
Documentation under 'help launchpad'
427
      objects.
428
429
For more information see http://help.launchpad.net/
430
"""
431
topic_registry.register('launchpad',
432
    _launchpad_help,
433
    'Using Bazaar with Launchpad.net')