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
1=== modified file 'tarmac/bin/commands.py'
2--- tarmac/bin/commands.py 2013-02-01 17:24:20 +0000
3+++ tarmac/bin/commands.py 2013-02-01 17:24:20 +0000
4@@ -142,7 +142,8 @@
5 takes_options = [
6 options.http_debug_option,
7 options.debug_option,
8- options.imply_commit_message_option]
9+ options.imply_commit_message_option,
10+ options.one_option]
11
12 def _do_merges(self, branch_url):
13
14@@ -168,13 +169,10 @@
15 success_count = 0
16 try:
17 for proposal in proposals:
18-
19+ target.cleanup()
20 self.logger.debug(
21 u'Preparing to merge %(source_branch)s' % {
22 'source_branch': proposal.source_branch.web_link})
23- source = Branch.create(
24- proposal.source_branch, self.config, target=target)
25-
26 try:
27 prerequisite = proposal.prerequisite_branch
28 if prerequisite:
29@@ -208,9 +206,14 @@
30 raise TarmacMergeError(
31 u'No approved revision specified.')
32
33+
34+ source = Branch.create(
35+ proposal.source_branch, self.config, target=target)
36+
37 approved = source.bzr_branch.revision_id_to_revno(
38 str(proposal.reviewed_revid))
39 tip = source.bzr_branch.revno()
40+
41 if tip > approved:
42 message = u'Unapproved changes made after approval'
43 lp_comment = (
44@@ -253,7 +256,11 @@
45 except AttributeError:
46 proposal.setStatus(status=u'Needs review')
47 proposal.lp_save()
48- target.cleanup()
49+
50+ # If we've been asked to only merge one branch, then exit.
51+ if self.config.one:
52+ return True
53+
54 continue
55 except PointlessMerge:
56 self.logger.warn(
57@@ -261,7 +268,6 @@
58 'pointless.' % {
59 'source': proposal.source_branch.web_link,
60 'target': proposal.target_branch.web_link})
61- target.cleanup()
62 continue
63
64 merge_url = get_review_url(proposal)
65@@ -280,6 +286,8 @@
66 self, target, source, proposal)
67 success_count += 1
68 target.cleanup()
69+ if self.config.one:
70+ return True
71
72 # This except is here because we need the else and can't have it
73 # without an except as well.
74@@ -361,7 +369,11 @@
75 'Merging approved branches against %(branch)s' % {
76 'branch': branch})
77 try:
78- self._do_merges(branch)
79+ merged = self._do_merges(branch)
80+
81+ # If we've been asked to only merge one branch, then exit.
82+ if merged and self.config.one:
83+ break
84 except Exception, error:
85 self.logger.error(
86 'An error occurred trying to merge %s: %s',
87
88=== modified file 'tarmac/bin/options.py'
89--- tarmac/bin/options.py 2011-01-06 20:20:19 +0000
90+++ tarmac/bin/options.py 2013-02-01 17:24:20 +0000
91@@ -15,3 +15,6 @@
92 'imply-commit-message',
93 help=("Use the description as a commit message if the branch "
94 "doesn't have a message"))
95+one_option = Option(
96+ 'one', short_name='1',
97+ help='Merge only one branch and exit.')

Subscribers

People subscribed via source and target branches