Merge lp:~blr/launchpad/recycle-commit-message into lp:launchpad

Proposed by Kit Randel on 2015-06-11
Status: Merged
Approved by: Kit Randel on 2015-06-12
Approved revision: no longer in the source branch.
Merged at revision: 17562
Proposed branch: lp:~blr/launchpad/recycle-commit-message
Merge into: lp:launchpad
Diff against target: 204 lines (+36/-12)
6 files modified
lib/lp/code/browser/branchmergeproposal.py (+3/-1)
lib/lp/code/browser/tests/test_branchmergeproposal.py (+5/-0)
lib/lp/code/interfaces/branchmergeproposal.py (+4/-1)
lib/lp/code/model/branchmergeproposal.py (+5/-2)
lib/lp/code/model/tests/test_branchmergeproposal.py (+7/-0)
lib/lp/testing/factory.py (+12/-8)
To merge this branch: bzr merge lp:~blr/launchpad/recycle-commit-message
Reviewer Review Type Date Requested Status
William Grant code 2015-06-11 Approve on 2015-06-12
Review via email: mp+261793@code.launchpad.net

Commit Message

Preserve commit message on branch merge proposal resubmission.

Description of the Change

Preserve commit message on branch merge proposal resubmission.

Support for commit_message has also been added to the BranchMergeProposal and BranchMergeProposalForGit factories.

To post a comment you must log in.
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/browser/branchmergeproposal.py'
2--- lib/lp/code/browser/branchmergeproposal.py 2015-06-10 10:25:28 +0000
3+++ lib/lp/code/browser/branchmergeproposal.py 2015-06-12 03:51:02 +0000
4@@ -1012,6 +1012,7 @@
5 ]
6 field_names.extend([
7 'description',
8+ 'commit_message',
9 'break_link',
10 ])
11 return field_names
12@@ -1044,7 +1045,8 @@
13 merge_prerequisite = None
14 proposal = self.context.resubmit(
15 self.user, merge_source, merge_target, merge_prerequisite,
16- data['description'], data['break_link'])
17+ data['commit_message'], data['description'],
18+ data['break_link'])
19 except BranchMergeProposalExists as e:
20 message = structured(
21 'Cannot resubmit because <a href="%(url)s">a similar merge'
22
23=== modified file 'lib/lp/code/browser/tests/test_branchmergeproposal.py'
24--- lib/lp/code/browser/tests/test_branchmergeproposal.py 2015-06-05 17:49:22 +0000
25+++ lib/lp/code/browser/tests/test_branchmergeproposal.py 2015-06-12 03:51:02 +0000
26@@ -925,6 +925,7 @@
27 new_proposal = view.resubmit_action.success(self._getFormValues(
28 context.merge_source, context.merge_target,
29 context.merge_prerequisite, {
30+ 'commit_message': None,
31 'description': None,
32 'break_link': False,
33 }))
34@@ -943,6 +944,7 @@
35 view.context.merge_source)
36 new_proposal = view.resubmit_action.success(self._getFormValues(
37 new_source, new_target, new_prerequisite, {
38+ 'commit_message': 'a commit',
39 'description': 'description',
40 'break_link': False,
41 }))
42@@ -964,6 +966,7 @@
43 merge_prerequisite = context.merge_prerequisite
44 return view.resubmit_action.success(cls._getFormValues(
45 context.merge_source, context.merge_target, merge_prerequisite, {
46+ 'commit_message': None,
47 'description': None,
48 'break_link': break_link,
49 }))
50@@ -1108,9 +1111,11 @@
51 """Proposals can be resubmitted using the browser."""
52 bmp = self.factory.makeBranchMergeProposalForGit(registrant=self.user)
53 browser = self.getViewBrowser(bmp, '+resubmit')
54+ browser.getControl('Commit Message').value = 'dribble'
55 browser.getControl('Description').value = 'flibble'
56 browser.getControl('Resubmit').click()
57 with person_logged_in(self.user):
58+ self.assertEqual('dribble', bmp.superseded_by.commit_message)
59 self.assertEqual('flibble', bmp.superseded_by.description)
60
61
62
63=== modified file 'lib/lp/code/interfaces/branchmergeproposal.py'
64--- lib/lp/code/interfaces/branchmergeproposal.py 2015-06-10 10:25:28 +0000
65+++ lib/lp/code/interfaces/branchmergeproposal.py 2015-06-12 03:51:02 +0000
66@@ -581,7 +581,8 @@
67 """
68
69 def resubmit(registrant, merge_source=None, merge_target=None,
70- merge_prerequisite=DEFAULT):
71+ merge_prerequisite=DEFAULT, commit_message=None,
72+ description=None):
73 """Mark the branch merge proposal as superseded and return a new one.
74
75 The new proposal is created as work-in-progress, and copies across
76@@ -596,6 +597,8 @@
77 to the current merge_target).
78 :param merge_prerequisite: The merge_prerequisite for the new
79 proposal (defaults to the current merge_prerequisite).
80+ :param commit_message: The commit message for the new proposal (defaults
81+ to the current commit message).
82 :param description: The description for the new proposal (defaults to
83 the current description).
84 """
85
86=== modified file 'lib/lp/code/model/branchmergeproposal.py'
87--- lib/lp/code/model/branchmergeproposal.py 2015-06-10 10:25:28 +0000
88+++ lib/lp/code/model/branchmergeproposal.py 2015-06-12 03:51:02 +0000
89@@ -634,8 +634,8 @@
90 self.date_merged = date_merged
91
92 def resubmit(self, registrant, merge_source=None, merge_target=None,
93- merge_prerequisite=DEFAULT, description=None,
94- break_link=False):
95+ merge_prerequisite=DEFAULT, commit_message=None,
96+ description=None, break_link=False):
97 """See `IBranchMergeProposal`."""
98 if merge_source is None:
99 merge_source = self.merge_source
100@@ -649,6 +649,8 @@
101 raise BranchMergeProposalExists(proposal)
102 if merge_prerequisite is DEFAULT:
103 merge_prerequisite = self.merge_prerequisite
104+ if commit_message is None:
105+ commit_message = self.commit_message
106 if description is None:
107 description = self.description
108 # You can transition from REJECTED to SUPERSEDED, but
109@@ -665,6 +667,7 @@
110 registrant=registrant,
111 merge_target=merge_target,
112 merge_prerequisite=merge_prerequisite,
113+ commit_message=commit_message,
114 description=description,
115 needs_review=True, review_requests=review_requests)
116 if not break_link:
117
118=== modified file 'lib/lp/code/model/tests/test_branchmergeproposal.py'
119--- lib/lp/code/model/tests/test_branchmergeproposal.py 2015-05-26 07:39:49 +0000
120+++ lib/lp/code/model/tests/test_branchmergeproposal.py 2015-06-12 03:51:02 +0000
121@@ -1689,6 +1689,13 @@
122 revised = original.resubmit(original.registrant, description='foo')
123 self.assertEqual('foo', revised.description)
124
125+ def test_resubmit_preserves_commit(self):
126+ """Resubmit preserves commit message."""
127+ original = self.factory.makeBranchMergeProposal()
128+ self.useContext(person_logged_in(original.registrant))
129+ revised = original.resubmit(original.registrant)
130+ self.assertEqual(original.commit_message, revised.commit_message)
131+
132 def test_resubmit_breaks_link(self):
133 """Resubmit breaks link, if specified."""
134 original = self.factory.makeBranchMergeProposal()
135
136=== modified file 'lib/lp/testing/factory.py'
137--- lib/lp/testing/factory.py 2015-06-11 08:06:28 +0000
138+++ lib/lp/testing/factory.py 2015-06-12 03:51:02 +0000
139@@ -1435,8 +1435,8 @@
140 set_state=None, prerequisite_branch=None,
141 product=None, initial_comment=None,
142 source_branch=None, date_created=None,
143- description=None, reviewer=None,
144- merged_revno=None):
145+ commit_message=None, description=None,
146+ reviewer=None, merged_revno=None):
147 """Create a proposal to merge based on anonymous branches."""
148 if target_branch is not None:
149 target_branch = removeSecurityProxy(target_branch)
150@@ -1452,9 +1452,11 @@
151 target_branch = self.makeProductBranch(product)
152 target = target_branch.target
153
154- # Fall back to initial_comment for description.
155+ # Fall back to initial_comment for description and commit_message.
156 if description is None:
157 description = initial_comment
158+ if commit_message is None:
159+ commit_message = initial_comment
160
161 if target_branch is None:
162 target_branch = self.makeBranchTargetBranch(target)
163@@ -1468,7 +1470,7 @@
164 proposal = source_branch.addLandingTarget(
165 registrant, target_branch, review_requests=review_requests,
166 merge_prerequisite=prerequisite_branch, description=description,
167- date_created=date_created)
168+ commit_message=commit_message, date_created=date_created)
169
170 unsafe_proposal = removeSecurityProxy(proposal)
171 unsafe_proposal.merged_revno = merged_revno
172@@ -1497,8 +1499,8 @@
173 set_state=None, prerequisite_ref=None,
174 target=_DEFAULT, initial_comment=None,
175 source_ref=None, date_created=None,
176- description=None, reviewer=None,
177- merged_revision_id=None):
178+ commit_message=None, description=None,
179+ reviewer=None, merged_revision_id=None):
180 """Create a proposal to merge based on anonymous branches."""
181 if target is not _DEFAULT:
182 pass
183@@ -1514,9 +1516,11 @@
184 [target_ref] = self.makeGitRefs(target=target)
185 target = target_ref.target
186
187- # Fall back to initial_comment for description.
188+ # Fall back to initial_comment for description and commit_message.
189 if description is None:
190 description = initial_comment
191+ if commit_message is None:
192+ commit_message = initial_comment
193
194 if target_ref is None:
195 [target_ref] = self.makeGitRefs(target=target)
196@@ -1530,7 +1534,7 @@
197 proposal = source_ref.addLandingTarget(
198 registrant, target_ref, review_requests=review_requests,
199 merge_prerequisite=prerequisite_ref, description=description,
200- date_created=date_created)
201+ commit_message=commit_message, date_created=date_created)
202
203 unsafe_proposal = removeSecurityProxy(proposal)
204 unsafe_proposal.merged_revision_id = merged_revision_id