~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/devscripts/autoland.py

  • Committer: Ursula Junque (Ursinha)
  • Date: 2010-07-06 05:07:59 UTC
  • mto: This revision was merged to the branch mainline in revision 11268.
  • Revision ID: ursinha@canonical.com-20100706050759-n70bjldnvicf6xfw
Adding MissingBugsIncrError exception and incr commit tag to the check_qa_clauses method, now changed to check both tags, no-qa and incr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
    bugs."""
18
18
 
19
19
 
 
20
class MissingBugsIncrError(Exception):
 
21
    """Raised when we try to land a mp with the 'incr' tag and no linked
 
22
    bugs."""
 
23
 
 
24
 
20
25
class LaunchpadBranchLander:
21
26
 
22
27
    name = 'launchpad-branch-lander'
157
162
        # URL. Do it ourselves.
158
163
        return URI(scheme='bzr+ssh', host=host, path='/' + branch.unique_name)
159
164
 
160
 
    def get_commit_message(self, commit_text, testfix=False, no_qa=False):
 
165
    def get_commit_message(self, commit_text, testfix=False, no_qa=False,
 
166
            incr=False):
161
167
        """Get the Launchpad-style commit message for a merge proposal."""
162
168
        reviews = self.get_reviews()
163
169
        bugs = self.get_bugs()
164
 
        no_qa = check_qa_clause(no_qa, bugs)
 
170
        no_qa, incr = check_qa_clauses(bugs, no_qa, incr)
165
171
 
166
172
        if testfix:
167
173
            testfix = '[testfix]'
168
174
        else:
169
175
            testfix = ''
170
176
 
171
 
        return '%s%s%s%s %s' % (
 
177
        return '%s%s%s%s%s %s' % (
172
178
            testfix,
173
179
            get_reviewer_clause(reviews),
174
180
            get_bugs_clause(bugs),
175
181
            no_qa,
 
182
            incr,
176
183
            commit_text)
177
184
 
178
185
 
179
 
def check_qa_clause(bugs, no_qa=False):
180
 
    """Check if the commit should be a no-qa or not."""
181
 
    if bugs is None and not no_qa:
 
186
def check_qa_clauses(bugs, no_qa=False, incr=False):
 
187
    """Check the no-qa and incr clauses."""
 
188
 
 
189
    if not bugs and not no_qa and not incr:
182
190
        raise MissingBugsError("Need bugs linked or --no-qa option.")
 
191
 
 
192
    if incr and not bugs:
 
193
        raise MissingBugsIncrError("--incr option requires bugs linked to the "
 
194
            "branch.")
 
195
 
 
196
    if incr:
 
197
        incr = '[incr]'
 
198
    else:
 
199
        incr = ''
183
200
    if no_qa:
184
201
        no_qa = '[no-qa]'
185
202
    else:
186
203
        no_qa = ''
187
 
    return no_qa
 
204
 
 
205
    return no_qa, incr
188
206
 
189
207
 
190
208
def get_email(person):