22
22
# see http://bazaar-vcs.org/Specs/BranchRegistrationTool
24
from bzrlib.branch import Branch
24
from bzrlib.lazy_import import lazy_import
25
lazy_import(globals(), """
29
branch as _mod_branch,
25
34
from bzrlib.commands import Command, Option, register_command
26
35
from bzrlib.directory_service import directories
27
from bzrlib.errors import BzrCommandError, NoPublicBranch, NotBranchError
36
from bzrlib.errors import (
28
42
from bzrlib.help_topics import topic_registry
43
from bzrlib.plugins.launchpad.lp_registration import (
31
49
class cmd_register_branch(Command):
34
52
This command lists a bzr branch in the directory of branches on
35
53
launchpad.net. Registration allows the branch to be associated with
36
54
bugs or specifications.
38
56
Before using this command you must register the product to which the
39
57
branch belongs, and create an account for yourself on launchpad.net.
127
145
register_command(cmd_register_branch)
148
class cmd_launchpad_open(Command):
149
"""Open a Launchpad branch page in your web browser."""
151
aliases = ['lp-open']
154
'Do not actually open the browser. Just say the URL we would '
157
takes_args = ['location?']
159
def _possible_locations(self, location):
160
"""Yield possible external locations for the branch at 'location'."""
163
branch = _mod_branch.Branch.open(location)
164
except NotBranchError:
166
branch_url = branch.get_public_branch()
167
if branch_url is not None:
169
branch_url = branch.get_push_location()
170
if branch_url is not None:
173
def _get_web_url(self, service, location):
174
for branch_url in self._possible_locations(location):
176
return service.get_web_url_from_branch_url(branch_url)
177
except (NotLaunchpadBranch, InvalidURL):
179
raise NotLaunchpadBranch(branch_url)
181
def run(self, location=None, dry_run=False):
184
web_url = self._get_web_url(LaunchpadService(), location)
185
trace.note('Opening %s in web browser' % web_url)
187
webbrowser.open(web_url)
189
register_command(cmd_launchpad_open)
130
192
class cmd_launchpad_login(Command):
131
193
"""Show or set the Launchpad user ID.
182
244
"""Called by bzrlib to fetch tests for this plugin"""
183
245
from unittest import TestSuite, TestLoader
184
246
from bzrlib.plugins.launchpad import (
185
test_account, test_lp_directory, test_lp_service, test_register,
188
254
loader = TestLoader()
189
255
suite = TestSuite()