Merge lp:~dobey/tarmac/list-approved into lp:tarmac

Proposed by dobey
Status: Merged
Approved by: dobey
Approved revision: 428
Merged at revision: 427
Proposed branch: lp:~dobey/tarmac/list-approved
Merge into: lp:tarmac
Diff against target: 93 lines (+48/-1)
3 files modified
tarmac/bin/commands.py (+23/-1)
tarmac/bin/options.py (+18/-0)
tarmac/tests/test_commands.py (+7/-0)
To merge this branch: bzr merge lp:~dobey/tarmac/list-approved
Reviewer Review Type Date Requested Status
Francis Ginther Approve
David Britton Approve
Review via email: mp+206808@code.launchpad.net

Commit message

Add a --list-approved option to the merge command.

Description of the change

With this, running "tarmac merge lp:foo --list-approved" will print out the list of MP URLs for all branches approved for merging into lp:foo. With "tarmac merge --list-approved" omitting the specific branch target, tarmac will print all approved branches for merging into all target branches specified in the tarmac.conf file.

To post a comment you must log in.
Revision history for this message
David Britton (dpb) wrote :

[0] typo on docstring for test:

   *Test* that *--list-approved* option prints..

Looks good! +1

review: Approve
lp:~dobey/tarmac/list-approved updated
428. By dobey

Fix typos.

Revision history for this message
Francis Ginther (fginther) wrote :

This should resolve part 1 of the feature request as documented in the bug.

+1

review: Approve

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-12-05 22:28:15 +0000
3+++ tarmac/bin/commands.py 2014-02-18 23:18:12 +0000
4@@ -1,3 +1,18 @@
5+# Copyright 2009-2012 Paul Hummer
6+# Copyright 2009-2014 Canonical Ltd.
7+#
8+# Tarmac is free software: you can redistribute it and/or modify
9+# it under the terms of the GNU General Public License version 3 as
10+# published by
11+# the Free Software Foundation.
12+#
13+# Tarmac is distributed in the hope that it will be useful,
14+# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+# GNU General Public License for more details.
17+#
18+# You should have received a copy of the GNU General Public License
19+# along with Tarmac. If not, see <http://www.gnu.org/licenses/>.
20 '''Command handling for Tarmac.'''
21 import httplib2
22 import logging
23@@ -158,7 +173,9 @@
24 options.http_debug_option,
25 options.debug_option,
26 options.imply_commit_message_option,
27- options.one_option]
28+ options.one_option,
29+ options.list_approved_option,
30+ ]
31
32 def _handle_merge_error(self, proposal, failure):
33 """Handle TarmacMergeError cases from _do_merges."""
34@@ -200,6 +217,11 @@
35 'branch_url': branch_url})
36 return
37
38+ if self.config.list_approved:
39+ for proposal in proposals:
40+ print(get_review_url(proposal))
41+ return
42+
43 try:
44 target = Branch.create(lp_branch, self.config, create_tree=True,
45 launchpad=self.launchpad)
46
47=== modified file 'tarmac/bin/options.py'
48--- tarmac/bin/options.py 2012-05-26 04:14:45 +0000
49+++ tarmac/bin/options.py 2014-02-18 23:18:12 +0000
50@@ -1,3 +1,18 @@
51+# Copyright 2010-2011 Paul Hummer
52+# Copyright 2010-2014 Canonical Ltd.
53+#
54+# Tarmac is free software: you can redistribute it and/or modify
55+# it under the terms of the GNU General Public License version 3 as
56+# published by
57+# the Free Software Foundation.
58+#
59+# Tarmac is distributed in the hope that it will be useful,
60+# but WITHOUT ANY WARRANTY; without even the implied warranty of
61+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
62+# GNU General Public License for more details.
63+#
64+# You should have received a copy of the GNU General Public License
65+# along with Tarmac. If not, see <http://www.gnu.org/licenses/>.
66 '''Command options.'''
67 from bzrlib.option import Option
68
69@@ -18,3 +33,6 @@
70 one_option = Option(
71 'one', short_name='1',
72 help='Merge only one branch and exit.')
73+list_approved_option = Option(
74+ 'list-approved', short_name='l',
75+ help='List Approved merge proposals for the target branch.')
76
77=== modified file 'tarmac/tests/test_commands.py'
78--- tarmac/tests/test_commands.py 2014-01-09 21:40:25 +0000
79+++ tarmac/tests/test_commands.py 2014-02-18 23:18:12 +0000
80@@ -449,6 +449,13 @@
81 self.assertEqual(self.error.comment,
82 invalid_tree_comment)
83
84+ @patch('tarmac.bin.commands.get_review_url')
85+ def test_run_merge_with_list_approved_option(self, mocked):
86+ """Test that --list-approved option prints a list and returns."""
87+ self.addProposal('list_approved')
88+ self.command.run(launchpad=self.launchpad, list_approved=True)
89+ self.assertEqual(mocked.call_count, 2)
90+
91 def test__compare_proposals(self):
92 """
93 _compare_proposals is meant to be a sort routine comparison function

Subscribers

People subscribed via source and target branches