← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/bug-707808-unlanded-revisions into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/bug-707808-unlanded-revisions into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  #707808 Unmerged revisions list does not exclude merged revisions
  https://bugs.launchpad.net/bugs/707808

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/bug-707808-unlanded-revisions/+merge/47617

r12246 removed the final uses of BranchRevision.id, but also erroneously added a new condition to BranchMergeProposal.getUnlandedSourceBranchRevisions. This broke merged revision detection, causing the merge proposal page to show everything as unmerged (bug #707808).

This branch removes that erroneous addition, and adds a test (the method was previously untested).
-- 
https://code.launchpad.net/~wgrant/launchpad/bug-707808-unlanded-revisions/+merge/47617
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/bug-707808-unlanded-revisions into lp:launchpad.
=== modified file 'lib/lp/code/model/branchmergeproposal.py'
--- lib/lp/code/model/branchmergeproposal.py	2011-01-20 19:07:26 +0000
+++ lib/lp/code/model/branchmergeproposal.py	2011-01-27 00:36:15 +0000
@@ -650,7 +650,6 @@
         TargetRevision = ClassAlias(BranchRevision)
         target_join = LeftJoin(
             TargetRevision, And(
-                SourceRevision.branch_id == self.target_branch.id,
                 TargetRevision.branch_id == self.target_branch.id,
                 TargetRevision.revision_id == SourceRevision.revision_id))
         origin = [SourceRevision, target_join]

=== modified file 'lib/lp/code/model/tests/test_branchmergeproposal.py'
--- lib/lp/code/model/tests/test_branchmergeproposal.py	2010-12-02 16:13:51 +0000
+++ lib/lp/code/model/tests/test_branchmergeproposal.py	2011-01-27 00:36:15 +0000
@@ -1938,5 +1938,26 @@
         self.assertEqual([diff2, diff1], result)
 
 
+class TestGetUnlandedSourceBranchRevisions(TestCaseWithFactory):
+
+    layer = LaunchpadFunctionalLayer
+
+    def test_getUnlandedSourceBranchRevisions(self):
+        # Revisions in the source branch but not in the target are shown
+        # as unlanded.
+        bmp = self.factory.makeBranchMergeProposal()
+        self.factory.makeRevisionsForBranch(bmp.source_branch, count=5)
+        r1 = bmp.source_branch.getBranchRevision(sequence=1)
+        initial_revisions = list(bmp.getUnlandedSourceBranchRevisions())
+        self.assertEquals(5, len(initial_revisions))
+        self.assertIn(r1, initial_revisions)
+        # If we push one of the revisions into the target, it disappears
+        # from the unlanded list.
+        bmp.target_branch.createBranchRevision(1, r1.revision)
+        partial_revisions = list(bmp.getUnlandedSourceBranchRevisions())
+        self.assertEquals(4, len(partial_revisions))
+        self.assertNotIn(r1, partial_revisions)
+
+
 def test_suite():
     return TestLoader().loadTestsFromName(__name__)