~tarmac-control-tower/tarmac/main

« back to all changes in this revision

Viewing changes to tarmac/bin/commands.py

  • Committer: Tarmac
  • Author(s): Sidnei da Silva, James Westby
  • Date: 2013-02-04 21:05:04 UTC
  • mfrom: (398.3.5 one-at-a-time)
  • Revision ID: tarmac-20130204210504-pia2lnicwrwtluqp
Add the option to only act on a single MP, useful when tarmac is used
with jenkins.

Show diffs side-by-side

added added

removed removed

Lines of Context:
142
142
    takes_options = [
143
143
        options.http_debug_option,
144
144
        options.debug_option,
145
 
        options.imply_commit_message_option]
 
145
        options.imply_commit_message_option,
 
146
        options.one_option]
146
147
 
147
148
    def _do_merges(self, branch_url):
148
149
 
168
169
        success_count = 0
169
170
        try:
170
171
            for proposal in proposals:
171
 
 
 
172
                target.cleanup()
172
173
                self.logger.debug(
173
174
                    u'Preparing to merge %(source_branch)s' % {
174
175
                        'source_branch': proposal.source_branch.web_link})
175
 
                source = Branch.create(
176
 
                    proposal.source_branch, self.config, target=target)
177
 
 
178
176
                try:
179
177
                    prerequisite = proposal.prerequisite_branch
180
178
                    if prerequisite:
208
206
                        raise TarmacMergeError(
209
207
                            u'No approved revision specified.')
210
208
 
 
209
 
 
210
                    source = Branch.create(
 
211
                        proposal.source_branch, self.config, target=target)
 
212
 
211
213
                    approved = source.bzr_branch.revision_id_to_revno(
212
214
                        str(proposal.reviewed_revid))
213
215
                    tip = source.bzr_branch.revno()
 
216
 
214
217
                    if tip > approved:
215
218
                        message = u'Unapproved changes made after approval'
216
219
                        lp_comment = (
253
256
                    except AttributeError:
254
257
                        proposal.setStatus(status=u'Needs review')
255
258
                    proposal.lp_save()
256
 
                    target.cleanup()
 
259
 
 
260
                    # If we've been asked to only merge one branch, then exit.
 
261
                    if self.config.one:
 
262
                        return True
 
263
 
257
264
                    continue
258
265
                except PointlessMerge:
259
266
                    self.logger.warn(
261
268
                        'pointless.' % {
262
269
                            'source': proposal.source_branch.web_link,
263
270
                            'target': proposal.target_branch.web_link})
264
 
                    target.cleanup()
265
271
                    continue
266
272
 
267
273
                merge_url = get_review_url(proposal)
280
286
                                  self, target, source, proposal)
281
287
                success_count += 1
282
288
                target.cleanup()
 
289
                if self.config.one:
 
290
                    return True
283
291
 
284
292
        # This except is here because we need the else and can't have it
285
293
        # without an except as well.
361
369
                    'Merging approved branches against %(branch)s' % {
362
370
                        'branch': branch})
363
371
                try:
364
 
                    self._do_merges(branch)
 
372
                    merged = self._do_merges(branch)
 
373
 
 
374
                    # If we've been asked to only merge one branch, then exit.
 
375
                    if merged and self.config.one:
 
376
                        break
365
377
                except Exception, error:
366
378
                    self.logger.error(
367
379
                        'An error occurred trying to merge %s: %s',