17
17
"""Launchpad.net integration plugin for Bazaar.
19
19
This plugin provides facilities for working with Bazaar branches that are
20
hosted on Launchpad (http://launchpad.net). It provides a directory service
20
hosted on Launchpad (http://launchpad.net). It provides a directory service
21
21
for referring to Launchpad branches using the "lp:" prefix. For example,
22
22
lp:bzr refers to the Bazaar's main development branch and
23
23
lp:~username/project/branch-name can be used to refer to a specific branch.
30
30
launchpad-login: Show or set the Launchpad user ID
31
31
launchpad-open: Open a Launchpad branch page in your web browser
33
As well as the following deprecated command:
32
35
lp-propose-merge: Propose merging a branch on Launchpad
33
launchpad-mirror: Ask Launchpad to mirror a branch now
36
(deprecated in favour of the more generic 'brz propose-merge')
59
62
("cmd_launchpad_open", ["lp-open"]),
60
63
("cmd_launchpad_login", ["lp-login"]),
61
64
("cmd_launchpad_logout", ["lp-logout"]),
62
("cmd_launchpad_mirror", ["lp-mirror"]),
63
65
("cmd_lp_propose_merge", ["lp-submit", "lp-propose"]),
64
("cmd_lp_find_proposal", [])]:
66
("cmd_lp_find_proposal", [])]:
65
67
plugin_cmds.register_lazy(klsname, aliases,
66
"breezy.plugins.launchpad.cmds")
68
"breezy.plugins.launchpad.cmds")
69
71
def _register_directory():
70
72
directories.register_lazy('lp:', 'breezy.plugins.launchpad.lp_directory',
71
73
'LaunchpadDirectory',
72
74
'Launchpad-based directory service',)
75
directories.register_lazy('lp+bzr:', 'breezy.plugins.launchpad.lp_directory',
77
'Bazaar-specific Launchpad directory service',)
73
78
directories.register_lazy(
74
79
'debianlp:', 'breezy.plugins.launchpad.lp_directory',
75
80
'LaunchpadDirectory',
79
84
'LaunchpadDirectory',
80
85
'ubuntu: shortcut')
82
88
_register_directory()
84
# This is kept in __init__ so that we don't load lp_api_lite unless the branch
85
# actually matches. That way we can avoid importing extra dependencies like
87
_package_branch = lazy_regex.lazy_compile(
88
r'bazaar.launchpad.net.*?/'
89
r'(?P<user>~[^/]+/)?(?P<archive>ubuntu|debian)/(?P<series>[^/]+/)?'
90
r'(?P<project>[^/]+)(?P<branch>/[^/]+)?'
93
def _get_package_branch_info(url):
94
"""Determine the packaging information for this URL.
96
:return: If this isn't a packaging branch, return None. If it is, return
97
(archive, series, project)
101
m = _package_branch.search(url)
104
archive, series, project, user = m.group('archive', 'series',
106
if series is not None:
107
# series is optional, so the regex includes the extra '/', we don't
108
# want to send that on (it causes Internal Server Errors.)
109
series = series.strip('/')
111
user = user.strip('~/')
112
if user != 'ubuntu-branches':
114
return archive, series, project
117
def _check_is_up_to_date(the_branch):
118
info = _get_package_branch_info(the_branch.base)
121
c = the_branch.get_config_stack()
122
verbosity = c.get('launchpad.packaging_verbosity')
124
trace.mutter('not checking %s because verbosity is turned off'
125
% (the_branch.base,))
127
archive, series, project = info
128
from . import lp_api_lite
129
latest_pub = lp_api_lite.LatestPublication(archive, series, project)
130
lp_api_lite.report_freshness(the_branch, verbosity, latest_pub)
133
def _register_hooks():
134
_mod_branch.Branch.hooks.install_named_hook('open',
135
_check_is_up_to_date, 'package-branch-up-to-date')
140
90
def load_tests(loader, basic_tests, pattern):
146
95
'test_lp_directory',
149
98
'test_lp_service',
151
100
basic_tests.addTest(loader.loadTestsFromModuleNames(
152
["%s.%s" % (__name__, tmn) for tmn in testmod_names]))
101
["%s.%s" % (__name__, tmn) for tmn in testmod_names]))
153
102
return basic_tests
179
128
For more information see http://help.launchpad.net/
181
130
topic_registry.register('launchpad',
183
'Using Bazaar with Launchpad.net')
185
_mod_config.option_registry.register(
186
_mod_config.Option('launchpad.packaging_verbosity', default=True,
187
from_unicode=_mod_config.bool_from_store,
189
Whether to warn if a UDD package import branch is accessed that is out of date.
191
Setting this option to 'off' will disable verbosity.
193
_mod_config.option_registry.register(
194
_mod_config.Option('launchpad_username', default=None,
195
help="The username to login with when conneting to Launchpad."))
132
'Using Bazaar with Launchpad.net')