Merge lp:~matsubara/bzr-pqm/NewMergeWorkflow into lp:bzr-pqm

Proposed by Diogo Matsubara
Status: Merged
Merged at revision: 73
Proposed branch: lp:~matsubara/bzr-pqm/NewMergeWorkflow
Merge into: lp:bzr-pqm
Diff against target: 199 lines (+72/-20)
3 files modified
__init__.py (+11/-9)
lpland.py (+20/-11)
tests/test_lpland.py (+41/-0)
To merge this branch: bzr merge lp:~matsubara/bzr-pqm/NewMergeWorkflow
Reviewer Review Type Date Requested Status
Ursula Junque (community) qa-logic Approve
Bzr-pqm-devel Pending
Review via email: mp+34968@code.launchpad.net

Commit message

Implements additional options to the lpland command: removes the restriction to use the --no-qa and --incremental option together and implements the --rollback option.

Description of the change

This branch implements additional options to the lpland command. More specifically it implements use cases 3 and 6 of https://dev.launchpad.net/QAProcessContinuousRollouts. It removes the restriction to use the --no-qa and --incremental option together and implements the --rollback option.

To post a comment you must log in.
Revision history for this message
Ursula Junque (ursinha) wrote :

Hi Diogo, the logic here seems correct. I'm approving it from the merge workflow perspective.

Cheers!

