Merge lp:~jelmer/bzr-pqm/lazy-commands into lp:bzr-pqm

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 81
Merged at revision: 89
Proposed branch: lp:~jelmer/bzr-pqm/lazy-commands
Merge into: lp:bzr-pqm
Diff against target: 342 lines (+168/-152)
2 files modified
__init__.py (+3/-152)
cmds.py (+165/-0)
To merge this branch: bzr merge lp:~jelmer/bzr-pqm/lazy-commands
Reviewer Review Type Date Requested Status
Marius Kruger (community) Approve
Bzr-pqm-devel Pending
Review via email: mp+86069@code.launchpad.net

Description of the change

Lazily load the command implementations of bzr-pqm.

To post a comment you must log in.
Revision history for this message
Marius Kruger (amanica) wrote :

looks pretty mechanical to me, so +1 from me.
(I haven't tried to run it at all)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '__init__.py'
--- __init__.py 2010-09-09 12:27:00 +0000
+++ __init__.py 2011-12-16 16:01:58 +0000
@@ -16,9 +16,7 @@
16"""Functionality for controlling a Patch Queue Manager (pqm).16"""Functionality for controlling a Patch Queue Manager (pqm).
17"""17"""
1818
19from bzrlib.commands import Command, register_command19from bzrlib.commands import plugin_cmds
20from bzrlib.option import Option
21from bzrlib.errors import BzrCommandError
2220
2321
24version_info = (1, 4, 0, 'dev', 0)22version_info = (1, 4, 0, 'dev', 0)
@@ -30,155 +28,8 @@
30__version__ = version_string28__version__ = version_string
3129
3230
33class cmd_pqm_submit(Command):31plugin_cmds.register_lazy('cmd_pqm_submit', [], 'bzrlib.plugins.pqm.cmds')
34 """Submit the parent tree to the pqm.32plugin_cmds.register_lazy('cmd_lp_land', [], 'bzrlib.plugins.pqm.cmds')
35
36 This acts like:
37 $ echo "star-merge $PARENT $TARGET"
38 | gpg --cl
39 | mail pqm@somewhere -s "merge text"
40
41 But it pays attention to who the local committer is
42 (using their e-mail address), and uses the local
43 gpg signing configuration. (As well as target pqm
44 settings, etc.)
45
46 The reason we use 'parent' instead of the local branch
47 is that most likely the local branch is not a public
48 branch. And the branch must be available to the pqm.
49
50 This can be configured at the branch level using ~/.bazaar/locations.conf.
51 Here is an example:
52 [/home/emurphy/repo]
53 pqm_email = PQM <pqm@example.com>
54 pqm_user_email = User Name <user@example.com>
55 submit_branch = http://code.example.com/code/project/devel
56 # Set public_branch appropriately for all branches in repository:
57 public_branch = http://code.example.com/code/emurphy/project
58 public_branch:policy = appendpath
59 [/home/emurphy/repo/branch]
60 # Override public_branch for this repository:
61 public_branch = http://alternate.host.example.com/other/public/branch
62
63 smtp_server = host:port
64 smtp_username =
65 smtp_password =
66
67 If you don't specify the smtp server, the message will be sent via localhost.
68 """
69
70 takes_args = ['location?']
71 takes_options = [
72 Option('message',
73 help='Message to use on merge to pqm. '
74 'Currently must be a single line because of pqm limits.',
75 short_name='m',
76 type=unicode),
77 Option('dry-run', help='Print request instead of sending.'),
78 Option('public-location', type=str,
79 help='Use this url as the public location to the pqm.'),
80 Option('submit-branch', type=str,
81 help='Use this url as the target submission branch.'),
82 Option('ignore-local', help='Do not check the local branch or tree.'),
83 ]
84
85 def run(self, location=None, message=None, public_location=None,
86 dry_run=False, submit_branch=None, ignore_local=False):
87 from bzrlib import trace, bzrdir
88 if __name__ != 'bzrlib.plugins.pqm':
89 trace.warning('The bzr-pqm plugin needs to be called'
90 ' "bzrlib.plugins.pqm" not "%s"\n'
91 'Please rename the plugin.',
92 __name__)
93 return 1
94 from bzrlib.plugins.pqm.pqm_submit import submit
95
96 if ignore_local:
97 tree, b, relpath = None, None, None
98 else:
99 if location is None:
100 location = '.'
101 tree, b, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
102 location)
103 if b is not None:
104 b.lock_read()
105 self.add_cleanup(b.unlock)
106 if relpath and not tree and location != '.':
107 raise BzrCommandError(
108 'No working tree was found, but we were not given the '
109 'exact path to the branch.\n'
110 'We found a branch at: %s' % (b.base,))
111 if message is None:
112 raise BzrCommandError(
113 'You must supply a commit message for the pqm to use.')
114 submit(b, message=message, dry_run=dry_run,
115 public_location=public_location,
116 submit_location=submit_branch,
117 tree=tree, ignore_local=ignore_local)
118
119class cmd_lp_land(Command):
120 """Land the merge proposal for this branch via PQM.
121
122 The branch will be submitted to PQM according to the merge proposal. If
123 there is more than one one outstanding proposal for the branch, its
124 location must be specified.
125 """
126
127 takes_args = ['location?']
128
129 takes_options = [
130 Option('dry-run', help='Display the PQM message instead of sending.'),
131 Option(
132 'testfix',
133 help="This is a testfix (tags commit with [testfix])."),
134 Option(
135 'no-qa',
136 help="Does not require QA (tags commit with [no-qa])."),
137 Option(
138 'incremental',
139 help="Incremental to other bug fix (tags commit with [incr])."),
140 Option(
141 'rollback', type=int,
142 help=(
143 "Rollback given revision number. (tags commit with "
144 "[rollback=revno]).")),
145 ]
146
147 def run(self, location=None, dry_run=False, testfix=False,
148 no_qa=False, incremental=False, rollback=None):
149 from bzrlib.plugins.pqm.lpland import Submitter
150 from bzrlib import branch as _mod_branch
151 from bzrlib.plugins.pqm.lpland import (
152 MissingReviewError, MissingBugsError, MissingBugsIncrementalError)
153
154 branch = _mod_branch.Branch.open_containing('.')[0]
155 if dry_run:
156 outf = self.outf
157 else:
158 outf = None
159 if rollback and (no_qa or incremental):
160 print "--rollback option used. Ignoring --no-qa and --incremental."
161 try:
162 submitter = Submitter(branch, location, testfix, no_qa,
163 incremental, rollback=rollback).run(outf)
164 except MissingReviewError:
165 raise BzrCommandError(
166 "Cannot land branches that haven't got approved code "
167 "reviews. Get an 'Approved' vote so we can fill in the "
168 "[r=REVIEWER] section.")
169 except MissingBugsError:
170 raise BzrCommandError(
171 "Branch doesn't have linked bugs and doesn't have no-qa "
172 "option set. Use --no-qa, or link the related bugs to the "
173 "branch.")
174 except MissingBugsIncrementalError:
175 raise BzrCommandError(
176 "--incremental option requires bugs linked to the branch. "
177 "Link the bugs or remove the --incremental option.")
178
179
180register_command(cmd_pqm_submit)
181register_command(cmd_lp_land)
18233
18334
184def test_suite():35def test_suite():
18536
=== added file 'cmds.py'
--- cmds.py 1970-01-01 00:00:00 +0000
+++ cmds.py 2011-12-16 16:01:58 +0000
@@ -0,0 +1,165 @@
1# Copyright (C) 2006-2010 by Canonical Ltd
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 along
14# with this program; if not, write to the Free Software Foundation, Inc.,
15# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16"""Functionality for controlling a Patch Queue Manager (pqm).
17"""
18
19from bzrlib.commands import Command
20from bzrlib.option import Option
21from bzrlib.errors import BzrCommandError
22
23
24class cmd_pqm_submit(Command):
25 """Submit the parent tree to the pqm.
26
27 This acts like:
28 $ echo "star-merge $PARENT $TARGET"
29 | gpg --cl
30 | mail pqm@somewhere -s "merge text"
31
32 But it pays attention to who the local committer is
33 (using their e-mail address), and uses the local
34 gpg signing configuration. (As well as target pqm
35 settings, etc.)
36
37 The reason we use 'parent' instead of the local branch
38 is that most likely the local branch is not a public
39 branch. And the branch must be available to the pqm.
40
41 This can be configured at the branch level using ~/.bazaar/locations.conf.
42 Here is an example:
43 [/home/emurphy/repo]
44 pqm_email = PQM <pqm@example.com>
45 pqm_user_email = User Name <user@example.com>
46 submit_branch = http://code.example.com/code/project/devel
47 # Set public_branch appropriately for all branches in repository:
48 public_branch = http://code.example.com/code/emurphy/project
49 public_branch:policy = appendpath
50 [/home/emurphy/repo/branch]
51 # Override public_branch for this repository:
52 public_branch = http://alternate.host.example.com/other/public/branch
53
54 smtp_server = host:port
55 smtp_username =
56 smtp_password =
57
58 If you don't specify the smtp server, the message will be sent via localhost.
59 """
60
61 takes_args = ['location?']
62 takes_options = [
63 Option('message',
64 help='Message to use on merge to pqm. '
65 'Currently must be a single line because of pqm limits.',
66 short_name='m',
67 type=unicode),
68 Option('dry-run', help='Print request instead of sending.'),
69 Option('public-location', type=str,
70 help='Use this url as the public location to the pqm.'),
71 Option('submit-branch', type=str,
72 help='Use this url as the target submission branch.'),
73 Option('ignore-local', help='Do not check the local branch or tree.'),
74 ]
75
76 def run(self, location=None, message=None, public_location=None,
77 dry_run=False, submit_branch=None, ignore_local=False):
78 from bzrlib import bzrdir
79 from bzrlib.plugins.pqm.pqm_submit import submit
80
81 if ignore_local:
82 tree, b, relpath = None, None, None
83 else:
84 if location is None:
85 location = '.'
86 tree, b, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
87 location)
88 if b is not None:
89 b.lock_read()
90 self.add_cleanup(b.unlock)
91 if relpath and not tree and location != '.':
92 raise BzrCommandError(
93 'No working tree was found, but we were not given the '
94 'exact path to the branch.\n'
95 'We found a branch at: %s' % (b.base,))
96 if message is None:
97 raise BzrCommandError(
98 'You must supply a commit message for the pqm to use.')
99 submit(b, message=message, dry_run=dry_run,
100 public_location=public_location,
101 submit_location=submit_branch,
102 tree=tree, ignore_local=ignore_local)
103
104class cmd_lp_land(Command):
105 """Land the merge proposal for this branch via PQM.
106
107 The branch will be submitted to PQM according to the merge proposal. If
108 there is more than one one outstanding proposal for the branch, its
109 location must be specified.
110 """
111
112 takes_args = ['location?']
113
114 takes_options = [
115 Option('dry-run', help='Display the PQM message instead of sending.'),
116 Option(
117 'testfix',
118 help="This is a testfix (tags commit with [testfix])."),
119 Option(
120 'no-qa',
121 help="Does not require QA (tags commit with [no-qa])."),
122 Option(
123 'incremental',
124 help="Incremental to other bug fix (tags commit with [incr])."),
125 Option(
126 'rollback', type=int,
127 help=(
128 "Rollback given revision number. (tags commit with "
129 "[rollback=revno]).")),
130 ]
131
132 def run(self, location=None, dry_run=False, testfix=False,
133 no_qa=False, incremental=False, rollback=None):
134 from bzrlib.plugins.pqm.lpland import Submitter
135 from bzrlib import branch as _mod_branch
136 from bzrlib.plugins.pqm.lpland import (
137 MissingReviewError, MissingBugsError, MissingBugsIncrementalError)
138
139 branch = _mod_branch.Branch.open_containing('.')[0]
140 if dry_run:
141 outf = self.outf
142 else:
143 outf = None
144 if rollback and (no_qa or incremental):
145 print "--rollback option used. Ignoring --no-qa and --incremental."
146 try:
147 submitter = Submitter(branch, location, testfix, no_qa,
148 incremental, rollback=rollback).run(outf)
149 except MissingReviewError:
150 raise BzrCommandError(
151 "Cannot land branches that haven't got approved code "
152 "reviews. Get an 'Approved' vote so we can fill in the "
153 "[r=REVIEWER] section.")
154 except MissingBugsError:
155 raise BzrCommandError(
156 "Branch doesn't have linked bugs and doesn't have no-qa "
157 "option set. Use --no-qa, or link the related bugs to the "
158 "branch.")
159 except MissingBugsIncrementalError:
160 raise BzrCommandError(
161 "--incremental option requires bugs linked to the branch. "
162 "Link the bugs or remove the --incremental option.")
163
164
165

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: