Merge lp:~thumper/launchpad/only-show-latest-bmp-in-revision-mail into lp:launchpad
| Status: | Merged | ||||
|---|---|---|---|---|---|
| Merged at revision: | 10325 | ||||
| Proposed branch: | lp:~thumper/launchpad/only-show-latest-bmp-in-revision-mail | ||||
| Merge into: | lp:launchpad | ||||
| Diff against target: |
126 lines (+48/-16) 2 files modified
lib/lp/code/model/branchjob.py (+24/-12) lib/lp/code/model/tests/test_branchjob.py (+24/-4) |
||||
| To merge this branch: | bzr merge lp:~thumper/launchpad/only-show-latest-bmp-in-revision-mail | ||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Michael Hudson-Doyle | 2010-02-16 | Approve on 2010-02-16 | |
|
Review via email:
|
|||
Commit Message
Only show the most recent proposal for any given source branch in the revision mail.
| Tim Penhey (thumper) wrote : | # |
| Michael Hudson-Doyle (mwhudson) wrote : | # |
Hi Tim,
nice branch, just a couple of things to think about.
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -13,6 +13,7 @@
> ]
>
> import contextlib
> +import operator
> import os
> import shutil
> from StringIO import StringIO
> @@ -600,28 +601,43 @@
> authors.
> return authors
>
> - def findRelatedBMP(
> + def findRelatedBMP(
> """Find merge proposals related to the revision-ids and branch.
>
> Only proposals whose source branch last-scanned-id is in the set of
> revision-ids and whose target_branch is the BranchJob branch are
> returned.
>
> + Only return the most recent proposal for any given source branch.
> +
> :param revision_ids: A list of revision-ids to look for.
> :param include_superseded: If true, include merge proposals that are
> superseded in the results.
> """
> store = Store.of(
> conditions = [
> + ]
'conditions' is unused now.
> + result = store.find(
> + (BranchMergePro
> BranchMergeProp
> BranchMergeProp
> - Branch.
> - if not include_superseded:
> - conditions.append(
> - BranchMergeProp
> - BranchMergeProp
> - result = store.find(
> - return result
> + Branch.
> + (BranchMergePro
> + BranchMergeProp
> +
> + proposals = {}
> + for proposal, source in result:
> + # Only show the must recent proposal for any given source.
> + date_created = proposal.
> + source_id = source.id
> +
> + if (source_id not in proposals or
> + date_created > proposals[
> + proposals[
> +
> + return sorted(
> + [proposal for proposal, date_created in proposals.
> + key=operator.
This seems a little complicated, although I admit I can't think of any
obviously clearer ways. Did you think about any ways of doing the
filtering in the database? That seems likely to be complicated too
though...
> def getRevisionMess
> """Return the log message for a revision.
> @@ -654,9 +670,7 @@
> if len(pretty_authors) > 5:
> outf.write('...\n')
> outf.write('\n')
> - bmps = list(
> - self.findRelate
> - include_
> + bmps = self.f...
| Tim Penhey (thumper) wrote : | # |
On Tue, 16 Feb 2010 19:27:34 Michael Hudson wrote:
> Review: Approve
> Hi Tim,
>
> nice branch, just a couple of things to think about.
>
> > === modified file 'lib/lp/
> > --- lib/lp/
> > +++ lib/lp/
> > store = Store.of(
> > conditions = [
> > + ]
>
> 'conditions' is unused now.
Removed now.
> > + return sorted(
> > + [proposal for proposal, date_created in
> > proposals.
> > key=operator.
>
> This seems a little complicated, although I admit I can't think of any
> obviously clearer ways. Did you think about any ways of doing the
> filtering in the database? That seems likely to be complicated too
> though...
It could possibly be done, but I don't know how to do it in storm.
We want to group by the source branch and choose the merge proposal with the
latest date_created. I just don't know how to do this.
> > def getRevisionMess
> > """Return the log message for a revision.
> > @@ -654,9 +670,7 @@
> > if len(pretty_authors) > 5:
> > outf.write('...\n')
> > outf.write('\n')
> > - bmps = list(
> > - self.findRelate
> > - include_
> > + bmps = self.findRelate
> > if len(bmps) > 0:
> > outf.write('Related merge proposals:\n')
> > for bmp in bmps:
> >
> > === modified file 'lib/lp/
> > --- lib/lp/
> > +++ lib/lp/
> > + def test_findRelate
> > + """Assert that only the lastest for any particular source is
> > returned.
>
> I don't think it adds anything to start a test method
> comment/docstring with "Assert that". Something like "findRelatedBMP
> only returns the latest proposal for any source." would be better
> IMHO.
Fixed.
> And lastest isn't spelt like that :-)
I was tired. Also fixed.
> > self.assertEqua
> > list(job.
>
> It would be nice to reformat this as
>
> self.assertEqual(
> [desired_proposal], job.findRelated
>
> as you did for the other test.
Done.

The revision mail that goes out includes related merge proposals, which is great as long as one doesn't reuse branches. An example is the pending-db-changes that stub has. This branch only shows the latest merge proposal for any given source branch.