Merge lp:~james-w/tarmac/one-at-a-time into lp:tarmac

Proposed by James Westby
Status: Merged
Approved by: Paul Hummer
Approved revision: 403
Merged at revision: 404
Proposed branch: lp:~james-w/tarmac/one-at-a-time
Merge into: lp:tarmac
Prerequisite: lp:~james-w/tarmac/use-web-link
Diff against target: 97 lines (+23/-8)
2 files modified
tarmac/bin/commands.py (+20/-8)
tarmac/bin/options.py (+3/-0)
To merge this branch: bzr merge lp:~james-w/tarmac/one-at-a-time
Reviewer Review Type Date Requested Status
Paul Hummer Approve
Review via email: mp+145965@code.launchpad.net

Commit message

Add the option to only act on a single MP, useful when tarmac is used
with jenkins.

Description of the change

This adds the option to only act on a single MP, useful when tarmac is used
with jenkins.

(from the u1 fork)

To post a comment you must log in.
Revision history for this message
Paul Hummer (rockstar) :
review: Approve
Revision history for this message
Paul Hummer (rockstar) wrote :

The prerequisite lp:~james-w/tarmac/use-web-link has not yet been merged into lp:tarmac.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tarmac/bin/commands.py'
--- tarmac/bin/commands.py 2013-02-01 17:24:20 +0000
+++ tarmac/bin/commands.py 2013-02-01 17:24:20 +0000
@@ -142,7 +142,8 @@
142 takes_options = [142 takes_options = [
143 options.http_debug_option,143 options.http_debug_option,
144 options.debug_option,144 options.debug_option,
145 options.imply_commit_message_option]145 options.imply_commit_message_option,
146 options.one_option]
146147
147 def _do_merges(self, branch_url):148 def _do_merges(self, branch_url):
148149
@@ -168,13 +169,10 @@
168 success_count = 0169 success_count = 0
169 try:170 try:
170 for proposal in proposals:171 for proposal in proposals:
171172 target.cleanup()
172 self.logger.debug(173 self.logger.debug(
173 u'Preparing to merge %(source_branch)s' % {174 u'Preparing to merge %(source_branch)s' % {
174 'source_branch': proposal.source_branch.web_link})175 'source_branch': proposal.source_branch.web_link})
175 source = Branch.create(
176 proposal.source_branch, self.config, target=target)
177
178 try:176 try:
179 prerequisite = proposal.prerequisite_branch177 prerequisite = proposal.prerequisite_branch
180 if prerequisite:178 if prerequisite:
@@ -208,9 +206,14 @@
208 raise TarmacMergeError(206 raise TarmacMergeError(
209 u'No approved revision specified.')207 u'No approved revision specified.')
210208
209
210 source = Branch.create(
211 proposal.source_branch, self.config, target=target)
212
211 approved = source.bzr_branch.revision_id_to_revno(213 approved = source.bzr_branch.revision_id_to_revno(
212 str(proposal.reviewed_revid))214 str(proposal.reviewed_revid))
213 tip = source.bzr_branch.revno()215 tip = source.bzr_branch.revno()
216
214 if tip > approved:217 if tip > approved:
215 message = u'Unapproved changes made after approval'218 message = u'Unapproved changes made after approval'
216 lp_comment = (219 lp_comment = (
@@ -253,7 +256,11 @@
253 except AttributeError:256 except AttributeError:
254 proposal.setStatus(status=u'Needs review')257 proposal.setStatus(status=u'Needs review')
255 proposal.lp_save()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 continue264 continue
258 except PointlessMerge:265 except PointlessMerge:
259 self.logger.warn(266 self.logger.warn(
@@ -261,7 +268,6 @@
261 'pointless.' % {268 'pointless.' % {
262 'source': proposal.source_branch.web_link,269 'source': proposal.source_branch.web_link,
263 'target': proposal.target_branch.web_link})270 'target': proposal.target_branch.web_link})
264 target.cleanup()
265 continue271 continue
266272
267 merge_url = get_review_url(proposal)273 merge_url = get_review_url(proposal)
@@ -280,6 +286,8 @@
280 self, target, source, proposal)286 self, target, source, proposal)
281 success_count += 1287 success_count += 1
282 target.cleanup()288 target.cleanup()
289 if self.config.one:
290 return True
283291
284 # This except is here because we need the else and can't have it292 # This except is here because we need the else and can't have it
285 # without an except as well.293 # without an except as well.
@@ -361,7 +369,11 @@
361 'Merging approved branches against %(branch)s' % {369 'Merging approved branches against %(branch)s' % {
362 'branch': branch})370 'branch': branch})
363 try: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 except Exception, error:377 except Exception, error:
366 self.logger.error(378 self.logger.error(
367 'An error occurred trying to merge %s: %s',379 'An error occurred trying to merge %s: %s',
368380
=== modified file 'tarmac/bin/options.py'
--- tarmac/bin/options.py 2011-01-06 20:20:19 +0000
+++ tarmac/bin/options.py 2013-02-01 17:24:20 +0000
@@ -15,3 +15,6 @@
15 'imply-commit-message',15 'imply-commit-message',
16 help=("Use the description as a commit message if the branch "16 help=("Use the description as a commit message if the branch "
17 "doesn't have a message"))17 "doesn't have a message"))
18one_option = Option(
19 'one', short_name='1',
20 help='Merge only one branch and exit.')

Subscribers

People subscribed via source and target branches