Revision history for this message
Ursula Junque (ursinha) :
review: Approve (qa-logic)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '__init__.py'
--- __init__.py 2010-08-06 16:52:30 +0000
+++ __init__.py 2010-09-09 12:34:39 +0000
@@ -137,28 +137,30 @@
137 Option(137 Option(
138 'incremental',138 'incremental',
139 help="Incremental to other bug fix (tags commit with [incr])."),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]).")),
140 ]145 ]
141146
142 def run(self, location=None, dry_run=False, testfix=False, 147 def run(self, location=None, dry_run=False, testfix=False,
143 no_qa=False, incremental=False):148 no_qa=False, incremental=False, rollback=None):
144 from bzrlib.plugins.pqm.lpland import Submitter149 from bzrlib.plugins.pqm.lpland import Submitter
145 from bzrlib import branch as _mod_branch150 from bzrlib import branch as _mod_branch
146 from bzrlib.plugins.pqm.lpland import (151 from bzrlib.plugins.pqm.lpland import (
147 MissingReviewError, MissingBugsError, MissingBugsIncrementalError)152 MissingReviewError, MissingBugsError, MissingBugsIncrementalError)
148153
149
150 if no_qa and incremental:
151 raise BzrCommandError(
152 "--no-qa and --incremental cannot be given at the same time.")
153
154 branch = _mod_branch.Branch.open_containing('.')[0]154 branch = _mod_branch.Branch.open_containing('.')[0]
155 if dry_run:155 if dry_run:
156 outf = self.outf156 outf = self.outf
157 else:157 else:
158 outf = None158 outf = None
159 if rollback and (no_qa or incremental):
160 print "--rollback option used. Ignoring --no-qa and --incremental."
159 try:161 try:
160 submitter = Submitter(branch, location, testfix, no_qa, incremental162 submitter = Submitter(branch, location, testfix, no_qa,
161 ).run(outf)163 incremental, rollback=rollback).run(outf)
162 except MissingReviewError:164 except MissingReviewError:
163 raise BzrCommandError(165 raise BzrCommandError(
164 "Cannot land branches that haven't got approved code "166 "Cannot land branches that haven't got approved code "
165167
=== modified file 'lpland.py'
--- lpland.py 2010-08-13 11:46:04 +0000
+++ lpland.py 2010-09-09 12:34:39 +0000
@@ -180,7 +180,7 @@
180 return branch.composePublicURL(scheme="bzr+ssh")180 return branch.composePublicURL(scheme="bzr+ssh")
181181
182 def get_commit_message(self, commit_text, testfix=False, no_qa=False,182 def get_commit_message(self, commit_text, testfix=False, no_qa=False,
183 incremental=False):183 incremental=False, rollback=None):
184 """Get the Launchpad-style commit message for a merge proposal."""184 """Get the Launchpad-style commit message for a merge proposal."""
185 reviews = self.get_reviews()185 reviews = self.get_reviews()
186 bugs = self.get_bugs()186 bugs = self.get_bugs()
@@ -190,7 +190,7 @@
190 get_reviewer_clause(reviews),190 get_reviewer_clause(reviews),
191 get_bugs_clause(bugs),191 get_bugs_clause(bugs),
192 get_qa_clause(bugs, no_qa,192 get_qa_clause(bugs, no_qa,
193 incremental),193 incremental, rollback=rollback),
194 ])194 ])
195195
196 return '%s %s' % (tags, commit_text)196 return '%s %s' % (tags, commit_text)
@@ -199,11 +199,12 @@
199class Submitter(object):199class Submitter(object):
200200
201 def __init__(self, branch, location, testfix=False, no_qa=False,201 def __init__(self, branch, location, testfix=False, no_qa=False,
202 incremental=False):202 incremental=False, rollback=None):
203 self.branch = branch203 self.branch = branch
204 self.testfix = testfix204 self.testfix = testfix
205 self.no_qa = no_qa205 self.no_qa = no_qa
206 self.incremental = incremental206 self.incremental = incremental
207 self.rollback = rollback
207 self.config = self.branch.get_config()208 self.config = self.branch.get_config()
208 self.mail_to = self.config.get_user_option('pqm_email')209 self.mail_to = self.config.get_user_option('pqm_email')
209 if not self.mail_to:210 if not self.mail_to:
@@ -225,11 +226,12 @@
225 submission.check_public_branch()226 submission.check_public_branch()
226227
227 @staticmethod228 @staticmethod
228 def set_message(submission, mp, testfix, no_qa, incremental):229 def set_message(submission, mp, testfix, no_qa, incremental,
230 rollback=None):
229 pqm_command = ''.join(submission.to_lines())231 pqm_command = ''.join(submission.to_lines())
230 commit_message = mp.commit_message or ''232 commit_message = mp.commit_message or ''
231 start_message = mp.get_commit_message(commit_message, testfix, no_qa,233 start_message = mp.get_commit_message(commit_message, testfix, no_qa,
232 incremental)234 incremental, rollback=rollback)
233 message = msgeditor.edit_commit_message(235 message = msgeditor.edit_commit_message(
234 'pqm command:\n%s' % pqm_command,236 'pqm command:\n%s' % pqm_command,
235 start_message=start_message).rstrip('\n')237 start_message=start_message).rstrip('\n')
@@ -243,7 +245,7 @@
243 submission = self.submission(mp)245 submission = self.submission(mp)
244 self.check_submission(submission)246 self.check_submission(submission)
245 self.set_message(submission, mp, self.testfix, self.no_qa,247 self.set_message(submission, mp, self.testfix, self.no_qa,
246 self.incremental)248 self.incremental, rollback=self.rollback)
247 email = submission.to_email(self.mail_from, self.mail_to)249 email = submission.to_email(self.mail_from, self.mail_to)
248 if outf is not None:250 if outf is not None:
249 outf.write(email.as_string())251 outf.write(email.as_string())
@@ -281,24 +283,31 @@
281 return testfix_clause283 return testfix_clause
282284
283285
284def get_qa_clause(bugs, no_qa=False, incremental=False):286def get_qa_clause(bugs, no_qa=False, incremental=False, rollback=None):
285 """Check the no-qa and incremental options, getting the qa clause.287 """Check the no-qa and incremental options, getting the qa clause.
286288
287 The qa clause will always be or no-qa, or incremental or no tags, never289 The qa clause will always be or no-qa, or incremental, or no-qa and
288 both at the same time.290 incremental, or a revno for the rollback clause, or no tags.
291
292 See https://dev.launchpad.net/QAProcessContinuousRollouts for detailed
293 explanation of each clause.
289 """294 """
290 qa_clause = ""295 qa_clause = ""
291296
292 if not bugs and not no_qa and not incremental:297 if not bugs and not no_qa and not incremental and not rollback:
293 raise MissingBugsError298 raise MissingBugsError
294299
295 if incremental and not bugs:300 if incremental and not bugs:
296 raise MissingBugsIncrementalError301 raise MissingBugsIncrementalError
297302
298 if incremental:303 if no_qa and incremental:
304 qa_clause = '[no-qa][incr]'
305 elif incremental:
299 qa_clause = '[incr]'306 qa_clause = '[incr]'
300 elif no_qa:307 elif no_qa:
301 qa_clause = '[no-qa]'308 qa_clause = '[no-qa]'
309 elif rollback:
310 qa_clause = '[rollback=%d]' % rollback
302 else:311 else:
303 qa_clause = ''312 qa_clause = ''
304313
305314
=== modified file 'tests/test_lpland.py'
--- tests/test_lpland.py 2010-08-13 11:46:04 +0000
+++ tests/test_lpland.py 2010-09-09 12:34:39 +0000
@@ -141,6 +141,25 @@
141 self.assertRaises(MissingBugsIncrementalError,141 self.assertRaises(MissingBugsIncrementalError,
142 get_qa_clause, bugs, no_qa, incr)142 get_qa_clause, bugs, no_qa, incr)
143143
144 def test_bugs_incr_and_noqa_option_given(self):
145 bug1 = FakeBug(20)
146 no_qa = True
147 incr = True
148 self.assertEqual('[no-qa][incr]',
149 get_qa_clause([bug1], no_qa, incr))
150
151 def test_rollback_given(self):
152 bugs = None
153 self.assertEqual('[rollback=123]',
154 get_qa_clause(bugs, rollback=123))
155
156 def test_rollback_and_noqa_and_incr_given(self):
157 bugs = None
158 no_qa = True
159 incr = True
160 self.assertEqual('[rollback=123]',
161 get_qa_clause(bugs, rollback=123))
162
144163
145class TestGetReviewerHandle(unittest.TestCase):164class TestGetReviewerHandle(unittest.TestCase):
146 """Tests for `get_reviewer_handle`."""165 """Tests for `get_reviewer_handle`."""
@@ -252,6 +271,28 @@
252 self.mp.get_commit_message("Foobaring the sbrubble.",271 self.mp.get_commit_message("Foobaring the sbrubble.",
253 testfix, no_qa, incr))272 testfix, no_qa, incr))
254273
274 def test_commit_with_noqa_and_incr(self):
275 incr = True
276 no_qa = True
277 testfix = False
278
279 self.mp.get_bugs = FakeMethod([self.fake_bug])
280 self.mp.get_reviews = FakeMethod({None : [self.fake_person]})
281
282 self.assertEqual(
283 "[r=foo][ui=none][bug=20][no-qa][incr] Foobaring the sbrubble.",
284 self.mp.get_commit_message("Foobaring the sbrubble.",
285 testfix, no_qa, incr))
286
287 def test_commit_with_rollback(self):
288 self.mp.get_bugs = FakeMethod([self.fake_bug])
289 self.mp.get_reviews = FakeMethod({None : [self.fake_person]})
290
291 self.assertEqual(
292 "[r=foo][ui=none][bug=20][rollback=123] Foobaring the sbrubble.",
293 self.mp.get_commit_message("Foobaring the sbrubble.",
294 rollback=123))
295
255296
256class TestGetReviewerClause(unittest.TestCase):297class TestGetReviewerClause(unittest.TestCase):
257 """Tests for `get_reviewer_clause`."""298 """Tests for `get_reviewer_clause`."""

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: