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

Proposed by William Grant
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 12270
Proposed branch: lp:~wgrant/launchpad/bug-707808-unlanded-revisions
Merge into: lp:launchpad
Diff against target: 42 lines (+21/-1)
2 files modified
lib/lp/code/model/branchmergeproposal.py (+0/-1)
lib/lp/code/model/tests/test_branchmergeproposal.py (+21/-0)
To merge this branch: bzr merge lp:~wgrant/launchpad/bug-707808-unlanded-revisions
Reviewer Review Type Date Requested Status
Tim Penhey (community) code Approve
Steve Kowalik (community) code* Approve
Review via email: mp+47617@code.launchpad.net

Commit message

[r=stevenk,thumper][ui=none][bug=707808] Unbreak BranchMergeProposal.getUnlandedSourceBranchRevisions such that it gets only unlanded source branch revisions.

Description of the change

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).

To post a comment you must log in.
Revision history for this message
Steve Kowalik (stevenk) wrote :

Excellent work, and thanks for adding to our test coverage.

review: Approve (code*)
Revision history for this message
Tim Penhey (thumper) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/model/branchmergeproposal.py'
2--- lib/lp/code/model/branchmergeproposal.py 2011-01-20 19:07:26 +0000
3+++ lib/lp/code/model/branchmergeproposal.py 2011-01-27 00:36:15 +0000
4@@ -650,7 +650,6 @@
5 TargetRevision = ClassAlias(BranchRevision)
6 target_join = LeftJoin(
7 TargetRevision, And(
8- SourceRevision.branch_id == self.target_branch.id,
9 TargetRevision.branch_id == self.target_branch.id,
10 TargetRevision.revision_id == SourceRevision.revision_id))
11 origin = [SourceRevision, target_join]
12
13=== modified file 'lib/lp/code/model/tests/test_branchmergeproposal.py'
14--- lib/lp/code/model/tests/test_branchmergeproposal.py 2010-12-02 16:13:51 +0000
15+++ lib/lp/code/model/tests/test_branchmergeproposal.py 2011-01-27 00:36:15 +0000
16@@ -1938,5 +1938,26 @@
17 self.assertEqual([diff2, diff1], result)
18
19
20+class TestGetUnlandedSourceBranchRevisions(TestCaseWithFactory):
21+
22+ layer = LaunchpadFunctionalLayer
23+
24+ def test_getUnlandedSourceBranchRevisions(self):
25+ # Revisions in the source branch but not in the target are shown
26+ # as unlanded.
27+ bmp = self.factory.makeBranchMergeProposal()
28+ self.factory.makeRevisionsForBranch(bmp.source_branch, count=5)
29+ r1 = bmp.source_branch.getBranchRevision(sequence=1)
30+ initial_revisions = list(bmp.getUnlandedSourceBranchRevisions())
31+ self.assertEquals(5, len(initial_revisions))
32+ self.assertIn(r1, initial_revisions)
33+ # If we push one of the revisions into the target, it disappears
34+ # from the unlanded list.
35+ bmp.target_branch.createBranchRevision(1, r1.revision)
36+ partial_revisions = list(bmp.getUnlandedSourceBranchRevisions())
37+ self.assertEquals(4, len(partial_revisions))
38+ self.assertNotIn(r1, partial_revisions)
39+
40+
41 def test_suite():
42 return TestLoader().loadTestsFromName(__name__)