Merge ~twom/launchpad:git-branch-picker-resubmit into launchpad:master

Proposed by Tom Wardill
Status: Merged
Approved by: Tom Wardill
Approved revision: 4e4016c105fb6c73f08541bf3e14cfac8b29fb50
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~twom/launchpad:git-branch-picker-resubmit
Merge into: launchpad:master
Diff against target: 98 lines (+18/-23)
3 files modified
lib/lp/code/browser/branchmergeproposal.py (+14/-16)
lib/lp/code/browser/tests/test_branchmergeproposal.py (+3/-6)
lib/lp/code/interfaces/branchmergeproposal.py (+1/-1)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+394481@code.launchpad.net

Commit message

Add autocomplete to git resubmit page

Description of the change

Now we have an autocomplete git picker on the propose MP page, we should use it on the resubmit page too. Slightly complicated by the 'source' being changeable as well as target/prerequisite.

Swap field names to use '_ref' instead of '_repository/_path'.
Add the custom widgets.
Read the data from the correct source.
Fix tests to match new field names

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/code/browser/branchmergeproposal.py b/lib/lp/code/browser/branchmergeproposal.py
2index a88531b..aecad03 100644
3--- a/lib/lp/code/browser/branchmergeproposal.py
4+++ b/lib/lp/code/browser/branchmergeproposal.py
5@@ -77,6 +77,7 @@ from lp.app.browser.tales import DateTimeFormatterAPI
6 from lp.code.adapters.branch import BranchMergeProposalNoPreviewDiffDelta
7 from lp.code.browser.codereviewcomment import CodeReviewDisplayComment
8 from lp.code.browser.decorations import DecoratedBranch
9+from lp.code.browser.widgets.gitref import GitRefWidget
10 from lp.code.enums import (
11 BranchMergeProposalStatus,
12 BranchType,
13@@ -1077,6 +1078,13 @@ class BranchMergeProposalResubmitView(LaunchpadFormView,
14 for_input = True
15 page_title = label = "Resubmit proposal to merge"
16
17+ custom_widget_source_git_ref = CustomWidgetFactory(
18+ GitRefWidget, require_branch=True)
19+ custom_widget_target_git_ref = CustomWidgetFactory(
20+ GitRefWidget, require_branch=True)
21+ custom_widget_prerequisite_git_ref = CustomWidgetFactory(
22+ GitRefWidget, require_branch=True)
23+
24 def initialize(self):
25 self.cancel_url = canonical_url(self.context)
26 super(BranchMergeProposalResubmitView, self).initialize()
27@@ -1091,12 +1099,9 @@ class BranchMergeProposalResubmitView(LaunchpadFormView,
28 ]
29 else:
30 field_names = [
31- 'source_git_repository',
32- 'source_git_path',
33- 'target_git_repository',
34- 'target_git_path',
35- 'prerequisite_git_repository',
36- 'prerequisite_git_path',
37+ 'source_git_ref',
38+ 'target_git_ref',
39+ 'prerequisite_git_ref',
40 ]
41 field_names.extend([
42 'description',
43@@ -1122,16 +1127,9 @@ class BranchMergeProposalResubmitView(LaunchpadFormView,
44 merge_target = data['target_branch']
45 merge_prerequisite = data['prerequisite_branch']
46 else:
47- merge_source = data['source_git_repository'].getRefByPath(
48- data['source_git_path'])
49- merge_target = data['target_git_repository'].getRefByPath(
50- data['target_git_path'])
51- if data['prerequisite_git_repository']:
52- merge_prerequisite = (
53- data['prerequisite_git_repository'].getRefByPath(
54- data['prerequisite_git_path']))
55- else:
56- merge_prerequisite = None
57+ merge_source = data['source_git_ref']
58+ merge_target = data['target_git_ref']
59+ merge_prerequisite = data.get('prerequisite_git_ref')
60 proposal = self.context.resubmit(
61 self.user, merge_source, merge_target, merge_prerequisite,
62 data['commit_message'], data['description'],
63diff --git a/lib/lp/code/browser/tests/test_branchmergeproposal.py b/lib/lp/code/browser/tests/test_branchmergeproposal.py
64index fedb00d..4fa7ed1 100644
65--- a/lib/lp/code/browser/tests/test_branchmergeproposal.py
66+++ b/lib/lp/code/browser/tests/test_branchmergeproposal.py
67@@ -1257,15 +1257,12 @@ class TestBranchMergeProposalResubmitViewGit(
68 def _getFormValues(source_branch, target_branch, prerequisite_branch,
69 extras):
70 values = {
71- 'source_git_repository': source_branch.repository,
72- 'source_git_path': source_branch.path,
73- 'target_git_repository': target_branch.repository,
74- 'target_git_path': target_branch.path,
75+ 'source_git_ref': source_branch,
76+ 'target_git_ref': target_branch
77 }
78 if prerequisite_branch is not None:
79 values.update({
80- 'prerequisite_git_repository': prerequisite_branch.repository,
81- 'prerequisite_git_path': prerequisite_branch.path,
82+ 'prerequisite_git_ref': prerequisite_branch
83 })
84 else:
85 values.update({
86diff --git a/lib/lp/code/interfaces/branchmergeproposal.py b/lib/lp/code/interfaces/branchmergeproposal.py
87index 820b7b0..7265218 100644
88--- a/lib/lp/code/interfaces/branchmergeproposal.py
89+++ b/lib/lp/code/interfaces/branchmergeproposal.py
90@@ -149,7 +149,7 @@ class IBranchMergeProposalPublic(IPrivacy):
91 source_git_commit_sha1 = TextLine(
92 title=_('Source Git commit SHA-1'), required=False, readonly=True)
93 source_git_ref = Reference(
94- title=_('Source Git reference'),
95+ title=_('Source Git branch'),
96 schema=IGitRef, required=False, readonly=True)
97
98 target_branch = exported(

Subscribers

People subscribed via source and target branches

to status/vote changes: