/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2006 - 2008 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
21
21
 
22
22
# see http://bazaar-vcs.org/Specs/BranchRegistrationTool
23
23
 
 
24
from bzrlib.branch import Branch
24
25
from bzrlib.commands import Command, Option, register_command
25
 
from bzrlib.transport import register_lazy_transport
 
26
from bzrlib.directory_service import directories
 
27
from bzrlib.errors import BzrCommandError, NoPublicBranch, NotBranchError
26
28
from bzrlib.help_topics import topic_registry
27
29
 
28
30
 
37
39
    branch belongs, and create an account for yourself on launchpad.net.
38
40
 
39
41
    arguments:
40
 
        branch_url: The publicly visible url for the branch.
41
 
                    This must be an http or https url, not a local file
42
 
                    path.
 
42
        public_url: The publicly visible url for the branch to register.
 
43
                    This must be an http or https url (which Launchpad can read
 
44
                    from to access the branch). Local file urls, SFTP urls, and
 
45
                    bzr+ssh urls will not work.
 
46
                    If no public_url is provided, bzr will use the configured
 
47
                    public_url if there is one for the current branch, and
 
48
                    otherwise error.
43
49
 
44
50
    example:
45
51
        bzr register-branch http://foo.com/bzr/fooproduct.mine \\
46
52
                --product fooproduct
47
53
    """
48
 
    takes_args = ['branch_url']
 
54
    takes_args = ['public_url?']
49
55
    takes_options = [
50
56
         Option('product',
51
57
                'Launchpad product short name to associate with the branch.',
71
77
        ]
72
78
 
73
79
 
74
 
    def run(self, 
75
 
            branch_url, 
 
80
    def run(self,
 
81
            public_url=None,
76
82
            product='',
77
83
            branch_name='',
78
84
            branch_title='',
83
89
        from bzrlib.plugins.launchpad.lp_registration import (
84
90
            LaunchpadService, BranchRegistrationRequest, BranchBugLinkRequest,
85
91
            DryRunLaunchpadService)
86
 
        rego = BranchRegistrationRequest(branch_url=branch_url,
 
92
        if public_url is None:
 
93
            try:
 
94
                b = Branch.open_containing('.')[0]
 
95
            except NotBranchError:
 
96
                raise BzrCommandError('register-branch requires a public '
 
97
                    'branch url - see bzr help register-branch.')
 
98
            public_url = b.get_public_branch()
 
99
            if public_url is None:
 
100
                raise NoPublicBranch(b)
 
101
 
 
102
        rego = BranchRegistrationRequest(branch_url=public_url,
87
103
                                         branch_name=branch_name,
88
104
                                         branch_title=branch_title,
89
105
                                         branch_description=branch_description,
90
106
                                         product_name=product,
91
107
                                         author_email=author,
92
108
                                         )
93
 
        linko = BranchBugLinkRequest(branch_url=branch_url,
 
109
        linko = BranchBugLinkRequest(branch_url=public_url,
94
110
                                     bug_id=link_bug)
95
111
        if not dry_run:
96
112
            service = LaunchpadService()
155
171
register_command(cmd_launchpad_login)
156
172
 
157
173
 
158
 
register_lazy_transport(
159
 
    'lp:',
160
 
    'bzrlib.plugins.launchpad.lp_indirect',
161
 
    'LaunchpadTransport')
 
174
def _register_directory():
 
175
    directories.register_lazy('lp:', 'bzrlib.plugins.launchpad.lp_directory',
 
176
                              'LaunchpadDirectory',
 
177
                              'Launchpad-based directory service',)
 
178
_register_directory()
162
179
 
163
 
register_lazy_transport(
164
 
    'lp://',
165
 
    'bzrlib.plugins.launchpad.lp_indirect',
166
 
    'LaunchpadTransport')
167
180
 
168
181
def test_suite():
169
182
    """Called by bzrlib to fetch tests for this plugin"""
170
183
    from unittest import TestSuite, TestLoader
171
184
    from bzrlib.plugins.launchpad import (
172
 
        test_register, test_lp_indirect, test_account)
 
185
         test_account, test_lp_directory, test_lp_service, test_register,
 
186
         )
173
187
 
174
188
    loader = TestLoader()
175
189
    suite = TestSuite()
176
 
    for m in [test_register, test_lp_indirect, test_account]:
177
 
        suite.addTests(loader.loadTestsFromModule(m))
 
190
    for module in [
 
191
        test_account,
 
192
        test_register,
 
193
        test_lp_directory,
 
194
        test_lp_service,
 
195
        ]:
 
196
        suite.addTests(loader.loadTestsFromModule(module))
178
197
    return suite
179
198
 
180
199
_launchpad_help = """Integration with Launchpad.net