launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #18371
[Merge] lp:~cjwatson/launchpad/git-mp-ref-proposals into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/git-mp-ref-proposals into lp:launchpad with lp:~cjwatson/launchpad/git-mp-collection as a prerequisite.
Commit message:
Add GitRef.getMergeProposals.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1445017 in Launchpad itself: "Support for Launchpad Git merge proposals "
https://bugs.launchpad.net/launchpad/+bug/1445017
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/git-mp-ref-proposals/+merge/257374
Add GitRef.getMergeProposals.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/git-mp-ref-proposals into lp:launchpad.
=== modified file 'lib/lp/_schema_circular_imports.py'
--- lib/lp/_schema_circular_imports.py 2015-04-22 16:11:40 +0000
+++ lib/lp/_schema_circular_imports.py 2015-04-24 13:23:09 +0000
@@ -568,6 +568,8 @@
patch_plain_parameter_type(
IGitRef, 'createMergeProposal', 'merge_prerequisite', IGitRef)
patch_entry_return_type(IGitRef, 'createMergeProposal', IBranchMergeProposal)
+patch_collection_return_type(
+ IGitRef, 'getMergeProposals', IBranchMergeProposal)
# IGitRepository
patch_collection_property(IGitRepository, 'branches', IGitRef)
=== modified file 'lib/lp/code/interfaces/gitref.py'
--- lib/lp/code/interfaces/gitref.py 2015-04-22 16:11:40 +0000
+++ lib/lp/code/interfaces/gitref.py 2015-04-24 13:23:09 +0000
@@ -14,9 +14,11 @@
call_with,
export_as_webservice_entry,
export_factory_operation,
+ export_read_operation,
exported,
operation_for_version,
operation_parameters,
+ operation_returns_collection_of,
REQUEST_USER,
)
from lazr.restful.fields import (
@@ -37,7 +39,10 @@
)
from lp import _
-from lp.code.enums import GitObjectType
+from lp.code.enums import (
+ BranchMergeProposalStatus,
+ GitObjectType,
+ )
from lp.registry.interfaces.person import IPerson
from lp.services.webapp.interfaces import ITableBatchNavigator
@@ -256,6 +261,21 @@
References in personal repositories cannot specify merge proposals.
"""
+ @operation_parameters(
+ status=List(
+ title=_("A list of merge proposal statuses to filter by."),
+ value_type=Choice(vocabulary=BranchMergeProposalStatus)),
+ merged_revision_ids=List(TextLine(
+ title=_('The target revision ID of the merge.'))))
+ @call_with(visible_by_user=REQUEST_USER)
+ # Really IBranchMergeProposal, patched in _schema_circular_imports.py.
+ @operation_returns_collection_of(Interface)
+ @export_read_operation()
+ @operation_for_version("devel")
+ def getMergeProposals(status=None, visible_by_user=None,
+ merged_revision_ids=None, eager_load=False):
+ """Return matching BranchMergeProposals."""
+
class IGitRefBatchNavigator(ITableBatchNavigator):
pass
=== modified file 'lib/lp/code/model/gitref.py'
--- lib/lp/code/model/gitref.py 2015-04-22 16:11:40 +0000
+++ lib/lp/code/model/gitref.py 2015-04-24 13:23:09 +0000
@@ -18,6 +18,7 @@
Store,
Unicode,
)
+from zope.component import getUtility
from zope.event import notify
from zope.interface import implements
@@ -38,6 +39,7 @@
from lp.code.interfaces.branchmergeproposal import (
BRANCH_MERGE_PROPOSAL_FINAL_STATES,
)
+from lp.code.interfaces.gitcollection import IAllGitRepositories
from lp.code.interfaces.gitref import IGitRef
from lp.code.model.branchmergeproposal import (
BranchMergeProposal,
@@ -181,6 +183,21 @@
Not(BranchMergeProposal.queue_status.is_in(
BRANCH_MERGE_PROPOSAL_FINAL_STATES)))
+ def getMergeProposals(self, status=None, visible_by_user=None,
+ merged_revision_ids=None, eager_load=False):
+ """See `IGitRef`."""
+ if not status:
+ status = (
+ BranchMergeProposalStatus.CODE_APPROVED,
+ BranchMergeProposalStatus.NEEDS_REVIEW,
+ BranchMergeProposalStatus.WORK_IN_PROGRESS)
+
+ collection = getUtility(IAllGitRepositories).visibleByUser(
+ visible_by_user)
+ return collection.getMergeProposals(
+ status, target_repository=self.repository, target_path=self.path,
+ merged_revision_ids=merged_revision_ids, eager_load=eager_load)
+
class GitRef(StormBase, GitRefMixin):
"""See `IGitRef`."""
=== modified file 'lib/lp/code/model/tests/test_gitref.py'
--- lib/lp/code/model/tests/test_gitref.py 2015-04-21 13:40:50 +0000
+++ lib/lp/code/model/tests/test_gitref.py 2015-04-24 13:23:09 +0000
@@ -26,8 +26,11 @@
layer = DatabaseFunctionalLayer
+ def setUp(self):
+ super(TestGitRef, self).setUp()
+ self.useFixture(FeatureFixture({GIT_FEATURE_FLAG: u"on"}))
+
def test_display_name(self):
- self.useFixture(FeatureFixture({GIT_FEATURE_FLAG: u"on"}))
[master, personal] = self.factory.makeGitRefs(
paths=[u"refs/heads/master", u"refs/heads/people/foo/bar"])
repo_path = master.repository.shortened_path
@@ -35,6 +38,11 @@
[u"%s:master" % repo_path, "%s:people/foo/bar" % repo_path],
[ref.display_name for ref in (master, personal)])
+ def test_getMergeProposals(self):
+ [target_ref] = self.factory.makeGitRefs()
+ bmp = self.factory.makeBranchMergeProposalForGit(target_ref=target_ref)
+ self.assertEqual([bmp], list(target_ref.getMergeProposals()))
+
class TestGitRefWebservice(TestCaseWithFactory):
"""Tests for the webservice."""
Follow ups