Merge lp:~abentley/launchpad/jobstatus into lp:launchpad

Proposed by Aaron Bentley
Status: Merged
Approved by: Guilherme Salgado
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~abentley/launchpad/jobstatus
Merge into: lp:launchpad
Diff against target: 280 lines (+119/-7)
10 files modified
lib/canonical/launchpad/icing/style.css (+2/-2)
lib/lp/code/browser/branchmergeproposal.py (+4/-0)
lib/lp/code/configure.zcml (+1/-0)
lib/lp/code/interfaces/branchmergeproposal.py (+3/-0)
lib/lp/code/model/branchmergeproposal.py (+26/-2)
lib/lp/code/model/branchmergeproposaljob.py (+5/-2)
lib/lp/code/model/tests/test_branchmergeproposals.py (+52/-0)
lib/lp/code/stories/branches/xx-branch-merge-proposals.txt (+16/-0)
lib/lp/code/templates/branch-index.pt (+1/-1)
lib/lp/code/templates/branchmergeproposal-index.pt (+9/-0)
To merge this branch: bzr merge lp:~abentley/launchpad/jobstatus
Reviewer Review Type Date Requested Status
Guilherme Salgado (community) code Approve
Review via email: mp+16309@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Aaron Bentley (abentley) wrote :

= Summary =
Fix bug #336936 "Show something on the merge proposal page while diff is being
generated".

== Proposed fix ==
Add a notice similar to the one about branch scanning

== Pre-implementation notes ==
None.

== Implementation details ==

== Tests ==
bin/test -t test_branchmergeproposals -t xx-branch-merge-proposals

== Demo and Q/A ==
Create a branch merge proposal. It should show a notice saying the diff is
being updated. After a few minutes, the diff should appear and the message
should go away. Now push new changes to the source branch. The message should
reappear.

= Launchpad lint =

There is lint here, but not of it seems very rational.

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/canonical/launchpad/icing/style.css
  lib/lp/code/configure.zcml
  lib/lp/code/browser/branchmergeproposal.py
  lib/lp/code/interfaces/branchmergeproposal.py
  lib/lp/code/model/branchmergeproposal.py
  lib/lp/code/model/branchmergeproposaljob.py
  lib/lp/code/model/tests/test_branchmergeproposals.py
  lib/lp/code/stories/branches/xx-branch-merge-proposals.txt
  lib/lp/code/templates/branchmergeproposal-index.pt

== Pylint notices ==

lib/lp/code/interfaces/branchmergeproposal.py
    27: [F0401] Unable to import 'lazr.lifecycle.event' (No module named lifecycle)
    42: [F0401] Unable to import 'lazr.restful.fields' (No module named restful)
    43: [F0401] Unable to import 'lazr.restful.declarations' (No module named restful)
    309: [C0322, IBranchMergeProposal.setStatus] Operator not preceded by a space
    title=_("The new status of the merge proposal."),
    ^
    vocabulary=BranchMergeProposalStatus),
    revision_id=Text(
    description=_("An optional parameter for specifying the "
    "revision of the branch for the status change."),
    required=False))
    @export_write_operation()
    def setStatus(status, user, revision_id):
    459: [C0322, IBranchMergeProposal.createComment] Operator not preceded by a space
    parent=Reference(schema=Interface))
    ^
    @call_with(owner=REQUEST_USER)

    @export_factory_operation(Interface, [])
    def createComment(owner, subject, content=None, vote=None,
    review_type=None, parent=None):
    490: [C0322, IBranchMergeProposal.updatePreviewDiff] Operator not preceded by a space
    target_revision_id=TextLine(), prerequisite_revision_id=TextLine(),
    ^
    conflicts=Text())
    @export_write_operation()
    def updatePreviewDiff(diff_content, source_revision_id,
    target_revision_id, prerequisite_revision_id=None,
    conflicts=None):

lib/lp/code/model/branchmergeproposaljob.py
    20: [F0401] Unable to import 'lazr.delegates' (No module named delegates)
    21: [F0401] Unable to import 'lazr.enum' (No module named enum)

Revision history for this message
Guilherme Salgado (salgado) wrote :
Download full text (6.4 KiB)

Hi Aaron,

I have a few questions/suggestions below, but it looks good overall.

 review needsfixing

On Thu, 2009-12-17 at 21:46 +0000, Aaron Bentley wrote:
> = Summary =
> Fix bug #336936 "Show something on the merge proposal page while diff
> is being
> generated".
>
> == Proposed fix ==
> Add a notice similar to the one about branch scanning
>
> == Pre-implementation notes ==
> None.
>
> == Implementation details ==
>
> == Tests ==
> bin/test -t test_branchmergeproposals -t xx-branch-merge-proposals
>

> === modified file 'lib/canonical/launchpad/icing/style.css'
> --- lib/canonical/launchpad/icing/style.css 2009-12-08 10:57:44 +0000
> +++ lib/canonical/launchpad/icing/style.css 2009-12-17 21:46:16 +0000
> @@ -1104,7 +1104,7 @@
> height: 2.5em;
> }
>
> -#branch-pending-writes {
> +#branch-pending-writes, #diff-pending-update {

Is this not a good opportunity to rename this class to 'pending-update'
or 'update-in-progress' instead of creating an alias to it?

> background: #FFF59C;
> width: 40em;
> margin: 1em auto;
> @@ -1117,7 +1117,7 @@
> -webkit-border-radius: 5px;
> }
>
> -#branch-pending-writes h3 {
> +#branch-pending-writes h3, #diff-pending-update h3 {
> color: black;
> font-weight: bold;
> text-align: center;
>

> === modified file 'lib/lp/code/interfaces/branchmergeproposal.py'
> --- lib/lp/code/interfaces/branchmergeproposal.py 2009-10-23 00:48:47 +0000
> +++ lib/lp/code/interfaces/branchmergeproposal.py 2009-12-17 21:46:16 +0000
> @@ -155,6 +155,8 @@
> IStaticDiff, title=_('The diff to be used for reviews.'),
> readonly=True)
>
> + next_preview_diff_job = Attribute('foo')
> +

!?

> preview_diff = exported(
> Reference(
> IPreviewDiff,
> @@ -511,6 +513,10 @@
> class IBranchMergeProposalJob(Interface):
> """A Job related to a Branch Merge Proposal."""
>
> + id = Int(
> + title=_('DB ID'), required=True, readonly=True,
> + description=_("Database id for this BranchJob."))

Do you really need to expose this in the public interface or is it just
for your test?

> +
> branch_merge_proposal = Object(
> title=_('The BranchMergeProposal this job is about'),
> schema=IBranchMergeProposal, required=True)
>
> === modified file 'lib/lp/code/model/branchmergeproposal.py'
> --- lib/lp/code/model/branchmergeproposal.py 2009-12-01 01:09:38 +0000
> +++ lib/lp/code/model/branchmergeproposal.py 2009-12-17 21:46:16 +0000
[...]
>
>
> def is_valid_transition(proposal, from_state, next_state, user=None):
> @@ -132,6 +134,26 @@
> review_diff = ForeignKey(
> foreignKey='StaticDiff', notNull=False, default=None)
>
> + @property
> + def next_preview_diff_job(self):
> + from lp.code.model.branchmergeproposaljob import (
> + BranchMergeProposalJob, MergeProposalCreatedJob,
> + UpdatePreviewDiffJob)

Circular dependencies? If so, care to leave a comment here?

> + job_classes = [MergeProposalCreatedJob, UpdatePreviewDiffJob]
> + type_classes = dict(
> + (job_class.class_job_type, job_class)
> + for job_class...

Read more...

review: Needs Fixing
Revision history for this message
Aaron Bentley (abentley) wrote :
Download full text (6.0 KiB)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Guilherme Salgado wrote:

>> === modified file 'lib/canonical/launchpad/icing/style.css'
>> --- lib/canonical/launchpad/icing/style.css 2009-12-08 10:57:44 +0000
>> +++ lib/canonical/launchpad/icing/style.css 2009-12-17 21:46:16 +0000
>> @@ -1104,7 +1104,7 @@
>> height: 2.5em;
>> }
>>
>> -#branch-pending-writes {
>> +#branch-pending-writes, #diff-pending-update {
>
> Is this not a good opportunity to rename this class to 'pending-update'
> or 'update-in-progress' instead of creating an alias to it?

Okay, I can do that.

>> background: #FFF59C;
>> width: 40em;
>> margin: 1em auto;
>> @@ -1117,7 +1117,7 @@
>> -webkit-border-radius: 5px;
>> }
>>
>> -#branch-pending-writes h3 {
>> +#branch-pending-writes h3, #diff-pending-update h3 {
>> color: black;
>> font-weight: bold;
>> text-align: center;
>>
>
>> === modified file 'lib/lp/code/interfaces/branchmergeproposal.py'
>> --- lib/lp/code/interfaces/branchmergeproposal.py 2009-10-23 00:48:47 +0000
>> +++ lib/lp/code/interfaces/branchmergeproposal.py 2009-12-17 21:46:16 +0000
>> @@ -155,6 +155,8 @@
>> IStaticDiff, title=_('The diff to be used for reviews.'),
>> readonly=True)
>>
>> + next_preview_diff_job = Attribute('foo')
>> +
>
> !?

