launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #25740
[Merge] ~twom/launchpad:git-branch-picker-resubmit into launchpad:master
Tom Wardill has proposed merging ~twom/launchpad:git-branch-picker-resubmit into launchpad:master.
Commit message:
Add autocomplete to git resubmit page
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/394481
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
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~twom/launchpad:git-branch-picker-resubmit into launchpad:master.
diff --git a/lib/lp/code/browser/branchmergeproposal.py b/lib/lp/code/browser/branchmergeproposal.py
index a88531b..aecad03 100644
--- a/lib/lp/code/browser/branchmergeproposal.py
+++ b/lib/lp/code/browser/branchmergeproposal.py
@@ -77,6 +77,7 @@ from lp.app.browser.tales import DateTimeFormatterAPI
from lp.code.adapters.branch import BranchMergeProposalNoPreviewDiffDelta
from lp.code.browser.codereviewcomment import CodeReviewDisplayComment
from lp.code.browser.decorations import DecoratedBranch
+from lp.code.browser.widgets.gitref import GitRefWidget
from lp.code.enums import (
BranchMergeProposalStatus,
BranchType,
@@ -1077,6 +1078,13 @@ class BranchMergeProposalResubmitView(LaunchpadFormView,
for_input = True
page_title = label = "Resubmit proposal to merge"
+ custom_widget_source_git_ref = CustomWidgetFactory(
+ GitRefWidget, require_branch=True)
+ custom_widget_target_git_ref = CustomWidgetFactory(
+ GitRefWidget, require_branch=True)
+ custom_widget_prerequisite_git_ref = CustomWidgetFactory(
+ GitRefWidget, require_branch=True)
+
def initialize(self):
self.cancel_url = canonical_url(self.context)
super(BranchMergeProposalResubmitView, self).initialize()
@@ -1091,12 +1099,9 @@ class BranchMergeProposalResubmitView(LaunchpadFormView,
]
else:
field_names = [
- 'source_git_repository',
- 'source_git_path',
- 'target_git_repository',
- 'target_git_path',
- 'prerequisite_git_repository',
- 'prerequisite_git_path',
+ 'source_git_ref',
+ 'target_git_ref',
+ 'prerequisite_git_ref',
]
field_names.extend([
'description',
@@ -1122,16 +1127,9 @@ class BranchMergeProposalResubmitView(LaunchpadFormView,
merge_target = data['target_branch']
merge_prerequisite = data['prerequisite_branch']
else:
- merge_source = data['source_git_repository'].getRefByPath(
- data['source_git_path'])
- merge_target = data['target_git_repository'].getRefByPath(
- data['target_git_path'])
- if data['prerequisite_git_repository']:
- merge_prerequisite = (
- data['prerequisite_git_repository'].getRefByPath(
- data['prerequisite_git_path']))
- else:
- merge_prerequisite = None
+ merge_source = data['source_git_ref']
+ merge_target = data['target_git_ref']
+ merge_prerequisite = data.get('prerequisite_git_ref')
proposal = self.context.resubmit(
self.user, merge_source, merge_target, merge_prerequisite,
data['commit_message'], data['description'],
diff --git a/lib/lp/code/browser/tests/test_branchmergeproposal.py b/lib/lp/code/browser/tests/test_branchmergeproposal.py
index fedb00d..4fa7ed1 100644
--- a/lib/lp/code/browser/tests/test_branchmergeproposal.py
+++ b/lib/lp/code/browser/tests/test_branchmergeproposal.py
@@ -1257,15 +1257,12 @@ class TestBranchMergeProposalResubmitViewGit(
def _getFormValues(source_branch, target_branch, prerequisite_branch,
extras):
values = {
- 'source_git_repository': source_branch.repository,
- 'source_git_path': source_branch.path,
- 'target_git_repository': target_branch.repository,
- 'target_git_path': target_branch.path,
+ 'source_git_ref': source_branch,
+ 'target_git_ref': target_branch
}
if prerequisite_branch is not None:
values.update({
- 'prerequisite_git_repository': prerequisite_branch.repository,
- 'prerequisite_git_path': prerequisite_branch.path,
+ 'prerequisite_git_ref': prerequisite_branch
})
else:
values.update({
diff --git a/lib/lp/code/interfaces/branchmergeproposal.py b/lib/lp/code/interfaces/branchmergeproposal.py
index 820b7b0..7265218 100644
--- a/lib/lp/code/interfaces/branchmergeproposal.py
+++ b/lib/lp/code/interfaces/branchmergeproposal.py
@@ -149,7 +149,7 @@ class IBranchMergeProposalPublic(IPrivacy):
source_git_commit_sha1 = TextLine(
title=_('Source Git commit SHA-1'), required=False, readonly=True)
source_git_ref = Reference(
- title=_('Source Git reference'),
+ title=_('Source Git branch'),
schema=IGitRef, required=False, readonly=True)
target_branch = exported(