bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
6622.7.1
by Colin Watson
Remove `bzr register-branch`, since it has not worked for a long time. |
1 |
# Copyright (C) 2006-2017 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 |
launchpad-mirror: Ask Launchpad to mirror a branch now
|
34 |
||
35 |
"""
|
|
|
0.4.1
by Martin Pool
Start lp-register command |
36 |
|
|
6379.6.1
by Jelmer Vernooij
Import absolute_import in a few places. |
37 |
from __future__ import absolute_import |
38 |
||
|
0.4.17
by Martin Pool
Allow xmlrpc service url to be overridden by $BZR_LP_XMLRPC_URL |
39 |
# The XMLRPC server address can be overridden by setting the environment
|
|
6622.1.28
by Jelmer Vernooij
More renames; commands in output, environment variables. |
40 |
# variable $BRZ_LP_XMLRPC_URL
|
|
0.4.17
by Martin Pool
Allow xmlrpc service url to be overridden by $BZR_LP_XMLRPC_URL |
41 |
|
|
5560.2.1
by Vincent Ladeuil
Fix the remaining references to http://bazaar-vcs.org (except the explicitly historical ones). |
42 |
# see http://wiki.bazaar.canonical.com/Specs/BranchRegistrationTool
|
|
0.4.9
by Martin Pool
Don't transmit non-standard xmlrpc <nil> value. |
43 |
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
44 |
from ... import ( |
|
5050.79.5
by John Arbash Meinel
Add a Branch.open hook. |
45 |
branch as _mod_branch, |
|
6464.1.1
by Jelmer Vernooij
Merge launchpad configuration to config stacks. |
46 |
config as _mod_config, |
|
5050.79.5
by John Arbash Meinel
Add a Branch.open hook. |
47 |
lazy_regex, |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
48 |
# Since we are a built-in plugin we share the breezy version
|
|
6491.2.1
by Jelmer Vernooij
lazily load launchpad plugin commands. |
49 |
trace, |
|
7143.11.1
by Jelmer Vernooij
Remove some unused imports. |
50 |
version_info, # noqa: F401 |
|
5050.79.5
by John Arbash Meinel
Add a Branch.open hook. |
51 |
)
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
52 |
from ...commands import ( |
|
6491.2.1
by Jelmer Vernooij
lazily load launchpad plugin commands. |
53 |
plugin_cmds, |
|
5753.2.2
by Jelmer Vernooij
Remove some unnecessary imports, clean up lazy imports. |
54 |
)
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
55 |
from ...directory_service import directories |
56 |
from ...help_topics import topic_registry |
|
|
6491.2.1
by Jelmer Vernooij
lazily load launchpad plugin commands. |
57 |
|
58 |
for klsname, aliases in [ |
|
59 |
("cmd_launchpad_open", ["lp-open"]), |
|
60 |
("cmd_launchpad_login", ["lp-login"]), |
|
|
6852.1.1
by Jelmer Vernooij
Add lp-logout command. |
61 |
("cmd_launchpad_logout", ["lp-logout"]), |
|
6491.2.1
by Jelmer Vernooij
lazily load launchpad plugin commands. |
62 |
("cmd_launchpad_mirror", ["lp-mirror"]), |
63 |
("cmd_lp_propose_merge", ["lp-submit", "lp-propose"]), |
|
64 |
("cmd_lp_find_proposal", [])]: |
|
65 |
plugin_cmds.register_lazy(klsname, aliases, |
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
66 |
"breezy.plugins.launchpad.cmds") |
|
5546.2.1
by Aaron Bentley
Add lp-find-proposal. |
67 |
|
68 |
||
|
3251.4.2
by Aaron Bentley
Clean up Launchpad directory service code |
69 |
def _register_directory(): |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
70 |
directories.register_lazy('lp:', 'breezy.plugins.launchpad.lp_directory', |
|
3251.4.2
by Aaron Bentley
Clean up Launchpad directory service code |
71 |
'LaunchpadDirectory', |
72 |
'Launchpad-based directory service',) |
|
|
5462.4.1
by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant |
73 |
directories.register_lazy( |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
74 |
'debianlp:', 'breezy.plugins.launchpad.lp_directory', |
|
5462.4.1
by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant |
75 |
'LaunchpadDirectory', |
76 |
'debianlp: shortcut') |
|
77 |
directories.register_lazy( |
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
78 |
'ubuntu:', 'breezy.plugins.launchpad.lp_directory', |
|
5462.4.1
by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant |
79 |
'LaunchpadDirectory', |
80 |
'ubuntu: shortcut') |
|
81 |
||
|
3251.4.2
by Aaron Bentley
Clean up Launchpad directory service code |
82 |
_register_directory() |
|
2245.8.5
by Martin Pool
Add short-form lp:PRODUCT url form |
83 |
|
|
6024.3.5
by John Arbash Meinel
Pull out code into helper functions, which allows us to test it. |
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
|
|
86 |
# json.
|
|
87 |
_package_branch = lazy_regex.lazy_compile( |
|
|
6024.3.4
by John Arbash Meinel
More tests, and a small fix for the regex. |
88 |
r'bazaar.launchpad.net.*?/' |
|
6024.3.3
by John Arbash Meinel
Start at least testing the package_branch regex. |
89 |
r'(?P<user>~[^/]+/)?(?P<archive>ubuntu|debian)/(?P<series>[^/]+/)?' |
|
5050.79.5
by John Arbash Meinel
Add a Branch.open hook. |
90 |
r'(?P<project>[^/]+)(?P<branch>/[^/]+)?' |
91 |
)
|
|
|
6024.3.5
by John Arbash Meinel
Pull out code into helper functions, which allows us to test it. |
92 |
|
93 |
def _get_package_branch_info(url): |
|
94 |
"""Determine the packaging information for this URL. |
|
95 |
||
96 |
:return: If this isn't a packaging branch, return None. If it is, return
|
|
97 |
(archive, series, project)
|
|
98 |
"""
|
|
|
6015.10.2
by John Arbash Meinel
Fix bug #816417, it seems older foreign branch implementations did not set Branch.base. |
99 |
if url is None: |
100 |
return None |
|
|
6024.3.5
by John Arbash Meinel
Pull out code into helper functions, which allows us to test it. |
101 |
m = _package_branch.search(url) |
|
5050.79.5
by John Arbash Meinel
Add a Branch.open hook. |
102 |
if m is None: |
|
6015.10.2
by John Arbash Meinel
Fix bug #816417, it seems older foreign branch implementations did not set Branch.base. |
103 |
return None |
|
6024.3.3
by John Arbash Meinel
Start at least testing the package_branch regex. |
104 |
archive, series, project, user = m.group('archive', 'series', |
105 |
'project', 'user') |
|
|
5050.79.5
by John Arbash Meinel
Add a Branch.open hook. |
106 |
if series is not None: |
|
5050.79.7
by John Arbash Meinel
clarify a comment. |
107 |
# series is optional, so the regex includes the extra '/', we don't
|
108 |
# want to send that on (it causes Internal Server Errors.)
|
|
|
5050.79.5
by John Arbash Meinel
Add a Branch.open hook. |
109 |
series = series.strip('/') |
|
6024.3.5
by John Arbash Meinel
Pull out code into helper functions, which allows us to test it. |
110 |
if user is not None: |
111 |
user = user.strip('~/') |
|
112 |
if user != 'ubuntu-branches': |
|
113 |
return None |
|
114 |
return archive, series, project |
|
115 |
||
116 |
||
117 |
def _check_is_up_to_date(the_branch): |
|
118 |
info = _get_package_branch_info(the_branch.base) |
|
119 |
if info is None: |
|
120 |
return
|
|
|
6464.1.2
by Jelmer Vernooij
Use bool_from_store, fix tests. |
121 |
c = the_branch.get_config_stack() |
|
6464.1.1
by Jelmer Vernooij
Merge launchpad configuration to config stacks. |
122 |
verbosity = c.get('launchpad.packaging_verbosity') |
123 |
if not verbosity: |
|
|
6024.3.8
by John Arbash Meinel
Move 'place' logic onto LatestPublication. |
124 |
trace.mutter('not checking %s because verbosity is turned off' |
125 |
% (the_branch.base,)) |
|
126 |
return
|
|
|
6024.3.5
by John Arbash Meinel
Pull out code into helper functions, which allows us to test it. |
127 |
archive, series, project = info |
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
128 |
from . import lp_api_lite |
|
5050.79.5
by John Arbash Meinel
Add a Branch.open hook. |
129 |
latest_pub = lp_api_lite.LatestPublication(archive, series, project) |
|
6024.3.8
by John Arbash Meinel
Move 'place' logic onto LatestPublication. |
130 |
lp_api_lite.report_freshness(the_branch, verbosity, latest_pub) |
131 |
||
|
5050.79.5
by John Arbash Meinel
Add a Branch.open hook. |
132 |
|
133 |
def _register_hooks(): |
|
134 |
_mod_branch.Branch.hooks.install_named_hook('open', |
|
135 |
_check_is_up_to_date, 'package-branch-up-to-date') |
|
136 |
||
137 |
||
138 |
_register_hooks() |
|
139 |
||
|
6625.1.5
by Martin
Drop custom load_tests implementation and use unittest signature |
140 |
def load_tests(loader, basic_tests, pattern): |
|
4776.2.2
by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers. |
141 |
testmod_names = [ |
142 |
'test_account', |
|
143 |
'test_register', |
|
|
4505.6.25
by Jonathan Lange
Add a test to check what happens if launchpadlib not available. |
144 |
'test_lp_api', |
|
5050.79.2
by John Arbash Meinel
Start refactoring lp_api_lite and making it testable. |
145 |
'test_lp_api_lite', |
|
4776.2.2
by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers. |
146 |
'test_lp_directory', |
147 |
'test_lp_login', |
|
148 |
'test_lp_open', |
|
149 |
'test_lp_service', |
|
150 |
]
|
|
151 |
basic_tests.addTest(loader.loadTestsFromModuleNames( |
|
152 |
["%s.%s" % (__name__, tmn) for tmn in testmod_names])) |
|
153 |
return basic_tests |
|
|
2245.8.1
by Martin Pool
Start adding tests for launchpad indirection |
154 |
|
|
2245.8.6
by Martin Pool
Documentation under 'help launchpad' |
155 |
|
156 |
_launchpad_help = """Integration with Launchpad.net |
|
157 |
||
158 |
Launchpad.net provides free Bazaar branch hosting with integrated bug and
|
|
159 |
specification tracking.
|
|
160 |
||
|
3031.1.1
by jml at canonical
Expand the documentation on lp:// URLs and mention the launchpad-login command. |
161 |
The bzr client (through the plugin called 'launchpad') has special
|
|
2245.8.6
by Martin Pool
Documentation under 'help launchpad' |
162 |
features to communicate with Launchpad:
|
163 |
||
|
3031.1.1
by jml at canonical
Expand the documentation on lp:// URLs and mention the launchpad-login command. |
164 |
* The launchpad-login command tells Bazaar your Launchpad user name. This
|
165 |
is then used by the 'lp:' transport to download your branches using
|
|
166 |
bzr+ssh://.
|
|
167 |
||
|
4258.1.1
by James Westby
Add "--fixes lp:" to the launchpad plugin documentation. |
168 |
* The 'lp:' transport uses Launchpad as a directory service: for example
|
169 |
'lp:bzr' and 'lp:python' refer to the main branches of the relevant
|
|
170 |
projects and may be branched, logged, etc. You can also use the 'lp:'
|
|
171 |
transport to refer to specific branches, e.g. lp:~bzr/bzr/trunk.
|
|
172 |
||
173 |
* The 'lp:' bug tracker alias can expand launchpad bug numbers to their
|
|
174 |
URLs for use with 'bzr commit --fixes', e.g. 'bzr commit --fixes lp:12345'
|
|
175 |
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 |
176 |
Launchpad bug 12345. When you push that branch to Launchpad it will
|
177 |
automatically be linked to the bug report.
|
|
|
4258.1.1
by James Westby
Add "--fixes lp:" to the launchpad plugin documentation. |
178 |
|
|
2245.8.6
by Martin Pool
Documentation under 'help launchpad' |
179 |
For more information see http://help.launchpad.net/
|
180 |
"""
|
|
181 |
topic_registry.register('launchpad', |
|
182 |
_launchpad_help, |
|
183 |
'Using Bazaar with Launchpad.net') |
|
|
6464.1.1
by Jelmer Vernooij
Merge launchpad configuration to config stacks. |
184 |
|
185 |
_mod_config.option_registry.register( |
|
|
6464.1.2
by Jelmer Vernooij
Use bool_from_store, fix tests. |
186 |
_mod_config.Option('launchpad.packaging_verbosity', default=True, |
187 |
from_unicode=_mod_config.bool_from_store, |
|
|
6464.1.1
by Jelmer Vernooij
Merge launchpad configuration to config stacks. |
188 |
help="""\ |
189 |
Whether to warn if a UDD package import branch is accessed that is out of date.
|
|
190 |
||
191 |
Setting this option to 'off' will disable verbosity.
|
|
192 |
""")) |
|
193 |
_mod_config.option_registry.register( |
|
|
6464.1.2
by Jelmer Vernooij
Use bool_from_store, fix tests. |
194 |
_mod_config.Option('launchpad_username', default=None, |
|
6464.1.1
by Jelmer Vernooij
Merge launchpad configuration to config stacks. |
195 |
help="The username to login with when conneting to Launchpad.")) |