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
1=== modified file '__init__.py'
2--- __init__.py 2010-08-06 16:52:30 +0000
3+++ __init__.py 2010-09-09 12:34:39 +0000
4@@ -137,28 +137,30 @@
5 Option(
6 'incremental',
7 help="Incremental to other bug fix (tags commit with [incr])."),
8+ Option(
9+ 'rollback', type=int,
10+ help=(
11+ "Rollback given revision number. (tags commit with "
12+ "[rollback=revno]).")),
13 ]
14
15- def run(self, location=None, dry_run=False, testfix=False,
16- no_qa=False, incremental=False):
17+ def run(self, location=None, dry_run=False, testfix=False,
18+ no_qa=False, incremental=False, rollback=None):
19 from bzrlib.plugins.pqm.lpland import Submitter
20 from bzrlib import branch as _mod_branch
21 from bzrlib.plugins.pqm.lpland import (
22 MissingReviewError, MissingBugsError, MissingBugsIncrementalError)
23
24-
25- if no_qa and incremental:
26- raise BzrCommandError(
27- "--no-qa and --incremental cannot be given at the same time.")
28-
29 branch = _mod_branch.Branch.open_containing('.')[0]
30 if dry_run:
31 outf = self.outf
32 else:
33 outf = None
34+ if rollback and (no_qa or incremental):
35+ print "--rollback option used. Ignoring --no-qa and --incremental."
36 try:
37- submitter = Submitter(branch, location, testfix, no_qa, incremental
38- ).run(outf)
39+ submitter = Submitter(branch, location, testfix, no_qa,
40+ incremental, rollback=rollback).run(outf)
41 except MissingReviewError:
42 raise BzrCommandError(
43 "Cannot land branches that haven't got approved code "
44
45=== modified file 'lpland.py'
46--- lpland.py 2010-08-13 11:46:04 +0000
47+++ lpland.py 2010-09-09 12:34:39 +0000
48@@ -180,7 +180,7 @@
49 return branch.composePublicURL(scheme="bzr+ssh")
50
51 def get_commit_message(self, commit_text, testfix=False, no_qa=False,
52- incremental=False):
53+ incremental=False, rollback=None):
54 """Get the Launchpad-style commit message for a merge proposal."""
55 reviews = self.get_reviews()
56 bugs = self.get_bugs()
57@@ -190,7 +190,7 @@
58 get_reviewer_clause(reviews),
59 get_bugs_clause(bugs),
60 get_qa_clause(bugs, no_qa,
61- incremental),
62+ incremental, rollback=rollback),
63 ])
64
65 return '%s %s' % (tags, commit_text)
66@@ -199,11 +199,12 @@
67 class Submitter(object):
68
69 def __init__(self, branch, location, testfix=False, no_qa=False,
70- incremental=False):
71+ incremental=False, rollback=None):
72 self.branch = branch
73 self.testfix = testfix
74 self.no_qa = no_qa
75 self.incremental = incremental
76+ self.rollback = rollback
77 self.config = self.branch.get_config()
78 self.mail_to = self.config.get_user_option('pqm_email')
79 if not self.mail_to:
80@@ -225,11 +226,12 @@
81 submission.check_public_branch()
82
83 @staticmethod
84- def set_message(submission, mp, testfix, no_qa, incremental):
85+ def set_message(submission, mp, testfix, no_qa, incremental,
86+ rollback=None):
87 pqm_command = ''.join(submission.to_lines())
88 commit_message = mp.commit_message or ''
89 start_message = mp.get_commit_message(commit_message, testfix, no_qa,
90- incremental)
91+ incremental, rollback=rollback)
92 message = msgeditor.edit_commit_message(
93 'pqm command:\n%s' % pqm_command,
94 start_message=start_message).rstrip('\n')
95@@ -243,7 +245,7 @@
96 submission = self.submission(mp)
97 self.check_submission(submission)
98 self.set_message(submission, mp, self.testfix, self.no_qa,
99- self.incremental)
100+ self.incremental, rollback=self.rollback)
101 email = submission.to_email(self.mail_from, self.mail_to)
102 if outf is not None:
103 outf.write(email.as_string())
104@@ -281,24 +283,31 @@
105 return testfix_clause
106
107
108-def get_qa_clause(bugs, no_qa=False, incremental=False):
109+def get_qa_clause(bugs, no_qa=False, incremental=False, rollback=None):
110 """Check the no-qa and incremental options, getting the qa clause.
111
112- The qa clause will always be or no-qa, or incremental or no tags, never
113- both at the same time.
114+ The qa clause will always be or no-qa, or incremental, or no-qa and
115+ incremental, or a revno for the rollback clause, or no tags.
116+
117+ See https://dev.launchpad.net/QAProcessContinuousRollouts for detailed
118+ explanation of each clause.
119 """
120 qa_clause = ""
121
122- if not bugs and not no_qa and not incremental:
123+ if not bugs and not no_qa and not incremental and not rollback:
124 raise MissingBugsError
125
126 if incremental and not bugs:
127 raise MissingBugsIncrementalError
128
129- if incremental:
130+ if no_qa and incremental:
131+ qa_clause = '[no-qa][incr]'
132+ elif incremental:
133 qa_clause = '[incr]'
134 elif no_qa:
135 qa_clause = '[no-qa]'
136+ elif rollback:
137+ qa_clause = '[rollback=%d]' % rollback
138 else:
139 qa_clause = ''
140
141
142=== modified file 'tests/test_lpland.py'
143--- tests/test_lpland.py 2010-08-13 11:46:04 +0000
144+++ tests/test_lpland.py 2010-09-09 12:34:39 +0000
145@@ -141,6 +141,25 @@
146 self.assertRaises(MissingBugsIncrementalError,
147 get_qa_clause, bugs, no_qa, incr)
148
149+ def test_bugs_incr_and_noqa_option_given(self):
150+ bug1 = FakeBug(20)
151+ no_qa = True
152+ incr = True
153+ self.assertEqual('[no-qa][incr]',
154+ get_qa_clause([bug1], no_qa, incr))
155+
156+ def test_rollback_given(self):
157+ bugs = None
158+ self.assertEqual('[rollback=123]',
159+ get_qa_clause(bugs, rollback=123))
160+
161+ def test_rollback_and_noqa_and_incr_given(self):
162+ bugs = None
163+ no_qa = True
164+ incr = True
165+ self.assertEqual('[rollback=123]',
166+ get_qa_clause(bugs, rollback=123))
167+
168
169 class TestGetReviewerHandle(unittest.TestCase):
170 """Tests for `get_reviewer_handle`."""
171@@ -252,6 +271,28 @@
172 self.mp.get_commit_message("Foobaring the sbrubble.",
173 testfix, no_qa, incr))
174
175+ def test_commit_with_noqa_and_incr(self):
176+ incr = True
177+ no_qa = True
178+ testfix = False
179+
180+ self.mp.get_bugs = FakeMethod([self.fake_bug])
181+ self.mp.get_reviews = FakeMethod({None : [self.fake_person]})
182+
183+ self.assertEqual(
184+ "[r=foo][ui=none][bug=20][no-qa][incr] Foobaring the sbrubble.",
185+ self.mp.get_commit_message("Foobaring the sbrubble.",
186+ testfix, no_qa, incr))
187+
188+ def test_commit_with_rollback(self):
189+ self.mp.get_bugs = FakeMethod([self.fake_bug])
190+ self.mp.get_reviews = FakeMethod({None : [self.fake_person]})
191+
192+ self.assertEqual(
193+ "[r=foo][ui=none][bug=20][rollback=123] Foobaring the sbrubble.",
194+ self.mp.get_commit_message("Foobaring the sbrubble.",
195+ rollback=123))
196+
197
198 class TestGetReviewerClause(unittest.TestCase):
199 """Tests for `get_reviewer_clause`."""

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: