← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/bmp-merge-attributes into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/bmp-merge-attributes into lp:launchpad.

Commit message:
Use VCS-agnostic BranchMergeProposal.merge_* rather than *_branch where possible, in preparation for adding Git support.

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/bmp-merge-attributes/+merge/256977

Use VCS-agnostic BranchMergeProposal.merge_* rather than *_branch where possible, in preparation for adding Git support.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/bmp-merge-attributes into lp:launchpad.
=== modified file 'lib/lp/_schema_circular_imports.py'
--- lib/lp/_schema_circular_imports.py	2015-04-21 09:56:43 +0000
+++ lib/lp/_schema_circular_imports.py	2015-04-21 17:08:18 +0000
@@ -261,9 +261,9 @@
 
 patch_entry_return_type(IBranch, '_createMergeProposal', IBranchMergeProposal)
 patch_plain_parameter_type(
-    IBranch, '_createMergeProposal', 'target_branch', IBranch)
+    IBranch, '_createMergeProposal', 'merge_target', IBranch)
 patch_plain_parameter_type(
-    IBranch, '_createMergeProposal', 'prerequisite_branch', IBranch)
+    IBranch, '_createMergeProposal', 'merge_prerequisite', IBranch)
 patch_collection_return_type(
     IBranch, 'getMergeProposals', IBranchMergeProposal)
 

=== modified file 'lib/lp/code/browser/branch.py'
--- lib/lp/code/browser/branch.py	2015-04-19 12:56:32 +0000
+++ lib/lp/code/browser/branch.py	2015-04-21 17:08:18 +0000
@@ -1279,8 +1279,8 @@
 
         try:
             proposal = source_branch.addLandingTarget(
-                registrant=registrant, target_branch=target_branch,
-                prerequisite_branch=prerequisite_branch,
+                registrant=registrant, merge_target=target_branch,
+                merge_prerequisite=prerequisite_branch,
                 needs_review=data['needs_review'],
                 description=data.get('comment'),
                 review_requests=review_requests,

=== modified file 'lib/lp/code/browser/branchmergeproposal.py'
--- lib/lp/code/browser/branchmergeproposal.py	2015-04-19 12:56:32 +0000
+++ lib/lp/code/browser/branchmergeproposal.py	2015-04-21 17:08:18 +0000
@@ -134,10 +134,10 @@
             continue
         # Only show the must recent proposal for any given target.
         date_created = proposal.date_created
-        target_id = proposal.target_branch.id
+        target = proposal.merge_target
 
-        if target_id not in targets or date_created > targets[target_id][1]:
-            targets[target_id] = (proposal, date_created)
+        if target not in targets or date_created > targets[target][1]:
+            targets[target] = (proposal, date_created)
 
     return sorted(
         [proposal for proposal, date_created in targets.itervalues()],
@@ -149,7 +149,7 @@
 
     @property
     def text(self):
-        return 'Merge into %s' % self.context.target_branch.name
+        return 'Merge into %s' % self.context.merge_target.name
 
 
 def notify(func):
@@ -681,8 +681,8 @@
     @property
     def label(self):
         return "Merge %s into %s" % (
-            self.context.source_branch.bzr_identity,
-            self.context.target_branch.bzr_identity)
+            self.context.merge_source.identity,
+            self.context.merge_target.identity)
 
     @property
     def pending_diff(self):
@@ -797,7 +797,7 @@
     def trusted(self):
         """ Is the person a trusted reviewer."""
         proposal = self.context.branch_merge_proposal
-        return proposal.target_branch.isPersonTrustedReviewer(
+        return proposal.merge_target.isPersonTrustedReviewer(
             self.context.reviewer)
 
     @property
@@ -1113,7 +1113,7 @@
         # Store the source branch for `next_url` to make sure that
         # it is available in the situation where the merge proposal
         # is deleted.
-        self.source_branch = self.context.source_branch
+        self.merge_source = self.context.merge_source
         super(BranchMergeProposalDeleteView, self).initialize()
 
     @action('Delete proposal', name='delete')
@@ -1121,7 +1121,7 @@
         """Delete the merge proposal and go back to the source branch."""
         self.context.deleteProposal()
         # Override the next url to be the source branch.
-        self.next_url = canonical_url(self.source_branch)
+        self.next_url = canonical_url(self.merge_source)
 
 
 class BranchMergeProposalMergedView(LaunchpadEditFormView):
@@ -1180,8 +1180,8 @@
         self._full_subscribers = set()
         self._status_subscribers = set()
         # Add subscribers from the source and target branches.
-        self._add_subscribers_for_branch(self.context.source_branch)
-        self._add_subscribers_for_branch(self.context.target_branch)
+        self._add_subscribers_for_branch(self.context.merge_source)
+        self._add_subscribers_for_branch(self.context.merge_target)
         # Remove all the people from the comment_subscribers from the
         # status_and_vote_subscribers as they recipients will get the email
         # only once, and for the most detailed subscription from the source
@@ -1327,7 +1327,7 @@
     def label(self):
         """The pagetitle and heading."""
         return "Review merge proposal for %s" % (
-            self.context.source_branch.bzr_identity)
+            self.context.merge_source.identity)
     page_title = label
 
     @action('Save Review', name='vote')

=== modified file 'lib/lp/code/browser/configure.zcml'
--- lib/lp/code/browser/configure.zcml	2015-04-21 11:39:09 +0000
+++ lib/lp/code/browser/configure.zcml	2015-04-21 17:08:18 +0000
@@ -253,7 +253,7 @@
     <browser:url
         for="lp.code.interfaces.branchmergeproposal.IBranchMergeProposal"
         path_expression="string:+merge/${id}"
-        attribute_to_parent="source_branch"
+        attribute_to_parent="merge_source"
         rootsite="code"/>
     <browser:page
         for="lp.code.interfaces.branchmergeproposal.IBranchMergeProposalListingBatchNavigator"

=== modified file 'lib/lp/code/doc/branchmergeproposal.txt'
--- lib/lp/code/doc/branchmergeproposal.txt	2015-04-19 12:56:32 +0000
+++ lib/lp/code/doc/branchmergeproposal.txt	2015-04-21 17:08:18 +0000
@@ -43,7 +43,7 @@
     >>> target_branch = factory.makeProductBranch(product=fooix)
     >>> merge_proposal = source_branch.addLandingTarget(
     ...     registrant=source_branch.owner,
-    ...     target_branch=target_branch)
+    ...     merge_target=target_branch)
 
 The bare minimum that needs to be specified is the person that is proposing
 the merge, the ``registrant``, and the branch that the registrant wants the

=== modified file 'lib/lp/code/interfaces/branch.py'
--- lib/lp/code/interfaces/branch.py	2015-04-19 12:56:32 +0000
+++ lib/lp/code/interfaces/branch.py	2015-04-21 17:08:18 +0000
@@ -42,6 +42,7 @@
     operation_parameters,
     operation_returns_collection_of,
     operation_returns_entry,
+    rename_parameters_as,
     REQUEST_USER,
     )
 from lazr.restful.fields import (
@@ -570,9 +571,13 @@
         """Is the other branch mergeable into this branch (or vice versa)."""
 
     @export_operation_as('createMergeProposal')
+    # Rename back to Bazaar-specific names for API compatibility.
+    @rename_parameters_as(
+        merge_target='target_branch',
+        merge_prerequisite='prerequisite_branch')
     @operation_parameters(
-        target_branch=Reference(schema=Interface),
-        prerequisite_branch=Reference(schema=Interface),
+        merge_target=Reference(schema=Interface),
+        merge_prerequisite=Reference(schema=Interface),
         needs_review=Bool(title=_('Needs review'),
             description=_('If True the proposal needs review.'
             'Otherwise, it will be work in progress.')),
@@ -584,14 +589,14 @@
             description=_('Message to use when committing this merge.')),
         reviewers=List(value_type=Reference(schema=IPerson)),
         review_types=List(value_type=TextLine()))
-    # target_branch and prerequisite_branch are actually IBranch, patched in
+    # merge_target and merge_prerequisite are actually IBranch, patched in
     # _schema_circular_imports.
     @call_with(registrant=REQUEST_USER)
     # IBranchMergeProposal supplied as Interface to avoid circular imports.
     @export_factory_operation(Interface, [])
     @operation_for_version('beta')
     def _createMergeProposal(
-        registrant, target_branch, prerequisite_branch=None,
+        registrant, merge_target, merge_prerequisite=None,
         needs_review=True, initial_comment=None, commit_message=None,
         reviewers=None, review_types=None):
         """Create a new BranchMergeProposal with this branch as the source.
@@ -603,22 +608,22 @@
         targets.
         """
 
-    def addLandingTarget(registrant, target_branch, prerequisite_branch=None,
+    def addLandingTarget(registrant, merge_target, merge_prerequisite=None,
                          date_created=None, needs_review=False,
                          description=None, review_requests=None,
                          commit_message=None):
         """Create a new BranchMergeProposal with this branch as the source.
 
-        Both the target_branch and the prerequisite_branch, if it is there,
+        Both the merge_target and the merge_prerequisite, if it is there,
         must be branches with the same target as the source branch.
 
         Personal branches (a.k.a. junk branches) cannot specify landing
         targets.
 
         :param registrant: The person who is adding the landing target.
-        :param target_branch: Must be another branch, and different to self.
-        :param prerequisite_branch: Optional but if it is not None, it must be
-            another branch.
+        :param merge_target: Must be another branch, and different to self.
+        :param merge_prerequisite: Optional but if it is not None, it must
+            be another branch.
         :param date_created: Used to specify the date_created value of the
             merge request.
         :param needs_review: Used to specify the proposal is ready for

=== modified file 'lib/lp/code/interfaces/branchmergeproposal.py'
--- lib/lp/code/interfaces/branchmergeproposal.py	2015-04-19 12:56:32 +0000
+++ lib/lp/code/interfaces/branchmergeproposal.py	2015-04-21 17:08:18 +0000
@@ -502,8 +502,8 @@
         :type merge_reporter: ``Person``
         """
 
-    def resubmit(registrant, source_branch=None, target_branch=None,
-                 prerequisite_branch=DEFAULT):
+    def resubmit(registrant, merge_source=None, merge_target=None,
+                 merge_prerequisite=DEFAULT):
         """Mark the branch merge proposal as superseded and return a new one.
 
         The new proposal is created as work-in-progress, and copies across
@@ -512,12 +512,12 @@
         to review the new proposal.
 
         :param registrant: The person registering the new proposal.
-        :param source_branch: The source_branch for the new proposal (defaults
-            to the current source_branch).
-        :param target_branch: The target_branch for the new proposal (defaults
-            to the current target_branch).
-        :param prerequisite_branch: The prerequisite_branch for the new
-            proposal (defaults to the current prerequisite_branch).
+        :param merge_source: The merge_source for the new proposal (defaults
+            to the current merge_source).
+        :param merge_target: The merge_target for the new proposal (defaults
+            to the current merge_target).
+        :param merge_prerequisite: The merge_prerequisite for the new
+            proposal (defaults to the current merge_prerequisite).
         :param description: The description for the new proposal (defaults to
             the current description).
         """

=== modified file 'lib/lp/code/model/branch.py'
--- lib/lp/code/model/branch.py	2015-04-19 12:56:32 +0000
+++ lib/lp/code/model/branch.py	2015-04-21 17:08:18 +0000
@@ -508,8 +508,8 @@
         # and the target branch have common ancestry.
         return self.target.areBranchesMergeable(target_branch.target)
 
-    def addLandingTarget(self, registrant, target_branch,
-                         prerequisite_branch=None, whiteboard=None,
+    def addLandingTarget(self, registrant, merge_target,
+                         merge_prerequisite=None, whiteboard=None,
                          date_created=None, needs_review=False,
                          description=None, review_requests=None,
                          commit_message=None):
@@ -518,27 +518,27 @@
             raise InvalidBranchMergeProposal(
                 '%s branches do not support merge proposals.'
                 % self.target.displayname)
-        if self == target_branch:
+        if self == merge_target:
             raise InvalidBranchMergeProposal(
                 'Source and target branches must be different.')
-        if not target_branch.isBranchMergeable(self):
+        if not merge_target.isBranchMergeable(self):
             raise InvalidBranchMergeProposal(
                 '%s is not mergeable into %s' % (
-                    self.displayname, target_branch.displayname))
-        if prerequisite_branch is not None:
-            if not self.isBranchMergeable(prerequisite_branch):
+                    self.displayname, merge_target.displayname))
+        if merge_prerequisite is not None:
+            if not self.isBranchMergeable(merge_prerequisite):
                 raise InvalidBranchMergeProposal(
                     '%s is not mergeable into %s' % (
-                        prerequisite_branch.displayname, self.displayname))
-            if self == prerequisite_branch:
+                        merge_prerequisite.displayname, self.displayname))
+            if self == merge_prerequisite:
                 raise InvalidBranchMergeProposal(
                     'Source and prerequisite branches must be different.')
-            if target_branch == prerequisite_branch:
+            if merge_target == merge_prerequisite:
                 raise InvalidBranchMergeProposal(
                     'Target and prerequisite branches must be different.')
 
         target = BranchMergeProposalGetter.activeProposalsForBranches(
-            self, target_branch)
+            self, merge_target)
         for existing_proposal in target:
             raise BranchMergeProposalExists(existing_proposal)
 
@@ -557,12 +557,12 @@
 
         # If no reviewer is specified, use the default for the branch.
         if len(review_requests) == 0:
-            review_requests.append((target_branch.code_reviewer, None))
+            review_requests.append((merge_target.code_reviewer, None))
 
         bmp = BranchMergeProposal(
             registrant=registrant, source_branch=self,
-            target_branch=target_branch,
-            prerequisite_branch=prerequisite_branch, whiteboard=whiteboard,
+            target_branch=merge_target,
+            prerequisite_branch=merge_prerequisite, whiteboard=whiteboard,
             date_created=date_created,
             date_review_requested=date_review_requested,
             queue_status=queue_status, commit_message=commit_message,
@@ -579,7 +579,7 @@
         return bmp
 
     def _createMergeProposal(
-        self, registrant, target_branch, prerequisite_branch=None,
+        self, registrant, merge_target, merge_prerequisite=None,
         needs_review=True, initial_comment=None, commit_message=None,
         reviewers=None, review_types=None):
         """See `IBranch`."""
@@ -592,7 +592,7 @@
                 'reviewers and review_types must be equal length.')
         review_requests = zip(reviewers, review_types)
         return self.addLandingTarget(
-            registrant, target_branch, prerequisite_branch,
+            registrant, merge_target, merge_prerequisite,
             needs_review=needs_review, description=initial_comment,
             commit_message=commit_message, review_requests=review_requests)
 

=== modified file 'lib/lp/code/model/branchmergeproposal.py'
--- lib/lp/code/model/branchmergeproposal.py	2015-04-19 12:56:32 +0000
+++ lib/lp/code/model/branchmergeproposal.py	2015-04-21 17:08:18 +0000
@@ -122,7 +122,7 @@
         return True
     if from_state in FINAL_STATES and next_state not in FINAL_STATES:
         dupes = BranchMergeProposalGetter.activeProposalsForBranches(
-            proposal.source_branch, proposal.target_branch)
+            proposal.merge_source, proposal.merge_target)
         if not dupes.is_empty():
             return False
 
@@ -140,7 +140,7 @@
     # Transitioning to code approved, rejected, or failed from work in
     # progress or needs review needs the user to be a valid reviewer, other
     # states are fine.
-    valid_reviewer = proposal.target_branch.isPersonTrustedReviewer(user)
+    valid_reviewer = proposal.merge_target.isPersonTrustedReviewer(user)
     reviewed_ok_states = (code_approved, )
     obsolete_states = (merge_failed, queued)
     if not valid_reviewer:
@@ -205,14 +205,15 @@
 
     @property
     def private(self):
-        return (
-            (self.source_branch.information_type
-             in PRIVATE_INFORMATION_TYPES) or
-            (self.target_branch.information_type
-             in PRIVATE_INFORMATION_TYPES) or
-            (self.prerequisite_branch is not None and
-             (self.prerequisite_branch.information_type in
-              PRIVATE_INFORMATION_TYPES)))
+        objects = [
+            self.merge_source,
+            self.merge_target,
+            self.merge_prerequisite,
+            ]
+        return any(
+            obj is not None and
+            obj.information_type in PRIVATE_INFORMATION_TYPES
+            for obj in objects)
 
     reviewer = ForeignKey(
         dbName='reviewer', foreignKey='Person',
@@ -278,7 +279,9 @@
     @property
     def target(self):
         """See `IHasBranchTarget`."""
-        return self.source_branch.target
+        # XXX cjwatson 2015-04-12: This is not an IBranchTarget for Git,
+        # although it has similar semantics.
+        return self.merge_source.target
 
     root_message_id = StringCol(default=None)
 
@@ -286,8 +289,9 @@
     def title(self):
         """See `IBranchMergeProposal`."""
         return "[Merge] %(source)s into %(target)s" % {
-            'source': self.source_branch.bzr_identity,
-            'target': self.target_branch.bzr_identity}
+            'source': self.merge_source.identity,
+            'target': self.merge_target.identity,
+            }
 
     @property
     def all_comments(self):
@@ -334,19 +338,19 @@
         """See IBranchMergeProposal.getNotificationRecipients"""
         recipients = {}
         branch_identity_cache = {
-            self.source_branch: self.source_branch.bzr_identity,
-            self.target_branch: self.target_branch.bzr_identity,
+            self.merge_source: self.merge_source.identity,
+            self.merge_target: self.merge_target.identity,
             }
-        branches = [self.source_branch, self.target_branch]
-        if self.prerequisite_branch is not None:
-            branches.append(self.prerequisite_branch)
+        branches = [self.merge_source, self.merge_target]
+        if self.merge_prerequisite is not None:
+            branches.append(self.merge_prerequisite)
         for branch in branches:
             branch_recipients = branch.getNotificationRecipients()
             for recipient in branch_recipients:
                 # If the recipient cannot see either of the branches, skip
                 # them.
-                if (not self.source_branch.visibleByUser(recipient) or
-                    not self.target_branch.visibleByUser(recipient)):
+                if (not self.merge_source.visibleByUser(recipient) or
+                    not self.merge_target.visibleByUser(recipient)):
                     continue
                 subscription, rationale = branch_recipients.getReason(
                     recipient)
@@ -375,8 +379,8 @@
             recipients[self.registrant] = RecipientReason.forRegistrant(
                 self, branch_identity_cache=branch_identity_cache)
         # If the owner of the source branch is getting emails, override the
-        # rationale to say they are the owner of the souce branch.
-        source_owner = self.source_branch.owner
+        # rationale to say they are the owner of the source branch.
+        source_owner = self.merge_source.owner
         if source_owner in recipients:
             reason = RecipientReason.forSourceOwner(
                 self, branch_identity_cache=branch_identity_cache)
@@ -467,7 +471,7 @@
         """Set the proposal to next_state."""
         # Check the reviewer can review the code for the target branch.
         old_state = self.queue_status
-        if not self.target_branch.isPersonTrustedReviewer(reviewer):
+        if not self.merge_target.isPersonTrustedReviewer(reviewer):
             raise UserNotBranchReviewer
         # Check the current state of the proposal.
         self._transitionToState(next_state, reviewer)
@@ -519,22 +523,22 @@
             date_merged = UTC_NOW
         self.date_merged = date_merged
 
-    def resubmit(self, registrant, source_branch=None, target_branch=None,
-                 prerequisite_branch=DEFAULT, description=None,
+    def resubmit(self, registrant, merge_source=None, merge_target=None,
+                 merge_prerequisite=DEFAULT, description=None,
                  break_link=False):
         """See `IBranchMergeProposal`."""
-        if source_branch is None:
-            source_branch = self.source_branch
-        if target_branch is None:
-            target_branch = self.target_branch
+        if merge_source is None:
+            merge_source = self.merge_source
+        if merge_target is None:
+            merge_target = self.merge_target
         # DEFAULT instead of None, because None is a valid value.
         proposals = BranchMergeProposalGetter.activeProposalsForBranches(
-            source_branch, target_branch)
+            merge_source, merge_target)
         for proposal in proposals:
             if proposal is not self:
                 raise BranchMergeProposalExists(proposal)
-        if prerequisite_branch is DEFAULT:
-            prerequisite_branch = self.prerequisite_branch
+        if merge_prerequisite is DEFAULT:
+            merge_prerequisite = self.merge_prerequisite
         if description is None:
             description = self.description
         # You can transition from REJECTED to SUPERSEDED, but
@@ -547,10 +551,10 @@
         self.syncUpdate()
         review_requests = list(set(
             (vote.reviewer, vote.review_type) for vote in self.votes))
-        proposal = source_branch.addLandingTarget(
+        proposal = merge_source.addLandingTarget(
             registrant=registrant,
-            target_branch=target_branch,
-            prerequisite_branch=prerequisite_branch,
+            merge_target=merge_target,
+            merge_prerequisite=merge_prerequisite,
             description=description,
             needs_review=True, review_requests=review_requests)
         if not break_link:

=== modified file 'lib/lp/code/model/tests/test_branchmergeproposal.py'
--- lib/lp/code/model/tests/test_branchmergeproposal.py	2015-04-19 12:56:32 +0000
+++ lib/lp/code/model/tests/test_branchmergeproposal.py	2015-04-21 17:08:18 +0000
@@ -1025,8 +1025,8 @@
             registrant = owner
         bmp = branch.addLandingTarget(
             registrant=registrant,
-            target_branch=self.factory.makeProductBranch(product=product,
-            owner=owner))
+            merge_target=self.factory.makeProductBranch(
+                product=product, owner=owner))
         if needs_review:
             bmp.requestReview()
         return bmp

=== modified file 'lib/lp/code/subscribers/karma.py'
--- lib/lp/code/subscribers/karma.py	2011-12-30 06:14:56 +0000
+++ lib/lp/code/subscribers/karma.py	2015-04-21 17:08:18 +0000
@@ -29,7 +29,7 @@
     # If the user is commenting on their own proposal, then they don't
     # count as a reviewer for that proposal.
     user = code_review_comment.message.owner
-    reviewer = user.inTeam(proposal.target_branch.code_reviewer)
+    reviewer = user.inTeam(proposal.merge_target.code_reviewer)
     if reviewer and user != proposal.registrant:
         target.assignKarma(user, 'codereviewreviewercomment')
     else:

=== modified file 'lib/lp/code/templates/branchmergeproposal-link-summary.pt'
--- lib/lp/code/templates/branchmergeproposal-link-summary.pt	2009-11-03 01:56:09 +0000
+++ lib/lp/code/templates/branchmergeproposal-link-summary.pt	2015-04-21 17:08:18 +0000
@@ -12,9 +12,9 @@
   </tal:for-merging>
   into
   <tal:source-branch
-      tal:define="branch context/target_branch">
+      tal:define="branch context/merge_target">
     <a tal:attributes="href branch/fmt:url"
-       tal:content="branch/bzr_identity">lp:product/branch-name</a>
+       tal:content="branch/identity">lp:product/branch-name</a>
   </tal:source-branch>
   <tal:for-merging condition="context/queue_status/enumvalue:MERGED">
     <tal:have-revno condition="context/merged_revno">

=== modified file 'lib/lp/code/templates/branchmergeproposal-pagelet-summary.pt'
--- lib/lp/code/templates/branchmergeproposal-pagelet-summary.pt	2015-04-19 12:56:32 +0000
+++ lib/lp/code/templates/branchmergeproposal-pagelet-summary.pt	2015-04-21 17:08:18 +0000
@@ -103,16 +103,16 @@
     </tal:merged>
     <tr id="summary-row-8-source-branch">
       <th>Proposed branch:</th>
-      <td tal:content="structure context/source_branch/fmt:bzr-link">lp:~foo/bar/baz</td>
+      <td tal:content="structure context/merge_source/fmt:link">lp:~foo/bar/baz</td>
     </tr>
     <tr id="summary-row-9-target-branch">
       <th>Merge into:</th>
-      <td tal:content="structure context/target_branch/fmt:bzr-link">lp:~foo/bar/baz</td>
+      <td tal:content="structure context/merge_target/fmt:link">lp:~foo/bar/baz</td>
     </tr>
     <tr id="summary-row-a-prerequisite-branch"
         tal:condition="context/prerequisite_branch">
       <th>Prerequisite:</th>
-      <td tal:content="structure context/prerequisite_branch/fmt:bzr-link">lp:~foo/bar/baz</td>
+      <td tal:content="structure context/merge_prerequisite/fmt:link">lp:~foo/bar/baz</td>
     </tr>
     <tr id="summary-row-b-diff"
         tal:condition="context/preview_diff">

=== modified file 'lib/lp/code/tests/helpers.py'
--- lib/lp/code/tests/helpers.py	2012-09-18 18:36:09 +0000
+++ lib/lp/code/tests/helpers.py	2015-04-21 17:08:18 +0000
@@ -107,7 +107,7 @@
     proposed = factory.makeProductBranch(
         owner=fred, product=fooix, name='proposed')
     bmp = proposed.addLandingTarget(
-        registrant=fred, target_branch=trunk, needs_review=True,
+        registrant=fred, merge_target=trunk, needs_review=True,
         review_requests=[(eric, 'code')])
     # And fake a diff.
     naked_bmp = removeSecurityProxy(bmp)

=== modified file 'lib/lp/security.py'
--- lib/lp/security.py	2015-04-19 12:56:32 +0000
+++ lib/lp/security.py	2015-04-21 17:08:18 +0000
@@ -2392,16 +2392,15 @@
 
         The user is able to edit if they are:
           * the registrant of the merge proposal
-          * the owner of the source_branch
-          * the owner of the target_branch
-          * the reviewer for the target_branch
+          * the owner of the merge_source
+          * the owner of the merge_target
+          * the reviewer for the merge_target
           * an administrator
         """
         return (user.inTeam(self.obj.registrant) or
-                user.inTeam(self.obj.source_branch.owner) or
-                self.forwardCheckAuthenticated(
-                    user, self.obj.target_branch) or
-                user.inTeam(self.obj.target_branch.reviewer))
+                user.inTeam(self.obj.merge_source.owner) or
+                self.forwardCheckAuthenticated(user, self.obj.merge_target) or
+                user.inTeam(self.obj.merge_target.reviewer))
 
 
 class AdminDistroSeriesLanguagePacks(

=== modified file 'lib/lp/testing/factory.py'
--- lib/lp/testing/factory.py	2015-04-21 09:56:43 +0000
+++ lib/lp/testing/factory.py	2015-04-21 17:08:18 +0000
@@ -1451,7 +1451,7 @@
             review_requests.append((reviewer, None))
         proposal = source_branch.addLandingTarget(
             registrant, target_branch, review_requests=review_requests,
-            prerequisite_branch=prerequisite_branch, description=description,
+            merge_prerequisite=prerequisite_branch, description=description,
             date_created=date_created)
 
         unsafe_proposal = removeSecurityProxy(proposal)
@@ -1464,10 +1464,10 @@
             unsafe_proposal.requestReview()
         elif set_state == BranchMergeProposalStatus.CODE_APPROVED:
             unsafe_proposal.approveBranch(
-                proposal.target_branch.owner, 'some_revision')
+                proposal.merge_target.owner, 'some_revision')
         elif set_state == BranchMergeProposalStatus.REJECTED:
             unsafe_proposal.rejectBranch(
-                proposal.target_branch.owner, 'some_revision')
+                proposal.merge_target.owner, 'some_revision')
         elif set_state == BranchMergeProposalStatus.MERGED:
             unsafe_proposal.markAsMerged()
         elif set_state == BranchMergeProposalStatus.SUPERSEDED:


Follow ups