Circular dependencies. I'll make the attribute somewhat better.

>> preview_diff = exported(
>> Reference(
>> IPreviewDiff,
>> @@ -511,6 +513,10 @@
>> class IBranchMergeProposalJob(Interface):
>> """A Job related to a Branch Merge Proposal."""
>>
>> + id = Int(
>> + title=_('DB ID'), required=True, readonly=True,
>> + description=_("Database id for this BranchJob."))
>
> Do you really need to expose this in the public interface or is it just
> for your test?

I think it makes a lot of sense to expose in the public interface, and I
have another branch in which it is necessary to expose it in the public
interface:

https://code.edge.launchpad.net/~abentley/launchpad/ampoulejob/+merge/15982

In this case, once I change the test to use an equality, I don't need it.

>
>> +
>> branch_merge_proposal = Object(
>> title=_('The BranchMergeProposal this job is about'),
>> schema=IBranchMergeProposal, required=True)
>>
>> === modified file 'lib/lp/code/model/branchmergeproposal.py'
>> --- lib/lp/code/model/branchmergeproposal.py 2009-12-01 01:09:38 +0000
>> +++ lib/lp/code/model/branchmergeproposal.py 2009-12-17 21:46:16 +0000
> [...]
>>
>>
>> def is_valid_transition(proposal, from_state, next_state, user=None):
>> @@ -132,6 +134,26 @@
>> review_diff = ForeignKey(
>> foreignKey='StaticDiff', notNull=False, default=None)
>>
>> + @property
>> + def next_preview_diff_job(self):
>> + from lp.code.model.branchmergeproposaljob import (
>> + BranchMergeProposalJob, MergeProposalCreatedJob,
>> + UpdatePreviewDiffJob)
>
> Circular dependencies?

Yes.

> If so, care to leave a comment here?

Alright.

>
>> + job_classes = [MergeProposalCreatedJob, UpdatePreviewDiffJob]
>> + type_classes = dict(
>> + (j...

Read more...

=== modified file 'lib/canonical/launchpad/icing/style.css'
--- lib/canonical/launchpad/icing/style.css 2009-12-14 20:08:29 +0000
+++ lib/canonical/launchpad/icing/style.css 2009-12-18 19:52:27 +0000
@@ -1104,7 +1104,7 @@
1104 height: 2.5em;1104 height: 2.5em;
1105}1105}
11061106
1107#branch-pending-writes, #diff-pending-update {1107.pending-update {
1108 background: #FFF59C;1108 background: #FFF59C;
1109 width: 40em;1109 width: 40em;
1110 margin: 1em auto;1110 margin: 1em auto;
@@ -1117,7 +1117,7 @@
1117 -webkit-border-radius: 5px;1117 -webkit-border-radius: 5px;
1118}1118}
11191119
1120#branch-pending-writes h3, #diff-pending-update h3 {1120.pending-update h3{
1121 color: black;1121 color: black;
1122 font-weight: bold;1122 font-weight: bold;
1123 text-align: center;1123 text-align: center;
11241124
=== modified file 'lib/lp/code/interfaces/branchmergeproposal.py'
--- lib/lp/code/interfaces/branchmergeproposal.py 2009-12-18 14:51:37 +0000
+++ lib/lp/code/interfaces/branchmergeproposal.py 2009-12-18 19:44:07 +0000
@@ -118,7 +118,8 @@
118 IStaticDiff, title=_('The diff to be used for reviews.'),118 IStaticDiff, title=_('The diff to be used for reviews.'),
119 readonly=True)119 readonly=True)
120120
121 next_preview_diff_job = Attribute('foo')121 next_preview_diff_job = Attribute(
122 'The next BranchMergeProposalJob that will update a preview diff.')
122123
123 preview_diff = exported(124 preview_diff = exported(
124 Reference(125 Reference(
@@ -476,10 +477,6 @@
476class IBranchMergeProposalJob(Interface):477class IBranchMergeProposalJob(Interface):
477 """A Job related to a Branch Merge Proposal."""478 """A Job related to a Branch Merge Proposal."""
478479
479 id = Int(
480 title=_('DB ID'), required=True, readonly=True,
481 description=_("Database id for this BranchJob."))
482
483 branch_merge_proposal = Object(480 branch_merge_proposal = Object(
484 title=_('The BranchMergeProposal this job is about'),481 title=_('The BranchMergeProposal this job is about'),
485 schema=IBranchMergeProposal, required=True)482 schema=IBranchMergeProposal, required=True)
486483
=== modified file 'lib/lp/code/model/branchmergeproposal.py'
--- lib/lp/code/model/branchmergeproposal.py 2009-12-18 14:51:37 +0000
+++ lib/lp/code/model/branchmergeproposal.py 2009-12-18 19:44:53 +0000
@@ -137,6 +137,7 @@
137137
138 @property138 @property
139 def next_preview_diff_job(self):139 def next_preview_diff_job(self):
140 # circular dependencies
140 from lp.code.model.branchmergeproposaljob import (141 from lp.code.model.branchmergeproposaljob import (
141 BranchMergeProposalJob, MergeProposalCreatedJob,142 BranchMergeProposalJob, MergeProposalCreatedJob,
142 UpdatePreviewDiffJob)143 UpdatePreviewDiffJob)
@@ -147,7 +148,7 @@
147 job = Store.of(self).find(148 job = Store.of(self).find(
148 BranchMergeProposalJob,149 BranchMergeProposalJob,
149 BranchMergeProposalJob.branch_merge_proposal == self,150 BranchMergeProposalJob.branch_merge_proposal == self,
150 BranchMergeProposalJob.job_type.is_in(type_classes),151 BranchMergeProposalJob.job_type.is_in(type_classes.keys()),
151 BranchMergeProposalJob.job == Job.id,152 BranchMergeProposalJob.job == Job.id,
152 Job._status.is_in([JobStatus.WAITING, JobStatus.RUNNING])153 Job._status.is_in([JobStatus.WAITING, JobStatus.RUNNING])
153 ).order_by(Job.scheduled_start, Job.date_created).first()154 ).order_by(Job.scheduled_start, Job.date_created).first()
154155
=== modified file 'lib/lp/code/model/tests/test_branchmergeproposals.py'
--- lib/lp/code/model/tests/test_branchmergeproposals.py 2009-12-18 14:51:37 +0000
+++ lib/lp/code/model/tests/test_branchmergeproposals.py 2009-12-18 19:41:47 +0000
@@ -1879,9 +1879,9 @@
1879 """Jobs are shown while pending."""1879 """Jobs are shown while pending."""
1880 bmp = self.factory.makeBranchMergeProposal()1880 bmp = self.factory.makeBranchMergeProposal()
1881 job = bmp.next_preview_diff_job1881 job = bmp.next_preview_diff_job
1882 self.assertEqual(job.id, bmp.next_preview_diff_job.id)1882 self.assertEqual(job, bmp.next_preview_diff_job)
1883 job.start()1883 job.start()
1884 self.assertEqual(job.id, bmp.next_preview_diff_job.id)1884 self.assertEqual(job, bmp.next_preview_diff_job)
1885 job.fail()1885 job.fail()
1886 self.assertIs(None, bmp.next_preview_diff_job)1886 self.assertIs(None, bmp.next_preview_diff_job)
18871887
18881888
=== modified file 'lib/lp/code/templates/branch-index.pt'
--- lib/lp/code/templates/branch-index.pt 2009-12-03 18:33:22 +0000
+++ lib/lp/code/templates/branch-index.pt 2009-12-18 19:49:08 +0000
@@ -162,7 +162,7 @@
162162
163 <div class="yui-g" tal:condition="view/pending_writes">163 <div class="yui-g" tal:condition="view/pending_writes">
164 <div class="portlet">164 <div class="portlet">
165 <div id="branch-pending-writes">165 <div id="branch-pending-writes" class="pending-update">
166 <h3>Updating branch...</h3>166 <h3>Updating branch...</h3>
167 <p>167 <p>
168 Launchpad is processing new changes to this branch and will be168 Launchpad is processing new changes to this branch and will be
169169
=== modified file 'lib/lp/code/templates/branchmergeproposal-index.pt'
--- lib/lp/code/templates/branchmergeproposal-index.pt 2009-12-14 20:08:29 +0000
+++ lib/lp/code/templates/branchmergeproposal-index.pt 2009-12-18 19:53:27 +0000
@@ -181,7 +181,7 @@
181 </div>181 </div>
182182
183 <div class="yui-g" tal:condition="view/pending_diff">183 <div class="yui-g" tal:condition="view/pending_diff">
184 <div class="portlet" id="diff-pending-update">184 <div class="portlet pending-update" id="diff-pending-update">
185 <h3>Updating diff...</h3>185 <h3>Updating diff...</h3>
186 <p>186 <p>
187 An updated diff will be available in a few minutes. Reload to see the187 An updated diff will be available in a few minutes. Reload to see the
Revision history for this message
Guilherme Salgado (salgado) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/canonical/launchpad/icing/style.css'
--- lib/canonical/launchpad/icing/style.css 2010-01-04 17:15:00 +0000
+++ lib/canonical/launchpad/icing/style.css 2010-01-06 20:54:14 +0000
@@ -1086,7 +1086,7 @@
1086 height: 2.5em;1086 height: 2.5em;
1087}1087}
10881088
1089#branch-pending-writes {1089.pending-update {
1090 background: #FFF59C;1090 background: #FFF59C;
1091 width: 40em;1091 width: 40em;
1092 margin: 1em auto;1092 margin: 1em auto;
@@ -1099,7 +1099,7 @@
1099 -webkit-border-radius: 5px;1099 -webkit-border-radius: 5px;
1100}1100}
11011101
1102#branch-pending-writes h3 {1102.pending-update h3{
1103 color: black;1103 color: black;
1104 font-weight: bold;1104 font-weight: bold;
1105 text-align: center;1105 text-align: center;
11061106
=== modified file 'lib/lp/code/browser/branchmergeproposal.py'
--- lib/lp/code/browser/branchmergeproposal.py 2009-12-11 00:56:16 +0000
+++ lib/lp/code/browser/branchmergeproposal.py 2010-01-06 20:54:14 +0000
@@ -626,6 +626,10 @@
626 result.append(dict(style=style, comment=comment))626 result.append(dict(style=style, comment=comment))
627 return result627 return result
628628
629 @property
630 def pending_diff(self):
631 return self.context.next_preview_diff_job is not None
632
629 @cachedproperty633 @cachedproperty
630 def preview_diff(self):634 def preview_diff(self):
631 """Return a `Diff` of the preview.635 """Return a `Diff` of the preview.
632636
=== modified file 'lib/lp/code/configure.zcml'
--- lib/lp/code/configure.zcml 2009-12-18 15:59:21 +0000
+++ lib/lp/code/configure.zcml 2010-01-06 20:54:14 +0000
@@ -226,6 +226,7 @@
226 date_review_requested226 date_review_requested
227 date_reviewed227 date_reviewed
228 review_diff228 review_diff
229 next_preview_diff_job
229 preview_diff230 preview_diff
230 votes231 votes
231 root_comment232 root_comment
232233
=== modified file 'lib/lp/code/interfaces/branchmergeproposal.py'
--- lib/lp/code/interfaces/branchmergeproposal.py 2009-12-18 15:59:21 +0000
+++ lib/lp/code/interfaces/branchmergeproposal.py 2010-01-06 20:54:14 +0000
@@ -118,6 +118,9 @@
118 IStaticDiff, title=_('The diff to be used for reviews.'),118 IStaticDiff, title=_('The diff to be used for reviews.'),
119 readonly=True)119 readonly=True)
120120
121 next_preview_diff_job = Attribute(
122 'The next BranchMergeProposalJob that will update a preview diff.')
123
121 preview_diff = exported(124 preview_diff = exported(
122 Reference(125 Reference(
123 IPreviewDiff,126 IPreviewDiff,
124127
=== modified file 'lib/lp/code/model/branchmergeproposal.py'
--- lib/lp/code/model/branchmergeproposal.py 2009-12-08 09:02:43 +0000
+++ lib/lp/code/model/branchmergeproposal.py 2010-01-06 20:54:14 +0000
@@ -38,7 +38,6 @@
38from lp.code.model.codereviewvote import (38from lp.code.model.codereviewvote import (
39 CodeReviewVoteReference)39 CodeReviewVoteReference)
40from lp.code.model.diff import PreviewDiff40from lp.code.model.diff import PreviewDiff
41from lp.registry.model.person import Person
42from lp.code.event.branchmergeproposal import (41from lp.code.event.branchmergeproposal import (
43 BranchMergeProposalStatusChangeEvent, NewCodeReviewCommentEvent,42 BranchMergeProposalStatusChangeEvent, NewCodeReviewCommentEvent,
44 ReviewerNominatedEvent)43 ReviewerNominatedEvent)
@@ -48,11 +47,14 @@
48 BRANCH_MERGE_PROPOSAL_FINAL_STATES as FINAL_STATES,47 BRANCH_MERGE_PROPOSAL_FINAL_STATES as FINAL_STATES,
49 IBranchMergeProposal, IBranchMergeProposalGetter)48 IBranchMergeProposal, IBranchMergeProposalGetter)
50from lp.code.interfaces.branchtarget import IHasBranchTarget49from lp.code.interfaces.branchtarget import IHasBranchTarget
50from lp.code.mail.branch import RecipientReason
51from lp.registry.model.person import Person
51from lp.registry.interfaces.person import IPerson52from lp.registry.interfaces.person import IPerson
52from lp.registry.interfaces.product import IProduct53from lp.registry.interfaces.product import IProduct
53from lp.code.mail.branch import RecipientReason
54from lp.registry.interfaces.person import validate_public_person54from lp.registry.interfaces.person import validate_public_person
55from lp.services.mail.sendmail import validate_message55from lp.services.mail.sendmail import validate_message
56from lp.services.job.interfaces.job import JobStatus
57from lp.services.job.model.job import Job
5658
5759
58def is_valid_transition(proposal, from_state, next_state, user=None):60def is_valid_transition(proposal, from_state, next_state, user=None):
@@ -133,6 +135,28 @@
133 review_diff = ForeignKey(135 review_diff = ForeignKey(
134 foreignKey='StaticDiff', notNull=False, default=None)136 foreignKey='StaticDiff', notNull=False, default=None)
135137
138 @property
139 def next_preview_diff_job(self):
140 # circular dependencies
141 from lp.code.model.branchmergeproposaljob import (
142 BranchMergeProposalJob, MergeProposalCreatedJob,
143 UpdatePreviewDiffJob)
144 job_classes = [MergeProposalCreatedJob, UpdatePreviewDiffJob]
145 type_classes = dict(
146 (job_class.class_job_type, job_class)
147 for job_class in job_classes)
148 job = Store.of(self).find(
149 BranchMergeProposalJob,
150 BranchMergeProposalJob.branch_merge_proposal == self,
151 BranchMergeProposalJob.job_type.is_in(type_classes.keys()),
152 BranchMergeProposalJob.job == Job.id,
153 Job._status.is_in([JobStatus.WAITING, JobStatus.RUNNING])
154 ).order_by(Job.scheduled_start, Job.date_created).first()
155 if job is not None:
156 return type_classes[job.job_type](job)
157 else:
158 return None
159
136 preview_diff_id = Int(name='merge_diff')160 preview_diff_id = Int(name='merge_diff')
137 preview_diff = Reference(preview_diff_id, 'PreviewDiff.id')161 preview_diff = Reference(preview_diff_id, 'PreviewDiff.id')
138162
139163
=== modified file 'lib/lp/code/model/branchmergeproposaljob.py'
--- lib/lp/code/model/branchmergeproposaljob.py 2009-12-10 18:20:09 +0000
+++ lib/lp/code/model/branchmergeproposaljob.py 2010-01-06 20:54:14 +0000
@@ -15,7 +15,7 @@
15 ]15 ]
1616
17import contextlib17import contextlib
18from email.Utils import parseaddr18from email.utils import parseaddr
19import transaction19import transaction
2020
21from lazr.delegates import delegates21from lazr.delegates import delegates
@@ -28,6 +28,7 @@
28from storm.store import Store28from storm.store import Store
29from zope.component import getUtility29from zope.component import getUtility
30from zope.interface import classProvides, implements30from zope.interface import classProvides, implements
31from zope.security.proxy import removeSecurityProxy
3132
32from canonical.database.enumcol import EnumCol33from canonical.database.enumcol import EnumCol
33from canonical.launchpad.database.message import MessageJob, MessageJobAction34from canonical.launchpad.database.message import MessageJob, MessageJobAction
@@ -153,7 +154,9 @@
153 self.context = job154 self.context = job
154155
155 def __eq__(self, job):156 def __eq__(self, job):
156 return (self.__class__ is job.__class__ and self.job == job.job)157 return (
158 self.__class__ is removeSecurityProxy(job.__class__)
159 and self.job == job.job)
157160
158 def __ne__(self, job):161 def __ne__(self, job):
159 return not (self == job)162 return not (self == job)
160163
=== modified file 'lib/lp/code/model/tests/test_branchmergeproposals.py'
--- lib/lp/code/model/tests/test_branchmergeproposals.py 2009-12-18 15:02:34 +0000
+++ lib/lp/code/model/tests/test_branchmergeproposals.py 2010-01-06 20:54:14 +0000
@@ -13,6 +13,7 @@
1313
14from pytz import UTC14from pytz import UTC
15from sqlobject import SQLObjectNotFound15from sqlobject import SQLObjectNotFound
16from storm.locals import Store
16from zope.component import getUtility17from zope.component import getUtility
17import transaction18import transaction
18from zope.security.proxy import removeSecurityProxy19from zope.security.proxy import removeSecurityProxy
@@ -1891,5 +1892,56 @@
1891 self.checkExampleMerge(bmp.preview_diff.text)1892 self.checkExampleMerge(bmp.preview_diff.text)
18921893
18931894
1895class TestNextPreviewDiffJob(TestCaseWithFactory):
1896
1897 layer = DatabaseFunctionalLayer
1898
1899 def test_returns_bmp_job(self):
1900 """For new proposals, get the MergeProposalCreatedJob."""
1901 bmp = self.factory.makeBranchMergeProposal()
1902 job = bmp.next_preview_diff_job
1903 self.assertEqual(bmp, job.branch_merge_proposal)
1904 self.assertIs(
1905 MergeProposalCreatedJob, removeSecurityProxy(job).__class__)
1906
1907 def test_returns_none_if_job_not_pending(self):
1908 """Jobs are shown while pending."""
1909 bmp = self.factory.makeBranchMergeProposal()
1910 job = bmp.next_preview_diff_job
1911 self.assertEqual(job, bmp.next_preview_diff_job)
1912 job.start()
1913 self.assertEqual(job, bmp.next_preview_diff_job)
1914 job.fail()
1915 self.assertIs(None, bmp.next_preview_diff_job)
1916
1917 def makeBranchMergeProposalNoPending(self):
1918 bmp = self.factory.makeBranchMergeProposal()
1919 bmp.next_preview_diff_job.start()
1920 bmp.next_preview_diff_job.complete()
1921 return bmp
1922
1923 def test_returns_update_preview_diff_job(self):
1924 """UpdatePreviewDiffJobs can be returned."""
1925 bmp = self.makeBranchMergeProposalNoPending()
1926 updatejob = UpdatePreviewDiffJob.create(bmp)
1927 Store.of(updatejob.context).flush()
1928 self.assertEqual(updatejob, bmp.next_preview_diff_job)
1929
1930 def test_returns_first__job(self):
1931 """First-created job is returned."""
1932 bmp = self.makeBranchMergeProposalNoPending()
1933 updatejob = UpdatePreviewDiffJob.create(bmp)
1934 updatejob2 = UpdatePreviewDiffJob.create(bmp)
1935 self.assertEqual(updatejob, bmp.next_preview_diff_job)
1936
1937 def test_does_not_return_jobs_for_other_proposals(self):
1938 """Jobs for other merge proposals are not returned."""
1939 bmp = self.factory.makeBranchMergeProposal()
1940 bmp.next_preview_diff_job.start()
1941 bmp.next_preview_diff_job.complete()
1942 bmp2 = self.factory.makeBranchMergeProposal()
1943 self.assertIs(None, bmp.next_preview_diff_job)
1944
1945
1894def test_suite():1946def test_suite():
1895 return TestLoader().loadTestsFromName(__name__)1947 return TestLoader().loadTestsFromName(__name__)
18961948
=== modified file 'lib/lp/code/stories/branches/xx-branch-merge-proposals.txt'
--- lib/lp/code/stories/branches/xx-branch-merge-proposals.txt 2009-11-27 01:29:10 +0000
+++ lib/lp/code/stories/branches/xx-branch-merge-proposals.txt 2010-01-06 20:54:14 +0000
@@ -628,6 +628,22 @@
628 Empty628 Empty
629629
630630
631Preview diff generation status
632------------------------------
633
634 >>> update = find_tag_by_id(nopriv_browser.contents, 'diff-pending-update')
635 >>> print extract_text(update)
636 Updating diff...
637 An updated diff will be available in a few minutes. Reload to see the
638 changes.
639 >>> bmp.next_preview_diff_job.start()
640 >>> bmp.next_preview_diff_job.complete()
641 >>> transaction.commit()
642 >>> nopriv_browser.open(url)
643 >>> print find_tag_by_id(nopriv_browser.contents, 'diff-pending-update')
644 None
645
646
631Merge proposal details shown on the branch page647Merge proposal details shown on the branch page
632-----------------------------------------------648-----------------------------------------------
633649
634650
=== modified file 'lib/lp/code/templates/branch-index.pt'
--- lib/lp/code/templates/branch-index.pt 2010-01-04 19:36:17 +0000
+++ lib/lp/code/templates/branch-index.pt 2010-01-06 20:54:14 +0000
@@ -163,7 +163,7 @@
163163
164 <div class="yui-g" tal:condition="view/pending_writes">164 <div class="yui-g" tal:condition="view/pending_writes">
165 <div class="portlet">165 <div class="portlet">
166 <div id="branch-pending-writes">166 <div id="branch-pending-writes" class="pending-update">
167 <h3>Updating branch...</h3>167 <h3>Updating branch...</h3>
168 <p>168 <p>
169 Launchpad is processing new changes to this branch and will be169 Launchpad is processing new changes to this branch and will be
170170
=== modified file 'lib/lp/code/templates/branchmergeproposal-index.pt'
--- lib/lp/code/templates/branchmergeproposal-index.pt 2009-12-11 05:07:57 +0000
+++ lib/lp/code/templates/branchmergeproposal-index.pt 2010-01-06 20:54:14 +0000
@@ -180,6 +180,15 @@
180 </div>180 </div>
181 </div>181 </div>
182182
183 <div class="yui-g" tal:condition="view/pending_diff">
184 <div class="portlet pending-update" id="diff-pending-update">
185 <h3>Updating diff...</h3>
186 <p>
187 An updated diff will be available in a few minutes. Reload to see the
188 changes.
189 </p>
190 </div>
191 </div>
183 <div id="review-diff" tal:condition="view/preview_diff">192 <div id="review-diff" tal:condition="view/preview_diff">
184 <h2>Preview Diff</h2>193 <h2>Preview Diff</h2>
185 <div tal:replace="structure context/@@++diff"/>194 <div tal:replace="structure context/@@++diff"/>