Merge lp:~thumper/launchpad/all-code-review-email-using-jobs into lp:launchpad/db-devel

Proposed by Tim Penhey
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~thumper/launchpad/all-code-review-email-using-jobs
Merge into: lp:launchpad/db-devel
Prerequisite: lp:~thumper/launchpad/merge-proposal-job-source
Diff against target: 1899 lines (+256/-476)
60 files modified
Makefile (+4/-5)
configs/development/launchpad-lazr.conf (+2/-2)
configs/testrunner/launchpad-lazr.conf (+2/-6)
cronscripts/merge-proposal-jobs.py (+22/-30)
cronscripts/update_preview_diffs.py (+0/-38)
database/schema/security.cfg (+1/-13)
lib/canonical/config/schema-lazr.conf (+2/-14)
lib/canonical/launchpad/doc/product-update-remote-product-script.txt (+1/-1)
lib/lp/answers/doc/expiration.txt (+1/-1)
lib/lp/bugs/doc/bugnotification-sending.txt (+1/-1)
lib/lp/bugs/doc/bugtask-expiration.txt (+1/-1)
lib/lp/bugs/doc/bugtask.txt (+1/-1)
lib/lp/bugs/doc/checkwatches.txt (+1/-1)
lib/lp/bugs/doc/cve-update.txt (+2/-2)
lib/lp/bugs/tests/test_apportjob.py (+1/-1)
lib/lp/bugs/tests/test_bugheat.py (+1/-1)
lib/lp/code/doc/branch-merge-proposal-notifications.txt (+11/-5)
lib/lp/code/doc/codereviewcomment.txt (+6/-12)
lib/lp/code/interfaces/branchmergeproposal.py (+4/-3)
lib/lp/code/mail/branch.py (+0/-1)
lib/lp/code/mail/tests/test_branchmergeproposal.py (+11/-10)
lib/lp/code/mail/tests/test_codehandler.py (+11/-13)
lib/lp/code/mail/tests/test_codereviewcomment.py (+1/-1)
lib/lp/code/model/branchmergeproposal.py (+6/-9)
lib/lp/code/model/branchmergeproposaljob.py (+2/-0)
lib/lp/code/model/tests/test_branchcloud.py (+4/-3)
lib/lp/code/model/tests/test_branchmergeproposaljobs.py (+10/-29)
lib/lp/code/model/tests/test_branchmergeproposals.py (+9/-56)
lib/lp/code/model/tests/test_diff.py (+4/-0)
lib/lp/code/scripts/tests/test_create_merge_proposals.py (+3/-3)
lib/lp/code/scripts/tests/test_merge_proposal_jobs.py (+9/-47)
lib/lp/code/scripts/tests/test_reclaim_branch_space.py (+3/-4)
lib/lp/code/scripts/tests/test_scan_branches.py (+2/-2)
lib/lp/code/scripts/tests/test_sendbranchmail.py (+13/-8)
lib/lp/code/scripts/tests/test_update_preview_diffs.py (+0/-93)
lib/lp/code/scripts/tests/test_upgrade_branches.py (+4/-4)
lib/lp/code/tests/helpers.py (+16/-0)
lib/lp/codehosting/scanner/tests/test_bzrsync.py (+6/-5)
lib/lp/codehosting/scanner/tests/test_mergedetection.py (+16/-4)
lib/lp/hardwaredb/doc/hwdb-submission.txt (+4/-4)
lib/lp/registry/doc/distribution-mirror.txt (+5/-5)
lib/lp/registry/doc/person-karma.txt (+1/-1)
lib/lp/registry/doc/sourceforge-remote-products.txt (+1/-1)
lib/lp/registry/doc/standing.txt (+2/-2)
lib/lp/services/job/tests/test_runner.py (+6/-2)
lib/lp/services/mail/sendmail.py (+20/-13)
lib/lp/soyuz/doc/buildd-slavescanner.txt (+2/-2)
lib/lp/soyuz/doc/gina.txt (+1/-1)
lib/lp/soyuz/doc/manage-chroot.txt (+1/-1)
lib/lp/soyuz/doc/package-cache-script.txt (+1/-1)
lib/lp/soyuz/scripts/tests/test_processupload.py (+1/-1)
lib/lp/translations/doc/distroseries-translations-copy.txt (+4/-2)
lib/lp/translations/doc/fix_translation_credits.txt (+2/-1)
lib/lp/translations/doc/poexport-language-pack.txt (+2/-1)
lib/lp/translations/doc/poexport-request.txt (+1/-1)
lib/lp/translations/doc/pofile-verify-stats.txt (+2/-2)
lib/lp/translations/doc/rosetta-poimport-script.txt (+1/-1)
lib/lp/translations/doc/sourcepackagerelease-translations.txt (+3/-2)
lib/lp/translations/doc/translations-export-to-branch.txt (+1/-1)
lib/lp/translations/scripts/tests/test_translations_to_branch.py (+1/-1)
To merge this branch: bzr merge lp:~thumper/launchpad/all-code-review-email-using-jobs
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle Approve
Review via email: mp+22439@code.launchpad.net

Commit message

All code review email is now sent using a single job.

Description of the change

This branch is the end of the pipeline.

This is the branch that is going to be merged, and it will be merged
into db-devel, as it is a large change and also landing a change that
would impact edge in such a way that it wouldn't send email is a
"bad thing" (TM).

$ bzr pipes
   remove-thumper-from-sample-data
   code-review-comment-email-job
   new-reviewer-email-job
   bmp-notification-email-job
   format-address-for-person
   subscriber-move-and-cleanup
   merge-proposal-job-source
* all-code-review-email-using-jobs

This branch is the branch that provides the cronjob to run all the
merge proposal jobs. The old mpcreationjobs.py cronscript is renamed
to merge-proposal-jobs.py. Configs are updated, the Makefile adjusted,
database permissions and users changed.

The jobs are tested elsewhere, so the script test just makes sure that
the process can start, load its config, access the database, do the query,
produce logging and finish.

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Looks fine, modulo the comment already made on skype: so long as there are some tests somewhere of the jobs running that run as the correct db user, to catch missing permissions.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2010-04-06 21:43:23 +0000
3+++ Makefile 2010-04-07 18:05:36 +0000
4@@ -203,9 +203,9 @@
5 ftest_inplace: inplace
6 bin/test -f $(TESTFLAGS) $(TESTOPTS)
7
8-mpcreationjobs:
9- # Handle merge proposal creations.
10- $(PY) cronscripts/mpcreationjobs.py
11+merge-proposal-jobs:
12+ # Handle merge proposal email jobs.
13+ $(PY) cronscripts/merge-proposal-jobs.py -v
14
15 run: inplace stop
16 $(RM) thread*.request
17@@ -249,8 +249,7 @@
18 # Scan branches from the filesystem into the database.
19 $(PY) cronscripts/scan_branches.py
20
21-
22-sync_branches: pull_branches scan_branches mpcreationjobs
23+sync_branches: pull_branches scan_branches merge-proposal-jobs
24
25 $(BZR_VERSION_INFO):
26 scripts/update-bzr-version-info.sh
27
28=== modified file 'configs/development/launchpad-lazr.conf'
29--- configs/development/launchpad-lazr.conf 2010-04-06 13:25:20 +0000
30+++ configs/development/launchpad-lazr.conf 2010-04-07 18:05:36 +0000
31@@ -196,9 +196,9 @@
32 port: 11217
33 memory_size: 1
34
35-[mpcreationjobs]
36+[merge_proposal_jobs]
37 error_dir: /var/tmp/codehosting.test
38-oops_prefix: DMPCR
39+oops_prefix: DMPJ
40
41 [personalpackagearchive]
42 root: /var/tmp/ppa/
43
44=== modified file 'configs/testrunner/launchpad-lazr.conf'
45--- configs/testrunner/launchpad-lazr.conf 2010-03-30 17:25:52 +0000
46+++ configs/testrunner/launchpad-lazr.conf 2010-04-07 18:05:36 +0000
47@@ -172,12 +172,8 @@
48 # processes spawned through some other mechanism.
49 port: 11242
50
51-[mpcreationjobs]
52-oops_prefix: TMPCJ
53-error_dir: /var/tmp/codehosting.test
54-
55-[update_preview_diffs]
56-oops_prefix: TUPD
57+[merge_proposal_jobs]
58+oops_prefix: TMPJ
59 error_dir: /var/tmp/codehosting.test
60
61 [upgrade_branches]
62
63=== renamed file 'cronscripts/mpcreationjobs.py' => 'cronscripts/merge-proposal-jobs.py'
64--- cronscripts/mpcreationjobs.py 2010-02-16 15:25:52 +0000
65+++ cronscripts/merge-proposal-jobs.py 2010-04-07 18:05:36 +0000
66@@ -1,48 +1,40 @@
67 #!/usr/bin/python2.5 -S
68 #
69-# Copyright 2009 Canonical Ltd. This software is licensed under the
70+# Copyright 2009, 2010 Canonical Ltd. This software is licensed under the
71 # GNU Affero General Public License version 3 (see the file LICENSE).
72
73 # pylint: disable-msg=W0403
74
75-"""Handle new BranchMergeProposals.
76+"""Handle jobs for BranchMergeProposals.
77
78-This script generates a diff for the merge proposal if needed, then notifies
79-all interested parties about the merge proposal.
80+This script handles all job types for branch merge proposals.
81 """
82
83 __metaclass__ = type
84
85 import _pythonpath
86-from zope.component import getUtility
87
88-from canonical.config import config
89-from lp.codehosting.vfs import get_scanner_server
90-from lp.services.job.runner import JobRunner
91+# The following line is a horrible hack, but unfortunately necessary right now
92+# to stop import errors from circular imports.
93+import canonical.launchpad.interfaces
94 from lp.code.interfaces.branchmergeproposal import (
95- IMergeProposalCreatedJobSource,)
96-from lp.services.scripts.base import LaunchpadCronScript
97-from canonical.launchpad.webapp.errorlog import globalErrorUtility
98-
99-
100-class RunMergeProposalCreatedJobs(LaunchpadCronScript):
101- """Run merge proposal creation jobs."""
102-
103- def main(self):
104- globalErrorUtility.configure('mpcreationjobs')
105- job_source = getUtility(IMergeProposalCreatedJobSource)
106- runner = JobRunner.fromReady(job_source, self.logger)
107- server = get_scanner_server()
108- server.start_server()
109- try:
110- runner.runAll()
111- finally:
112- server.stop_server()
113- self.logger.info(
114- 'Ran %d MergeProposalCreatedJobs.', len(runner.completed_jobs))
115+ IBranchMergeProposalJobSource,
116+ )
117+from lp.services.job.runner import JobCronScript, TwistedJobRunner
118+
119+
120+class RunMergeProposalJobs(JobCronScript):
121+ """Run all merge proposal jobs."""
122+
123+ config_name = 'merge_proposal_jobs'
124+ source_interface = IBranchMergeProposalJobSource
125+
126+ def __init__(self):
127+ super(RunMergeProposalJobs, self).__init__(
128+ runner_class=TwistedJobRunner,
129+ script_name='merge-proposal-jobs')
130
131
132 if __name__ == '__main__':
133- script = RunMergeProposalCreatedJobs(
134- 'mpcreationjobs', config.mpcreationjobs.dbuser)
135+ script = RunMergeProposalJobs()
136 script.lock_and_run()
137
138=== removed file 'cronscripts/update_preview_diffs.py'
139--- cronscripts/update_preview_diffs.py 2010-02-16 15:25:52 +0000
140+++ cronscripts/update_preview_diffs.py 1970-01-01 00:00:00 +0000
141@@ -1,38 +0,0 @@
142-#!/usr/bin/python2.5 -S
143-#
144-# Copyright 2009 Canonical Ltd. This software is licensed under the
145-# GNU Affero General Public License version 3 (see the file LICENSE).
146-
147-# pylint: disable-msg=W0403
148-
149-"""Update or create previews diffs for branch merge proposals."""
150-
151-__metaclass__ = type
152-
153-import _pythonpath
154-
155-from lp.services.job.runner import JobCronScript, JobRunner, TwistedJobRunner
156-from lp.code.interfaces.branchmergeproposal import (
157- IUpdatePreviewDiffJobSource,)
158-
159-
160-class RunUpdatePreviewDiffJobs(JobCronScript):
161- """Run UpdatePreviewDiff jobs."""
162-
163- config_name = 'update_preview_diffs'
164- source_interface = IUpdatePreviewDiffJobSource
165-
166- def __init__(self):
167- super(RunUpdatePreviewDiffJobs, self).__init__()
168- if self.options.twisted:
169- self.runner_class = TwistedJobRunner
170- else:
171- self.runner_class = JobRunner
172-
173- def add_my_options(self):
174- self.parser.add_option('--twisted', action='store_true')
175-
176-
177-if __name__ == '__main__':
178- script = RunUpdatePreviewDiffJobs()
179- script.lock_and_run()
180
181=== modified file 'database/schema/security.cfg'
182--- database/schema/security.cfg 2010-04-05 12:44:46 +0000
183+++ database/schema/security.cfg 2010-04-07 18:05:36 +0000
184@@ -1682,7 +1682,7 @@
185 public.teamparticipation = SELECT
186 public.validpersoncache = SELECT
187
188-[mp-creation-job]
189+[merge-proposal-jobs]
190 type=user
191 groups=script
192 public.account = SELECT
193@@ -1719,18 +1719,6 @@
194 public.teamparticipation = SELECT
195 public.validpersoncache = SELECT
196
197-[update-preview-diffs]
198-type=user
199-groups=script
200-public.branch = SELECT
201-public.branchmergeproposal = SELECT, UPDATE
202-public.branchmergeproposaljob = SELECT
203-public.diff = SELECT, INSERT
204-public.job = SELECT, UPDATE
205-public.libraryfilealias = SELECT, INSERT
206-public.libraryfilecontent = SELECT, INSERT
207-public.previewdiff = SELECT, INSERT
208-
209 [upgrade-branches]
210 type=user
211 groups=script
212
213=== modified file 'lib/canonical/config/schema-lazr.conf'
214--- lib/canonical/config/schema-lazr.conf 2010-04-07 18:05:11 +0000
215+++ lib/canonical/config/schema-lazr.conf 2010-04-07 18:05:36 +0000
216@@ -1412,10 +1412,10 @@
217 port: 11217
218
219
220-[mpcreationjobs]
221+[merge_proposal_jobs]
222 # The database user which will be used by this process.
223 # datatype: string
224-dbuser: mp-creation-job
225+dbuser: merge-proposal-jobs
226 storm_cache: generational
227 storm_cache_size: 500
228
229@@ -1428,18 +1428,6 @@
230 # See [error_reports].
231 copy_to_zlog: false
232
233-[update_preview_diffs]
234-dbuser: update-preview-diffs
235-
236-# See [error_reports].
237-error_dir: none
238-
239-# See [error_reports].
240-oops_prefix: none
241-
242-# See [error_reports].
243-copy_to_zlog: false
244-
245 [upgrade_branches]
246 dbuser: upgrade-branches
247
248
249=== modified file 'lib/canonical/launchpad/doc/product-update-remote-product-script.txt'
250--- lib/canonical/launchpad/doc/product-update-remote-product-script.txt 2009-03-27 03:29:31 +0000
251+++ lib/canonical/launchpad/doc/product-update-remote-product-script.txt 2010-04-07 18:05:36 +0000
252@@ -14,7 +14,7 @@
253 0
254
255 >>> print err
256- INFO creating lockfile
257+ INFO Creating lockfile: /var/lock/launchpad-updateremoteproduct.lock
258 INFO 0 projects using BUGZILLA needing updating.
259 ...
260 INFO 0 projects using RT needing updating.
261
262=== modified file 'lib/lp/answers/doc/expiration.txt'
263--- lib/lp/answers/doc/expiration.txt 2009-07-23 17:49:31 +0000
264+++ lib/lp/answers/doc/expiration.txt 2010-04-07 18:05:36 +0000
265@@ -132,7 +132,7 @@
266 ... stderr=subprocess.PIPE)
267 >>> (out, err) = process.communicate()
268 >>> print err
269- INFO creating lockfile
270+ INFO Creating lockfile: /var/lock/launchpad-expire-questions.lock
271 INFO Expiring OPEN and NEEDSINFO questions without activity for the
272 last 15 days.
273 INFO Found 5 questions to expire.
274
275=== modified file 'lib/lp/bugs/doc/bugnotification-sending.txt'
276--- lib/lp/bugs/doc/bugnotification-sending.txt 2009-12-24 01:41:54 +0000
277+++ lib/lp/bugs/doc/bugnotification-sending.txt 2010-04-07 18:05:36 +0000
278@@ -984,7 +984,7 @@
279 >>> process.returncode
280 0
281 >>> print err
282- INFO creating lockfile
283+ INFO Creating lockfile: /var/lock/launchpad-send-bug-notifications.lock
284 INFO Notifying mark@example.com about bug 2.
285 ...
286 INFO Notifying support@ubuntu.com about bug 2.
287
288=== modified file 'lib/lp/bugs/doc/bugtask-expiration.txt'
289--- lib/lp/bugs/doc/bugtask-expiration.txt 2009-06-12 16:36:02 +0000
290+++ lib/lp/bugs/doc/bugtask-expiration.txt 2010-04-07 18:05:36 +0000
291@@ -445,7 +445,7 @@
292 ... stderr=subprocess.PIPE)
293 >>> (out, err) = process.communicate()
294 >>> print err
295- INFO creating lockfile
296+ INFO Creating lockfile: /var/lock/launchpad-expire-bugtasks.lock
297 INFO Expiring unattended, INCOMPLETE bugtasks older than
298 60 days for projects that use Launchpad Bugs.
299 INFO Found 3 bugtasks to expire.
300
301=== modified file 'lib/lp/bugs/doc/bugtask.txt'
302--- lib/lp/bugs/doc/bugtask.txt 2010-01-21 17:40:23 +0000
303+++ lib/lp/bugs/doc/bugtask.txt 2010-04-07 18:05:36 +0000
304@@ -1104,7 +1104,7 @@
305 >>> (out, err) = process.communicate()
306
307 >>> print err
308- INFO creating lockfile
309+ INFO Creating lockfile: /var/lock/launchpad-launchpad-targetnamecacheupdater.lock
310 INFO Updating targetname cache of bugtasks.
311 INFO Updating 1 BugTasks (starting id: 2).
312 INFO Updating ...BugTasks...
313
314=== modified file 'lib/lp/bugs/doc/checkwatches.txt'
315--- lib/lp/bugs/doc/checkwatches.txt 2010-03-30 17:25:52 +0000
316+++ lib/lp/bugs/doc/checkwatches.txt 2010-04-07 18:05:36 +0000
317@@ -44,7 +44,7 @@
318 0
319
320 >>> print err
321- INFO creating lockfile
322+ INFO Creating lockfile: /var/lock/launchpad-checkwatches.lock
323 DEBUG Using a global batch size of None
324 DEBUG Skipping updating Ubuntu Bugzilla watches.
325 DEBUG No watches to update on http://bugs.debian.org
326
327=== modified file 'lib/lp/bugs/doc/cve-update.txt'
328--- lib/lp/bugs/doc/cve-update.txt 2009-06-12 16:36:02 +0000
329+++ lib/lp/bugs/doc/cve-update.txt 2010-04-07 18:05:36 +0000
330@@ -37,7 +37,7 @@
331 ... )
332 >>> (output, empty) = process.communicate()
333 >>> print output
334- INFO creating lockfile
335+ INFO Creating lockfile: /var/lock/launchpad-updatecve.lock
336 ...
337 INFO CVE-1999-0002 created
338 INFO Creating new SGI reference for 1999-0002
339@@ -91,7 +91,7 @@
340 ... )
341 >>> (output, empty) = process.communicate()
342 >>> print output
343- INFO creating lockfile
344+ INFO Creating lockfile: /var/lock/launchpad-updatecve.lock
345 ...
346 INFO Creating new CERT reference for 1999-0002
347 INFO Creating new CIAC reference for 1999-0002
348
349=== modified file 'lib/lp/bugs/tests/test_apportjob.py'
350--- lib/lp/bugs/tests/test_apportjob.py 2010-02-26 11:48:40 +0000
351+++ lib/lp/bugs/tests/test_apportjob.py 2010-04-07 18:05:36 +0000
352@@ -272,7 +272,7 @@
353 expect_returncode=0)
354 self.assertEqual('', stdout)
355 self.assertIn(
356- 'INFO Ran 1 IProcessApportBlobJobSource jobs.\n', stderr)
357+ 'INFO Ran 1 ProcessApportBlobJob jobs.\n', stderr)
358
359 def test_getFileBugData(self):
360 # The IProcessApportBlobJobSource.getFileBugData() method
361
362=== modified file 'lib/lp/bugs/tests/test_bugheat.py'
363--- lib/lp/bugs/tests/test_bugheat.py 2010-02-25 21:37:02 +0000
364+++ lib/lp/bugs/tests/test_bugheat.py 2010-04-07 18:05:36 +0000
365@@ -96,7 +96,7 @@
366 expect_returncode=0)
367 self.assertEqual('', stdout)
368 self.assertIn(
369- 'INFO Ran 1 ICalculateBugHeatJobSource jobs.\n', stderr)
370+ 'INFO Ran 1 CalculateBugHeatJob jobs.\n', stderr)
371
372 def test_getOopsVars(self):
373 # BugJobDerived.getOopsVars() returns the variables to be used
374
375=== modified file 'lib/lp/code/doc/branch-merge-proposal-notifications.txt'
376--- lib/lp/code/doc/branch-merge-proposal-notifications.txt 2010-02-19 02:15:27 +0000
377+++ lib/lp/code/doc/branch-merge-proposal-notifications.txt 2010-04-07 18:05:36 +0000
378@@ -15,7 +15,7 @@
379 ... BranchSubscriptionDiffSize, BranchSubscriptionNotificationLevel,
380 ... CodeReviewNotificationLevel)
381 >>> from lp.code.interfaces.branchmergeproposal import (
382- ... IMergeProposalCreatedJobSource)
383+ ... IBranchMergeProposalJobSource)
384 >>> from lp.code.model.diff import PreviewDiff
385 >>> from lp.testing.mail_helpers import pop_notifications
386 >>> import transaction
387@@ -103,8 +103,11 @@
388 >>> bmp = source_branch.addLandingTarget(
389 ... registrant, target_branch)
390 >>> removeSecurityProxy(bmp).preview_diff = preview_diff
391- >>> [job,] = list(getUtility(IMergeProposalCreatedJobSource).iterReady())
392- >>> job.run(_create_preview=False)
393+ >>> # Fake the update preview diff as done.
394+ >>> bmp.next_preview_diff_job.start()
395+ >>> bmp.next_preview_diff_job.complete()
396+ >>> [job] = list(getUtility(IBranchMergeProposalJobSource).iterReady())
397+ >>> job.run()
398 >>> notifications = pop_notifications(
399 ... sort_key=lambda n: n.get('X-Envelope-To'))
400
401@@ -155,8 +158,11 @@
402 ... registrant, target_branch,
403 ... description=initial_comment, review_requests=reviewers)
404 >>> removeSecurityProxy(bmp).preview_diff = preview_diff
405- >>> [job,] = list(getUtility(IMergeProposalCreatedJobSource).iterReady())
406- >>> job.run(_create_preview=False)
407+ >>> # Fake the update preview diff as done.
408+ >>> bmp.next_preview_diff_job.start()
409+ >>> bmp.next_preview_diff_job.complete()
410+ >>> [job] = list(getUtility(IBranchMergeProposalJobSource).iterReady())
411+ >>> job.run()
412 >>> notifications = pop_notifications(
413 ... sort_key=lambda n: n.get('X-Envelope-To'))
414 >>> for notification in notifications:
415
416=== modified file 'lib/lp/code/doc/codereviewcomment.txt'
417--- lib/lp/code/doc/codereviewcomment.txt 2010-04-07 18:05:11 +0000
418+++ lib/lp/code/doc/codereviewcomment.txt 2010-04-07 18:05:36 +0000
419@@ -48,19 +48,11 @@
420 When comments are added, a job is created to send the emails to the
421 subscribers of the merge proposal.
422
423- >>> from lp.code.interfaces.branchmergeproposal import (
424- ... ICodeReviewCommentEmailJobSource)
425 >>> # Needed for now to make the iterReady show the jobs.
426 >>> factory.makeRevisionsForBranch(merge_proposal.source_branch)
427- >>> jobs = list(getUtility(ICodeReviewCommentEmailJobSource).iterReady())
428- >>> print len(jobs)
429- 3
430-
431-Since we don't care about these, let's mark them as done.
432-
433- >>> for job in jobs:
434- ... job.start()
435- ... job.complete()
436+ >>> factory.makeRevisionsForBranch(merge_proposal.target_branch)
437+ >>> from lp.code.tests.helpers import mark_all_merge_proposal_jobs_done
438+ >>> mark_all_merge_proposal_jobs_done()
439
440 If there is a subscriber to any of the branches involved in the merge,
441 a notification is produced when the comment is created.
442@@ -84,7 +76,9 @@
443
444 Now run the pending job to send the email.
445
446- >>> [job] = list(getUtility(ICodeReviewCommentEmailJobSource).iterReady())
447+ >>> from lp.code.interfaces.branchmergeproposal import (
448+ ... IBranchMergeProposalJobSource)
449+ >>> [job] = list(getUtility(IBranchMergeProposalJobSource).iterReady())
450 >>> job.run()
451
452 >>> notifications = pop_notifications()
453
454=== modified file 'lib/lp/code/interfaces/branchmergeproposal.py'
455--- lib/lp/code/interfaces/branchmergeproposal.py 2010-04-07 18:05:11 +0000
456+++ lib/lp/code/interfaces/branchmergeproposal.py 2010-04-07 18:05:36 +0000
457@@ -583,7 +583,7 @@
458 """
459
460
461-class ICreateMergeProposalJobSource(Interface):
462+class ICreateMergeProposalJobSource(IJobSource):
463 """Acquire MergeProposalJobs."""
464
465 def create(message_bytes):
466@@ -635,7 +635,7 @@
467 """Interface for the job to sends review request emails."""
468
469 reviewer = Attribute('The person or team asked to do the review.')
470- requester = Attribute('The person who as asked for the review.')
471+ requester = Attribute('The person who has asked for the review.')
472
473
474 class IReviewRequestedEmailJobSource(Interface):
475@@ -652,7 +652,8 @@
476 """Interface for the job to sends email about merge proposal updates."""
477
478 editor = Attribute('The person that did the editing.')
479- delta_text = Attribute('The textual representation of the changed fields.')
480+ delta_text = Attribute(
481+ 'The textual representation of the changed fields.')
482
483
484 class IMergeProposalUpdatedEmailJobSource(Interface):
485
486=== modified file 'lib/lp/code/mail/branch.py'
487--- lib/lp/code/mail/branch.py 2010-04-07 18:05:11 +0000
488+++ lib/lp/code/mail/branch.py 2010-04-07 18:05:36 +0000
489@@ -92,7 +92,6 @@
490
491 The registrant will be the sole recipient.
492 """
493- branch = merge_proposal.source_branch
494 reason_template = 'You proposed %(branch_name)s for merging.'
495 return cls(merge_proposal.registrant, merge_proposal.registrant,
496 merge_proposal.source_branch,
497
498=== modified file 'lib/lp/code/mail/tests/test_branchmergeproposal.py'
499--- lib/lp/code/mail/tests/test_branchmergeproposal.py 2010-04-07 18:05:11 +0000
500+++ lib/lp/code/mail/tests/test_branchmergeproposal.py 2010-04-07 18:05:36 +0000
501@@ -4,9 +4,10 @@
502 """Tests for BranchMergeProposal mailings"""
503
504 from difflib import unified_diff
505-from unittest import TestLoader
506+import operator
507 from textwrap import dedent
508 import transaction
509+from unittest import TestLoader
510
511 from zope.security.proxy import removeSecurityProxy
512
513@@ -339,7 +340,8 @@
514 job, subscriber = self.makeProposalUpdatedEmailJob()
515 pop_notifications()
516 job.run()
517- emails = pop_notifications()
518+ emails = pop_notifications(
519+ sort_key=operator.itemgetter('x-launchpad-message-rationale'))
520 self.assertEqual(3, len(emails),
521 'There should be three emails sent out. One to the '
522 'explicit subscriber above, and one each to the '
523@@ -349,7 +351,7 @@
524 self.assertEqual('[Merge] '
525 'lp://dev/~bob/super-product/fix-foo-for-bar into\n\t'
526 'lp://dev/~mary/super-product/bar', email['subject'])
527- self.assertEqual(dedent("""\
528+ expected = dedent("""\
529 The proposal to merge lp://dev/~bob/super-product/fix-foo-for-bar into lp://dev/~mary/super-product/bar has been updated.
530
531 Status: Work in progress => Needs review
532@@ -363,9 +365,9 @@
533 change description
534 --\x20
535 %s
536- You are subscribed to branch lp://dev/~bob/super-product/fix-foo-for-bar.
537- """) % canonical_url(job.branch_merge_proposal),
538- email.get_payload(decode=True))
539+ You are the owner of lp://dev/~bob/super-product/fix-foo-for-bar.
540+ """) % canonical_url(job.branch_merge_proposal)
541+ self.assertEqual(expected, email.get_payload(decode=True))
542
543 def assertRecipientsMatches(self, recipients, mailer):
544 """Assert that `mailer` will send to the people in `recipients`."""
545@@ -468,8 +470,7 @@
546 review_request_job = self.getReviewNotificationEmail()
547 review_request_job.run()
548 [sent_mail] = pop_notifications()
549- self.assertEqual(
550- dedent("""\
551+ expected = dedent("""\
552 You have been requested to review the proposed merge of %(source)s into %(target)s.
553
554 This branch is awesome.
555@@ -480,8 +481,8 @@
556 """ % {
557 'source': self.bmp.source_branch.bzr_identity,
558 'target': self.bmp.target_branch.bzr_identity,
559- 'bmp': canonical_url(self.bmp)}),
560- sent_mail.get_payload(decode=True))
561+ 'bmp': canonical_url(self.bmp)})
562+ self.assertEqual(expected, sent_mail.get_payload(decode=True))
563
564 def test_nominateReview_emails_team_address(self):
565 # If a review request is made for a team, the members of the team are
566
567=== modified file 'lib/lp/code/mail/tests/test_codehandler.py'
568--- lib/lp/code/mail/tests/test_codehandler.py 2010-04-07 18:05:11 +0000
569+++ lib/lp/code/mail/tests/test_codehandler.py 2010-04-07 18:05:36 +0000
570@@ -27,7 +27,6 @@
571 from canonical.launchpad.interfaces.mail import (
572 EmailProcessingError, IWeaklyAuthenticatedPrincipal)
573 from canonical.launchpad.mail.handlers import mail_handlers
574-from canonical.launchpad.webapp import canonical_url
575 from canonical.launchpad.webapp.authorization import LaunchpadSecurityPolicy
576 from canonical.launchpad.webapp.interaction import (
577 get_current_principal, setupInteraction)
578@@ -158,7 +157,7 @@
579 self.assertTrue(self.code_handler.process(
580 mail, email_addr, None), "Succeeded, but didn't return True")
581 # if the message has not been created, this raises SQLObjectNotFound
582- message = MessageSet().get('<my-id>')
583+ MessageSet().get('<my-id>')
584
585 def test_process_packagebranch(self):
586 """Processing an email related to a package branch works.."""
587@@ -407,7 +406,7 @@
588 md = self.factory.makeMergeDirective(
589 source_branch_url=source_branch_url, target_branch=target_branch)
590 submitter = self.factory.makePerson()
591- duplicate_branch = self.factory.makeProductBranch(
592+ self.factory.makeProductBranch(
593 product=target_branch.product, name='suffix', owner=submitter)
594 self.switchDbUser(config.create_merge_proposals.dbuser)
595 mp_source, mp_target = self.code_handler._acquireBranchesForProposal(
596@@ -488,7 +487,6 @@
597
598 MissingMergeDirective is raised when no merge directive is present.
599 """
600- md = self.factory.makeMergeDirective()
601 message = self.factory.makeSignedMessage(body='Hi!\n')
602 self.switchDbUser(config.processmail.dbuser)
603 code_handler = CodeHandler()
604@@ -683,10 +681,10 @@
605 self.factory.makeMergeDirectiveEmail())
606 self.switchDbUser(config.create_merge_proposals.dbuser)
607 code_handler = CodeHandler()
608- bmp = code_handler.processMergeProposal(message)
609- _unused = pop_notifications()
610+ code_handler.processMergeProposal(message)
611+ pop_notifications()
612 transaction.commit()
613- _unused = code_handler.processMergeProposal(message)
614+ code_handler.processMergeProposal(message)
615 [notification] = pop_notifications()
616 self.assertEqual(
617 notification['Subject'], 'Error Creating Merge Proposal')
618@@ -757,8 +755,8 @@
619 """If an LP URL is provided, we attempt to reproduce it exactly."""
620 submitter = self.factory.makePerson(name='merge-submitter')
621 target = self.makeTargetBranch()
622- url_product = self.factory.makeProduct('uproduct')
623- url_person = self.factory.makePerson(name='uuser')
624+ self.factory.makeProduct('uproduct')
625+ self.factory.makePerson(name='uuser')
626 code_handler = CodeHandler()
627 namespace, base = code_handler._getNewBranchInfo(
628 config.codehosting.supermirror_root + '~uuser/uproduct/bar',
629@@ -770,8 +768,8 @@
630 """Trailing slashes are permitted in LP URLs."""
631 submitter = self.factory.makePerson(name='merge-submitter')
632 target = self.makeTargetBranch()
633- url_product = self.factory.makeProduct('uproduct')
634- url_person = self.factory.makePerson(name='uuser')
635+ self.factory.makeProduct('uproduct')
636+ self.factory.makePerson(name='uuser')
637 code_handler = CodeHandler()
638 namespace, base = code_handler._getNewBranchInfo(
639 config.codehosting.supermirror_root + '~uuser/uproduct/bar/',
640@@ -812,7 +810,7 @@
641 body=' review abstain',
642 subject='')
643 bmp = self.factory.makeBranchMergeProposal()
644- _unused = pop_notifications()
645+ pop_notifications()
646 email_addr = bmp.address
647 self.switchDbUser(config.processmail.dbuser)
648 self.code_handler.process(mail, email_addr, None)
649@@ -955,7 +953,7 @@
650 format="1.9")
651 bmp = self._processMergeDirective(message)
652 # The hosted location should be populated (open succeeds).
653- source_bzr_branch = self._openBazaarBranchAsClient(bmp.source_branch)
654+ self._openBazaarBranchAsClient(bmp.source_branch)
655 # Not the mirror (open raises).
656 self.assertRaises(
657 bzr_errors.NotBranchError, Branch.open,
658
659=== modified file 'lib/lp/code/mail/tests/test_codereviewcomment.py'
660--- lib/lp/code/mail/tests/test_codereviewcomment.py 2010-04-07 18:05:11 +0000
661+++ lib/lp/code/mail/tests/test_codereviewcomment.py 2010-04-07 18:05:36 +0000
662@@ -18,7 +18,7 @@
663 BranchSubscriptionNotificationLevel, CodeReviewNotificationLevel,
664 CodeReviewVote)
665 from lp.code.mail.codereviewcomment import CodeReviewCommentMailer
666-from lp.testing import ANONYMOUS, login, login_person, TestCaseWithFactory
667+from lp.testing import login, login_person, TestCaseWithFactory
668
669
670 class TestCodeReviewComment(TestCaseWithFactory):
671
672=== modified file 'lib/lp/code/model/branchmergeproposal.py'
673--- lib/lp/code/model/branchmergeproposal.py 2010-04-07 18:05:11 +0000
674+++ lib/lp/code/model/branchmergeproposal.py 2010-04-07 18:05:36 +0000
675@@ -141,21 +141,18 @@
676 def next_preview_diff_job(self):
677 # circular dependencies
678 from lp.code.model.branchmergeproposaljob import (
679- BranchMergeProposalJob, MergeProposalCreatedJob,
680- UpdatePreviewDiffJob)
681- job_classes = [MergeProposalCreatedJob, UpdatePreviewDiffJob]
682- type_classes = dict(
683- (job_class.class_job_type, job_class)
684- for job_class in job_classes)
685+ BranchMergeProposalJob, BranchMergeProposalJobFactory,
686+ BranchMergeProposalJobType)
687 job = Store.of(self).find(
688 BranchMergeProposalJob,
689 BranchMergeProposalJob.branch_merge_proposal == self,
690- BranchMergeProposalJob.job_type.is_in(type_classes.keys()),
691+ BranchMergeProposalJob.job_type ==
692+ BranchMergeProposalJobType.UPDATE_PREVIEW_DIFF,
693 BranchMergeProposalJob.job == Job.id,
694 Job._status.is_in([JobStatus.WAITING, JobStatus.RUNNING])
695 ).order_by(Job.scheduled_start, Job.date_created).first()
696 if job is not None:
697- return type_classes[job.job_type](job)
698+ return BranchMergeProposalJobFactory.create(job)
699 else:
700 return None
701
702@@ -620,7 +617,7 @@
703 message = Message(
704 parent=parent_message, owner=owner, rfc822msgid=msgid,
705 subject=subject, datecreated=_date_created)
706- chunk = MessageChunk(message=message, content=content, sequence=1)
707+ MessageChunk(message=message, content=content, sequence=1)
708 return self.createCommentFromMessage(
709 message, vote, review_type, original_email=None,
710 _notify_listeners=_notify_listeners, _validate=False)
711
712=== modified file 'lib/lp/code/model/branchmergeproposaljob.py'
713--- lib/lp/code/model/branchmergeproposaljob.py 2010-04-07 18:05:11 +0000
714+++ lib/lp/code/model/branchmergeproposaljob.py 2010-04-07 18:05:36 +0000
715@@ -17,7 +17,9 @@
716
717 __all__ = [
718 'BranchMergeProposalJob',
719+ 'BranchMergeProposalJobFactory',
720 'BranchMergeProposalJobSource',
721+ 'BranchMergeProposalJobType',
722 'CodeReviewCommentEmailJob',
723 'CreateMergeProposalJob',
724 'MergeProposalCreatedJob',
725
726=== modified file 'lib/lp/code/model/tests/test_branchcloud.py'
727--- lib/lp/code/model/tests/test_branchcloud.py 2009-06-30 16:56:07 +0000
728+++ lib/lp/code/model/tests/test_branchcloud.py 2010-04-07 18:05:36 +0000
729@@ -55,9 +55,10 @@
730 date_generator = time_counter(start_date, delta)
731 branch = self.factory.makeProductBranch(
732 product=product, branch_type=branch_type, private=private)
733- self.factory.makeRevisionsForBranch(
734- removeSecurityProxy(branch), count=revision_count,
735- date_generator=date_generator)
736+ if branch_type != BranchType.REMOTE:
737+ self.factory.makeRevisionsForBranch(
738+ removeSecurityProxy(branch), count=revision_count,
739+ date_generator=date_generator)
740 return branch
741
742 def test_empty_with_no_branches(self):
743
744=== modified file 'lib/lp/code/model/tests/test_branchmergeproposaljobs.py'
745--- lib/lp/code/model/tests/test_branchmergeproposaljobs.py 2010-04-07 18:05:11 +0000
746+++ lib/lp/code/model/tests/test_branchmergeproposaljobs.py 2010-04-07 18:05:36 +0000
747@@ -87,33 +87,6 @@
748 verifyObject(IMergeProposalCreatedJob, job)
749 verifyObject(IBranchMergeProposalJob, job)
750
751- def test_run_makes_diff(self):
752- """MergeProposalCreationJob.run creates a diff."""
753- self.useBzrBranches()
754- target, target_tree = self.create_branch_and_tree('target')
755- target_tree.bzrdir.root_transport.put_bytes('foo', 'foo\n')
756- target_tree.add('foo')
757- rev1 = target_tree.commit('added foo')
758- source, source_tree = self.create_branch_and_tree('source')
759- source_tree.pull(target_tree.branch, stop_revision=rev1)
760- source_tree.bzrdir.root_transport.put_bytes('foo', 'foo\nbar\n')
761- source_tree.commit('added bar')
762- target_tree.merge_from_branch(source_tree.branch)
763- target_tree.commit('merged from source')
764- source_tree.bzrdir.root_transport.put_bytes('foo', 'foo\nbar\nqux\n')
765- source_tree.commit('added qux')
766- bmp = self.factory.makeBranchMergeProposal(
767- source_branch=source, target_branch=target,
768- registrant=source.owner)
769- job = MergeProposalCreatedJob.create(bmp)
770- transaction.commit()
771- self.layer.switchDbUser(config.merge_proposal_jobs.dbuser)
772- job.run()
773- self.assertIs(None, bmp.review_diff)
774- self.assertIsNot(None, bmp.preview_diff)
775- transaction.commit()
776- self.checkDiff(bmp.preview_diff)
777-
778 def checkDiff(self, diff):
779 self.assertNotIn('+bar', diff.diff.text)
780 self.assertIn('+qux', diff.diff.text)
781@@ -174,12 +147,12 @@
782 def test_run(self):
783 self.useBzrBranches()
784 bmp = self.createExampleMerge()[0]
785- UpdatePreviewDiffJob.create(bmp)
786+ job = UpdatePreviewDiffJob.create(bmp)
787 self.factory.makeRevisionsForBranch(bmp.source_branch, count=1)
788 bmp.source_branch.next_mirror_time = None
789 transaction.commit()
790 self.layer.switchDbUser(config.merge_proposal_jobs.dbuser)
791- JobRunner.fromReady(UpdatePreviewDiffJob).runAll()
792+ JobRunner([job]).runAll()
793 transaction.commit()
794 self.checkExampleMerge(bmp.preview_diff.text)
795
796@@ -205,6 +178,14 @@
797 'The source branch has no revisions.',
798 email.get_payload(decode=True))
799
800+ def test_10_minute_lease(self):
801+ self.useBzrBranches()
802+ bmp = self.createExampleMerge()[0]
803+ job = UpdatePreviewDiffJob.create(bmp)
804+ job.acquireLease()
805+ expiry_delta = job.lease_expires - datetime.now(pytz.UTC)
806+ self.assertTrue(500 <= expiry_delta.seconds, expiry_delta)
807+
808
809 class TestBranchMergeProposalJobSource(TestCaseWithFactory):
810
811
812=== modified file 'lib/lp/code/model/tests/test_branchmergeproposals.py'
813--- lib/lp/code/model/tests/test_branchmergeproposals.py 2010-04-07 18:05:11 +0000
814+++ lib/lp/code/model/tests/test_branchmergeproposals.py 2010-04-07 18:05:36 +0000
815@@ -49,13 +49,7 @@
816 BranchMergeProposalGetter, is_valid_transition)
817 from lp.registry.interfaces.person import IPersonSet
818 from lp.registry.interfaces.product import IProductSet
819-<<<<<<< TREE
820-from lp.services.job.runner import JobRunner
821-from lp.testing import (
822- capture_events, login_person, TestCaseWithFactory)
823-=======
824 from lp.testing import login_person, TestCaseWithFactory
825->>>>>>> MERGE-SOURCE
826 from lp.testing.factory import GPGSigningContext, LaunchpadObjectFactory
827
828
829@@ -176,7 +170,7 @@
830 proposal.superseded_by.rejectBranch(self.target_branch.owner,
831 None)
832 self.assertProposalState(proposal, from_state)
833- dupe = self.factory.makeBranchMergeProposal(
834+ self.factory.makeBranchMergeProposal(
835 target_branch=proposal.target_branch,
836 source_branch=proposal.source_branch)
837 return proposal
838@@ -972,11 +966,10 @@
839 # participant.
840 wally = self.factory.makePerson(name='wally')
841 beaver = self.factory.makePerson(name='beaver')
842- name12 = getUtility(IPersonSet).getByName('name12')
843
844 bmp1 = self._make_merge_proposal('wally', 'gokart', 'turbo', True)
845 bmp1.nominateReviewer(beaver, wally)
846- bmp2 = self._make_merge_proposal('beaver', 'gokart', 'brakes', True)
847+ self._make_merge_proposal('beaver', 'gokart', 'brakes', True)
848
849 getter = BranchMergeProposalGetter
850 wally_proposals = getter.getProposalsForParticipant(
851@@ -1030,8 +1023,8 @@
852
853 def test_wip_for_product_restrictions(self):
854 # Check queries on product limited on status.
855- in_progress = self._make_merge_proposal('albert', 'november', 'work')
856- needs_review = self._make_merge_proposal(
857+ self._make_merge_proposal('albert', 'november', 'work')
858+ self._make_merge_proposal(
859 'bob', 'november', 'work', needs_review=True)
860 self.assertEqual(
861 ['~albert/november/work'],
862@@ -1386,7 +1379,7 @@
863 """A comment with a vote creates a vote reference."""
864 merge_proposal = self.factory.makeBranchMergeProposal()
865 reviewer = self.factory.makePerson()
866- comment = merge_proposal.createComment(
867+ merge_proposal.createComment(
868 reviewer, 'Message subject', 'Message content')
869 self.assertEqual([], list(merge_proposal.votes))
870
871@@ -1394,7 +1387,7 @@
872 """A second vote changes the comment reference only."""
873 merge_proposal = self.factory.makeBranchMergeProposal()
874 reviewer = self.factory.makePerson()
875- comment1 = merge_proposal.createComment(
876+ merge_proposal.createComment(
877 reviewer, 'Message subject', 'Message content',
878 vote=CodeReviewVote.DISAPPROVE)
879 comment2 = merge_proposal.createComment(
880@@ -1635,50 +1628,10 @@
881 removeSecurityProxy(merge_proposal.preview_diff).diff_id)
882
883
884-<<<<<<< TREE
885-class TestUpdatePreviewDiffJob(DiffTestCase):
886-
887- layer = LaunchpadZopelessLayer
888-
889- def test_implement_interface(self):
890- """UpdatePreviewDiffJob implements IUpdatePreviewDiffJobSource."""
891- verifyObject(IUpdatePreviewDiffJobSource, UpdatePreviewDiffJob)
892-
893- def test_run(self):
894- self.useBzrBranches()
895- bmp = self.createExampleMerge()[0]
896- job = UpdatePreviewDiffJob.create(bmp)
897- self.factory.makeRevisionsForBranch(bmp.source_branch, count=1)
898- bmp.source_branch.next_mirror_time = None
899- transaction.commit()
900- self.layer.switchDbUser(config.update_preview_diffs.dbuser)
901- JobRunner.fromReady(UpdatePreviewDiffJob).runAll()
902- transaction.commit()
903- self.checkExampleMerge(bmp.preview_diff.text)
904-
905- def test_10_minute_lease(self):
906- self.useBzrBranches()
907- bmp = self.createExampleMerge()[0]
908- job = UpdatePreviewDiffJob.create(bmp)
909- job.acquireLease()
910- expiry_delta = job.lease_expires - datetime.now(UTC)
911- self.assertTrue(500 <= expiry_delta.seconds, expiry_delta)
912-
913-
914-=======
915->>>>>>> MERGE-SOURCE
916 class TestNextPreviewDiffJob(TestCaseWithFactory):
917
918 layer = DatabaseFunctionalLayer
919
920- def test_returns_bmp_job(self):
921- """For new proposals, get the MergeProposalCreatedJob."""
922- bmp = self.factory.makeBranchMergeProposal()
923- job = bmp.next_preview_diff_job
924- self.assertEqual(bmp, job.branch_merge_proposal)
925- self.assertIs(
926- MergeProposalCreatedJob, removeSecurityProxy(job).__class__)
927-
928 def test_returns_none_if_job_not_pending(self):
929 """Jobs are shown while pending."""
930 bmp = self.factory.makeBranchMergeProposal()
931@@ -1702,11 +1655,11 @@
932 Store.of(updatejob.context).flush()
933 self.assertEqual(updatejob, bmp.next_preview_diff_job)
934
935- def test_returns_first__job(self):
936+ def test_returns_first_job(self):
937 """First-created job is returned."""
938 bmp = self.makeBranchMergeProposalNoPending()
939 updatejob = UpdatePreviewDiffJob.create(bmp)
940- updatejob2 = UpdatePreviewDiffJob.create(bmp)
941+ UpdatePreviewDiffJob.create(bmp)
942 self.assertEqual(updatejob, bmp.next_preview_diff_job)
943
944 def test_does_not_return_jobs_for_other_proposals(self):
945@@ -1714,7 +1667,7 @@
946 bmp = self.factory.makeBranchMergeProposal()
947 bmp.next_preview_diff_job.start()
948 bmp.next_preview_diff_job.complete()
949- bmp2 = self.factory.makeBranchMergeProposal()
950+ self.factory.makeBranchMergeProposal()
951 self.assertIs(None, bmp.next_preview_diff_job)
952
953
954
955=== modified file 'lib/lp/code/model/tests/test_diff.py'
956--- lib/lp/code/model/tests/test_diff.py 2010-02-17 19:10:51 +0000
957+++ lib/lp/code/model/tests/test_diff.py 2010-04-07 18:05:36 +0000
958@@ -55,6 +55,10 @@
959 """Create a merge proposal with conflicts and updates."""
960 self.useBzrBranches()
961 bmp = self.factory.makeBranchMergeProposal()
962+ # Make the branches of the merge proposal look good as far as the
963+ # model is concerned.
964+ self.factory.makeRevisionsForBranch(bmp.source_branch)
965+ self.factory.makeRevisionsForBranch(bmp.target_branch)
966 bzr_target = self.createBzrBranch(bmp.target_branch)
967 self.commitFile(bmp.target_branch, 'foo', 'a\n')
968 self.createBzrBranch(bmp.source_branch, bzr_target)
969
970=== modified file 'lib/lp/code/scripts/tests/test_create_merge_proposals.py'
971--- lib/lp/code/scripts/tests/test_create_merge_proposals.py 2009-10-17 14:06:03 +0000
972+++ lib/lp/code/scripts/tests/test_create_merge_proposals.py 2010-04-07 18:05:36 +0000
973@@ -40,7 +40,7 @@
974 'cronscripts/create_merge_proposals.py', [])
975 self.assertEqual(0, retcode)
976 self.assertEqual(
977- 'INFO creating lockfile\n'
978+ 'INFO Creating lockfile: /var/lock/launchpad-create_merge_proposals.lock\n'
979 'INFO Ran 1 CreateMergeProposalJobs.\n', stderr)
980 self.assertEqual('', stdout)
981 self.assertEqual(1, source.landing_targets.count())
982@@ -67,7 +67,7 @@
983 'cronscripts/create_merge_proposals.py', [])
984 self.assertEqual(0, retcode)
985 self.assertEqual(
986- 'INFO creating lockfile\n'
987+ 'INFO Creating lockfile: /var/lock/launchpad-create_merge_proposals.lock\n'
988 'INFO Ran 1 CreateMergeProposalJobs.\n', stderr)
989 self.assertEqual('', stdout)
990 # The hosted location should be populated, not the mirror.
991@@ -106,7 +106,7 @@
992 transaction.commit()
993 retcode, stdout, stderr = run_script(
994 'cronscripts/create_merge_proposals.py', [])
995- self.assertIn('INFO creating lockfile\n', stderr)
996+ self.assertIn('INFO Creating lockfile:', stderr)
997 self.assertIn('INFO Job resulted in OOPS:', stderr)
998 self.assertIn('INFO Ran 0 CreateMergeProposalJobs.\n', stderr)
999 self.assertEqual('', stdout)
1000
1001=== renamed file 'lib/lp/code/scripts/tests/test_mp_creationjob.py' => 'lib/lp/code/scripts/tests/test_merge_proposal_jobs.py'
1002--- lib/lp/code/scripts/tests/test_mp_creationjob.py 2010-01-06 14:41:45 +0000
1003+++ lib/lp/code/scripts/tests/test_merge_proposal_jobs.py 2010-04-07 18:05:36 +0000
1004@@ -6,64 +6,26 @@
1005 """Test the sendbranchmail script"""
1006
1007 import unittest
1008-import transaction
1009
1010 from canonical.testing import ZopelessAppServerLayer
1011 from lp.testing import TestCaseWithFactory
1012 from canonical.launchpad.scripts.tests import run_script
1013-from lp.code.model.branchmergeproposal import BranchMergeProposal
1014-from lp.code.model.branchmergeproposaljob import MergeProposalCreatedJob
1015-
1016-
1017-class TestDiffBMPs(TestCaseWithFactory):
1018+
1019+
1020+class TestMergeProposalJobScript(TestCaseWithFactory):
1021
1022 layer = ZopelessAppServerLayer
1023
1024- def test_mpcreationjobs(self):
1025- """Ensure mpcreationjobs runs and generates diffs."""
1026- self.useTempBzrHome()
1027- target, target_tree = self.createMirroredBranchAndTree()
1028- target_tree.bzrdir.root_transport.put_bytes('foo', 'foo\n')
1029- target_tree.add('foo')
1030- target_tree.commit('added foo')
1031- target.linkBug(self.factory.makeBug(), target.registrant)
1032- source, source_tree = self.createMirroredBranchAndTree()
1033- source_tree.pull(target_tree.branch)
1034- source_tree.bzrdir.root_transport.put_bytes('foo', 'foo\nbar\n')
1035- source_tree.commit('added bar')
1036- # Add a fake revisions so the proposal is ready.
1037- self.factory.makeRevisionsForBranch(source, count=1)
1038- source.linkBug(self.factory.makeBug(), source.registrant)
1039- bmp = BranchMergeProposal(
1040- source_branch=source, target_branch=target,
1041- registrant=source.owner)
1042- job = MergeProposalCreatedJob.create(bmp)
1043- self.assertIs(None, bmp.preview_diff)
1044- transaction.commit()
1045+ def test_script_runs(self):
1046+ """Ensure merge-proposal-jobs script runs."""
1047 retcode, stdout, stderr = run_script(
1048- 'cronscripts/mpcreationjobs.py', [])
1049+ 'cronscripts/merge-proposal-jobs.py', [])
1050 self.assertEqual(0, retcode)
1051 self.assertEqual('', stdout)
1052 self.assertEqual(
1053- 'INFO creating lockfile\n'
1054- 'INFO Ran 1 MergeProposalCreatedJobs.\n', stderr)
1055- self.assertIs(None, bmp.review_diff)
1056- self.assertIsNot(None, bmp.preview_diff)
1057-
1058- def test_mpcreationjobs_records_oops(self):
1059- """Ensure mpcreationjobs logs an oops if the job fails."""
1060- bmp = self.factory.makeBranchMergeProposal()
1061- self.factory.makeRevisionsForBranch(bmp.source_branch, count=1)
1062- job = MergeProposalCreatedJob.create(bmp)
1063- transaction.commit()
1064- retcode, stdout, stderr = run_script(
1065- 'cronscripts/mpcreationjobs.py', [])
1066- self.assertEqual(0, retcode)
1067- self.assertEqual('', stdout)
1068- self.assertIn(
1069- 'INFO Ran 0 MergeProposalCreatedJobs.\n', stderr)
1070- self.assertIn(
1071- 'INFO Job resulted in OOPS:', stderr)
1072+ 'INFO Creating lockfile:'
1073+ ' /var/lock/launchpad-merge-proposal-jobs.lock\n'
1074+ 'INFO Running through Twisted.\n', stderr)
1075
1076 def test_suite():
1077 return unittest.TestLoader().loadTestsFromName(__name__)
1078
1079=== modified file 'lib/lp/code/scripts/tests/test_reclaim_branch_space.py'
1080--- lib/lp/code/scripts/tests/test_reclaim_branch_space.py 2009-09-03 20:53:32 +0000
1081+++ lib/lp/code/scripts/tests/test_reclaim_branch_space.py 2010-04-07 18:05:36 +0000
1082@@ -43,7 +43,7 @@
1083 'cronscripts/reclaimbranchspace.py', [])
1084 self.assertEqual('', stdout)
1085 self.assertEqual(
1086- 'INFO creating lockfile\n'
1087+ 'INFO Creating lockfile: /var/lock/launchpad-reclaimbranchspace.lock\n'
1088 'INFO Reclaimed space for 0 branches.\n', stderr)
1089 self.assertEqual(0, retcode)
1090 self.assertTrue(
1091@@ -61,7 +61,7 @@
1092 'cronscripts/reclaimbranchspace.py', [])
1093 self.assertEqual('', stdout)
1094 self.assertEqual(
1095- 'INFO creating lockfile\n'
1096+ 'INFO Creating lockfile: /var/lock/launchpad-reclaimbranchspace.lock\n'
1097 'INFO Reclaimed space for 1 branches.\n', stderr)
1098 self.assertEqual(0, retcode)
1099 self.assertFalse(
1100@@ -91,8 +91,7 @@
1101 # The script will now remove the branch from disk.
1102 retcode, stdout, stderr = run_script(
1103 'cronscripts/reclaimbranchspace.py', [])
1104- self.assertEqual('', stdout)
1105- self.assertIn('INFO creating lockfile\n', stderr)
1106+ self.assertIn('INFO Creating lockfile: ', stderr)
1107 self.assertIn('INFO Job resulted in OOPS:', stderr)
1108 self.assertIn('INFO Reclaimed space for 0 branches.\n', stderr)
1109
1110
1111=== modified file 'lib/lp/code/scripts/tests/test_scan_branches.py'
1112--- lib/lp/code/scripts/tests/test_scan_branches.py 2010-01-29 19:15:05 +0000
1113+++ lib/lp/code/scripts/tests/test_scan_branches.py 2010-04-07 18:05:36 +0000
1114@@ -31,7 +31,7 @@
1115 target_tree.commit('First commit', rev_id='rev1')
1116 target_tree.commit('Second commit', rev_id='rev2')
1117 target_tree.commit('Third commit', rev_id='rev3')
1118- job = BranchScanJob.create(db_branch)
1119+ BranchScanJob.create(db_branch)
1120 transaction.commit()
1121
1122 def run_script_and_assert_success(self):
1123@@ -41,7 +41,7 @@
1124 expect_returncode=0)
1125 self.assertEqual('', stdout)
1126 self.assertIn(
1127- 'INFO Ran 1 IBranchScanJobSource jobs.\n', stderr)
1128+ 'INFO Ran 1 BranchScanJob jobs.\n', stderr)
1129
1130 def test_scan_branch(self):
1131 """Test that scan branches adds revisions to the database."""
1132
1133=== modified file 'lib/lp/code/scripts/tests/test_sendbranchmail.py'
1134--- lib/lp/code/scripts/tests/test_sendbranchmail.py 2009-10-17 14:06:03 +0000
1135+++ lib/lp/code/scripts/tests/test_sendbranchmail.py 2010-04-07 18:05:36 +0000
1136@@ -38,13 +38,14 @@
1137 """Ensure sendbranchmail runs and sends email."""
1138 self.useTempBzrHome()
1139 branch, tree = self.createBranch()
1140- job_1 = RevisionMailJob.create(
1141+ RevisionMailJob.create(
1142 branch, 1, 'from@example.org', 'body', True, 'foo')
1143 transaction.commit()
1144 retcode, stdout, stderr = run_script(
1145 'cronscripts/sendbranchmail.py', [])
1146- self.assertEqual('INFO creating lockfile\n'
1147- 'INFO Ran 1 RevisionMailJobs.\n', stderr)
1148+ self.assertEqual(
1149+ 'INFO Creating lockfile: /var/lock/launchpad-sendbranchmail.lock\n'
1150+ 'INFO Ran 1 RevisionMailJobs.\n', stderr)
1151 self.assertEqual('', stdout)
1152 self.assertEqual(0, retcode)
1153
1154@@ -52,12 +53,14 @@
1155 """Ensure sendbranchmail runs and sends email."""
1156 self.useTempBzrHome()
1157 branch = self.factory.makeBranch()
1158- job_1 = RevisionMailJob.create(
1159+ RevisionMailJob.create(
1160 branch, 1, 'from@example.org', 'body', True, 'foo')
1161 transaction.commit()
1162 retcode, stdout, stderr = run_script(
1163 'cronscripts/sendbranchmail.py', [])
1164- self.assertIn('INFO creating lockfile\n', stderr)
1165+ self.assertIn(
1166+ 'INFO Creating lockfile: /var/lock/launchpad-sendbranchmail.lock\n',
1167+ stderr)
1168 self.assertIn('INFO Job resulted in OOPS:', stderr)
1169 self.assertIn('INFO Ran 0 RevisionMailJobs.\n', stderr)
1170 self.assertEqual('', stdout)
1171@@ -69,13 +72,15 @@
1172 branch, tree = self.createBranch()
1173 tree.bzrdir.root_transport.put_bytes('foo', 'baz')
1174 tree.commit('Added foo.', rev_id='rev2')
1175- job_1 = RevisionsAddedJob.create(
1176+ RevisionsAddedJob.create(
1177 branch, 'rev1', 'rev2', 'from@example.org')
1178 transaction.commit()
1179 retcode, stdout, stderr = run_script(
1180 'cronscripts/sendbranchmail.py', [])
1181- self.assertEqual('INFO creating lockfile\n'
1182- 'INFO Ran 1 RevisionMailJobs.\n', stderr)
1183+ self.assertEqual(
1184+ 'INFO Creating lockfile: /var/lock/launchpad-sendbranchmail.lock\n'
1185+ 'INFO Ran 1 RevisionMailJobs.\n',
1186+ stderr)
1187 self.assertEqual('', stdout)
1188 self.assertEqual(0, retcode)
1189
1190
1191=== removed file 'lib/lp/code/scripts/tests/test_update_preview_diffs.py'
1192--- lib/lp/code/scripts/tests/test_update_preview_diffs.py 2010-01-05 20:37:10 +0000
1193+++ lib/lp/code/scripts/tests/test_update_preview_diffs.py 1970-01-01 00:00:00 +0000
1194@@ -1,93 +0,0 @@
1195-#! /usr/bin/python2.5
1196-#
1197-# Copyright 2009 Canonical Ltd. This software is licensed under the
1198-# GNU Affero General Public License version 3 (see the file LICENSE).
1199-
1200-"""Test the update_preview_diffs script."""
1201-
1202-
1203-import transaction
1204-
1205-from canonical.testing import ZopelessAppServerLayer
1206-from lp.testing import TestCaseWithFactory
1207-from canonical.launchpad.scripts.tests import run_script
1208-from canonical.launchpad.webapp import errorlog
1209-from lp.code.model.branchmergeproposal import BranchMergeProposal
1210-from lp.code.model.branchmergeproposaljob import UpdatePreviewDiffJob
1211-
1212-
1213-class TestUpdatePreviewDiffs(TestCaseWithFactory):
1214-
1215- layer = ZopelessAppServerLayer
1216-
1217- def create_preview_diff_job(self):
1218- self.useTempBzrHome()
1219- target, target_tree = self.createMirroredBranchAndTree()
1220- target_tree.bzrdir.root_transport.put_bytes('foo', 'foo\n')
1221- target_tree.add('foo')
1222- target_tree.commit('added foo')
1223- source, source_tree = self.createMirroredBranchAndTree()
1224- source_tree.pull(target_tree.branch)
1225- source_tree.bzrdir.root_transport.put_bytes('foo', 'foo\nbar\n')
1226- source_tree.commit('added bar')
1227- # Add a fake revisions so the proposal is ready.
1228- self.factory.makeRevisionsForBranch(source, count=1)
1229- bmp = BranchMergeProposal(
1230- source_branch=source, target_branch=target,
1231- registrant=source.owner)
1232- job = UpdatePreviewDiffJob.create(bmp)
1233- self.assertIs(None, bmp.preview_diff)
1234- transaction.commit()
1235- return job, bmp, source_tree
1236-
1237- def test_update_preview_diffs(self):
1238- """Ensure update_preview_diffs runs and generates diffs."""
1239- job, bmp, source_tree = self.create_preview_diff_job()
1240- retcode, stdout, stderr = run_script(
1241- 'cronscripts/update_preview_diffs.py', [])
1242- self.assertEqual(0, retcode)
1243- self.assertEqual('', stdout)
1244- self.assertEqual(
1245- 'INFO creating lockfile\n'
1246- 'INFO Running synchronously.\n'
1247- 'INFO Ran 1 IUpdatePreviewDiffJobSource jobs.\n'
1248- 'INFO 0 IUpdatePreviewDiffJobSource jobs did not complete.\n',
1249- stderr)
1250- self.assertIsNot(None, bmp.preview_diff)
1251-
1252- def test_update_preview_diffs_twisted(self):
1253- """Ensure update_preview_diffs runs and generates diffs."""
1254- job, bmp, source_tree = self.create_preview_diff_job()
1255- retcode, stdout, stderr = run_script(
1256- 'cronscripts/update_preview_diffs.py', ['--twisted'])
1257- self.assertEqual(0, retcode)
1258- self.assertEqual('', stdout)
1259- self.assertEqual(
1260- 'INFO creating lockfile\n'
1261- 'INFO Running through Twisted.\n'
1262- 'INFO Ran 1 IUpdatePreviewDiffJobSource jobs.\n'
1263- 'INFO 0 IUpdatePreviewDiffJobSource jobs did not complete.\n',
1264- stderr)
1265- self.assertIsNot(None, bmp.preview_diff)
1266-
1267- def test_update_preview_diffs_oops(self):
1268- """Ensure update_preview_diffs runs and generates diffs."""
1269- job, bmp, source_tree = self.create_preview_diff_job()
1270- source_tree.bzrdir.root_transport.delete_tree('.bzr')
1271- error_utility = errorlog.ErrorReportingUtility()
1272- error_utility.configure('update_preview_diffs')
1273- old_report = error_utility.getLastOopsReport()
1274- if old_report is not None:
1275- old_id = old_report.id
1276- else:
1277- old_id = None
1278- retcode, stdout, stderr = run_script(
1279- 'cronscripts/update_preview_diffs.py', ['--twisted'])
1280- self.assertEqual(0, retcode)
1281- self.assertIn(
1282- 'INFO 1 IUpdatePreviewDiffJobSource jobs did not complete.\n',
1283- stderr)
1284- self.assertIn('INFO Job resulted in OOPS:', stderr)
1285- new_id = error_utility.getLastOopsReport().id
1286- self.assertNotEqual(old_id, new_id)
1287-
1288
1289=== modified file 'lib/lp/code/scripts/tests/test_upgrade_branches.py'
1290--- lib/lp/code/scripts/tests/test_upgrade_branches.py 2010-01-22 06:03:19 +0000
1291+++ lib/lp/code/scripts/tests/test_upgrade_branches.py 2010-04-07 18:05:36 +0000
1292@@ -32,7 +32,7 @@
1293 target_tree.branch.repository._format.get_format_string(),
1294 'Bazaar-NG Knit Repository Format 1')
1295
1296- job = BranchUpgradeJob.create(target)
1297+ BranchUpgradeJob.create(target)
1298 transaction.commit()
1299
1300 retcode, stdout, stderr = run_script(
1301@@ -40,7 +40,7 @@
1302 expect_returncode=0)
1303 self.assertEqual('', stdout)
1304 self.assertIn(
1305- 'INFO Ran 1 IBranchUpgradeJobSource jobs.\n', stderr)
1306+ 'INFO Ran 1 BranchUpgradeJob jobs.\n', stderr)
1307
1308 target_branch = BzrBranch.open(target_tree.branch.base)
1309 self.assertEqual(
1310@@ -60,7 +60,7 @@
1311 target_tree.branch.repository._format.get_format_string(),
1312 'Bazaar-NG Knit Repository Format 1')
1313
1314- job = BranchUpgradeJob.create(target)
1315+ BranchUpgradeJob.create(target)
1316 transaction.commit()
1317
1318 retcode, stdout, stderr = run_script(
1319@@ -68,7 +68,7 @@
1320 expect_returncode=0)
1321 self.assertEqual('', stdout)
1322 self.assertIn(
1323- 'INFO Ran 1 IBranchUpgradeJobSource jobs.\n', stderr)
1324+ 'INFO Ran 1 BranchUpgradeJob jobs.\n', stderr)
1325
1326 target_branch = BzrBranch.open(target_tree.branch.base)
1327 self.assertEqual(
1328
1329=== modified file 'lib/lp/code/tests/helpers.py'
1330--- lib/lp/code/tests/helpers.py 2009-12-13 11:55:40 +0000
1331+++ lib/lp/code/tests/helpers.py 2010-04-07 18:05:36 +0000
1332@@ -19,6 +19,8 @@
1333 from zope.security.proxy import removeSecurityProxy
1334 from zope.security.proxy import isinstance as zisinstance
1335
1336+from lp.code.interfaces.branchmergeproposal import (
1337+ IBranchMergeProposalJobSource)
1338 from lp.code.interfaces.seriessourcepackagebranch import (
1339 IMakeOfficialBranchLinks)
1340 from lp.registry.interfaces.series import SeriesStatus
1341@@ -26,6 +28,20 @@
1342 from lp.testing import time_counter
1343
1344
1345+def mark_all_merge_proposal_jobs_done():
1346+ """Sometimes in tests we want to clear out all pending jobs.
1347+
1348+ This function iterates through all the pending jobs and marks the done.
1349+ """
1350+ while True:
1351+ jobs = list(getUtility(IBranchMergeProposalJobSource).iterReady())
1352+ if len(jobs) == 0:
1353+ break
1354+ for job in jobs:
1355+ job.start()
1356+ job.complete()
1357+
1358+
1359 def add_revision_to_branch(factory, branch, revision_date, date_created=None,
1360 mainline=True, commit_msg=None):
1361 """Add a new revision to the branch with the specified revision date.
1362
1363=== modified file 'lib/lp/codehosting/scanner/tests/test_bzrsync.py'
1364--- lib/lp/codehosting/scanner/tests/test_bzrsync.py 2010-03-09 19:52:02 +0000
1365+++ lib/lp/codehosting/scanner/tests/test_bzrsync.py 2010-04-07 18:05:36 +0000
1366@@ -655,17 +655,18 @@
1367 @run_as_db_user(config.launchpad.dbuser)
1368 def test_create_on_new_revision(self):
1369 """When branch tip changes, a job is created."""
1370- revision_id = self.commitRevision()
1371 bmp = self.factory.makeBranchMergeProposal(
1372 source_branch=self.db_branch)
1373 removeSecurityProxy(bmp).target_branch.last_scanned_id = 'rev'
1374+ # The creation of a merge proposal has created an update preview diff
1375+ # job, so we'll mark that one as done.
1376+ bmp.next_preview_diff_job.start()
1377+ bmp.next_preview_diff_job.complete()
1378+ self.assertIs(None, bmp.next_preview_diff_job)
1379 transaction.commit()
1380 LaunchpadZopelessLayer.switchDbUser(config.branchscanner.dbuser)
1381 self.makeBzrSync(self.db_branch).syncBranchAndClose()
1382- jobs = list(getUtility(IUpdatePreviewDiffJobSource).iterReady())
1383- self.assertEqual(1, len(jobs))
1384- self.assertEqual(
1385- bmp, removeSecurityProxy(jobs[0]).branch_merge_proposal)
1386+ self.assertIsNot(None, bmp.next_preview_diff_job)
1387
1388
1389 class TestRevisionProperty(BzrSyncTestCase):
1390
1391=== modified file 'lib/lp/codehosting/scanner/tests/test_mergedetection.py'
1392--- lib/lp/codehosting/scanner/tests/test_mergedetection.py 2010-03-02 18:56:25 +0000
1393+++ lib/lp/codehosting/scanner/tests/test_mergedetection.py 2010-04-07 18:05:36 +0000
1394@@ -14,16 +14,21 @@
1395 from zope.component import getUtility
1396 from zope.event import notify
1397
1398+from canonical.config import config
1399+from canonical.launchpad.interfaces import IStore
1400+from canonical.testing import LaunchpadZopelessLayer
1401+
1402 from lp.codehosting.scanner import events
1403 from lp.codehosting.scanner import mergedetection
1404 from lp.codehosting.scanner.tests.test_bzrsync import (
1405 BzrSyncTestCase, run_as_db_user)
1406-from canonical.config import config
1407 from lp.code.enums import BranchLifecycleStatus, BranchMergeProposalStatus
1408+from lp.code.model.branchmergeproposaljob import (
1409+ BranchMergeProposalJob, BranchMergeProposalJobFactory,
1410+ BranchMergeProposalJobType)
1411 from lp.code.interfaces.branchlookup import IBranchLookup
1412 from lp.testing import TestCaseWithFactory
1413 from lp.testing.mail_helpers import pop_notifications
1414-from canonical.testing import LaunchpadZopelessLayer
1415
1416
1417 class TestAutoMergeDetectionForMergeProposals(BzrSyncTestCase):
1418@@ -35,7 +40,7 @@
1419 @run_as_db_user(config.launchpad.dbuser)
1420 def createProposal(self, source, target):
1421 # The scanner doesn't have insert rights, so do it here.
1422- proposal = source.addLandingTarget(source.owner, target)
1423+ source.addLandingTarget(source.owner, target)
1424 transaction.commit()
1425
1426 def _createBranchesAndProposal(self):
1427@@ -210,7 +215,7 @@
1428 # Other branches for the product are checked, but if the tip revision
1429 # of the branch is not yet been set no merge event is emitted for that
1430 # branch.
1431- source = self.factory.makeProductBranch(product=self.product)
1432+ self.factory.makeProductBranch(product=self.product)
1433 self.autoMergeBranches(self.db_branch, ['revid'])
1434 self.assertEqual([], self.merges)
1435
1436@@ -257,6 +262,13 @@
1437 self.assertEqual(
1438 BranchLifecycleStatus.MERGED,
1439 proposal.source_branch.lifecycle_status)
1440+ job = IStore(proposal).find(
1441+ BranchMergeProposalJob,
1442+ BranchMergeProposalJob.branch_merge_proposal == proposal,
1443+ BranchMergeProposalJob.job_type ==
1444+ BranchMergeProposalJobType.MERGE_PROPOSAL_UPDATED).one()
1445+ derived_job = BranchMergeProposalJobFactory.create(job)
1446+ derived_job.run()
1447 notifications = pop_notifications()
1448 self.assertIn('Work in progress => Merged',
1449 notifications[0].get_payload(decode=True))
1450
1451=== modified file 'lib/lp/hardwaredb/doc/hwdb-submission.txt'
1452--- lib/lp/hardwaredb/doc/hwdb-submission.txt 2010-02-02 17:12:29 +0000
1453+++ lib/lp/hardwaredb/doc/hwdb-submission.txt 2010-04-07 18:05:36 +0000
1454@@ -270,7 +270,7 @@
1455 >>> returnvalue
1456 0
1457 >>> print err
1458- INFO creating lockfile
1459+ INFO Creating lockfile: /var/lock/launchpad-hwdbsubmissions.lock
1460 ERROR Parsing submission test_submission_id_1: syntax error:
1461 line 1, column 0
1462 INFO Processed 0 valid and 1 invalid HWDB submissions
1463@@ -306,7 +306,7 @@
1464 >>> returnvalue
1465 0
1466 >>> print err
1467- INFO creating lockfile
1468+ INFO Creating lockfile: /var/lock/launchpad-hwdbsubmissions.lock
1469 ERROR Parsing submission unique-id-1: syntax error: line 1, column 0
1470 INFO Processed 1 valid and 1 invalid HWDB submissions
1471 >>> print out
1472@@ -366,7 +366,7 @@
1473 >>> returnvalue
1474 0
1475 >>> print err
1476- INFO creating lockfile
1477+ INFO Creating lockfile: /var/lock/launchpad-hwdbsubmissions.lock
1478 INFO Processed 60 valid and 0 invalid HWDB submissions
1479 >>> print out
1480 <BLANKLINE>
1481@@ -403,7 +403,7 @@
1482 >>> returnvalue
1483 0
1484 >>> print err
1485- INFO creating lockfile
1486+ INFO Creating lockfile: /var/lock/launchpad-hwdbsubmissions.lock
1487 INFO Processed 100 valid and 0 invalid HWDB submissions
1488 >>> print out
1489 <BLANKLINE>
1490
1491=== modified file 'lib/lp/registry/doc/distribution-mirror.txt'
1492--- lib/lp/registry/doc/distribution-mirror.txt 2010-03-31 11:57:54 +0000
1493+++ lib/lp/registry/doc/distribution-mirror.txt 2010-04-07 18:05:36 +0000
1494@@ -585,7 +585,7 @@
1495 >>> print stdout
1496 <BLANKLINE>
1497 >>> print stderr
1498- INFO creating lockfile
1499+ INFO Creating lockfile: /var/lock/launchpad-distributionmirror-prober.lock
1500 INFO Probing Archive Mirrors
1501 INFO Probed 4 mirrors.
1502 INFO Disabling 1 mirror(s):
1503@@ -599,7 +599,7 @@
1504 >>> print stdout
1505 <BLANKLINE>
1506 >>> print stderr
1507- INFO creating lockfile
1508+ INFO Creating lockfile: /var/lock/launchpad-distributionmirror-prober.lock
1509 INFO Probing CD Image Mirrors
1510 INFO Probed 4 mirrors.
1511 INFO Disabling 1 mirror(s):
1512@@ -615,7 +615,7 @@
1513 >>> print stdout
1514 <BLANKLINE>
1515 >>> print stderr
1516- INFO creating lockfile
1517+ INFO Creating lockfile: /var/lock/launchpad-distributionmirror-prober.lock
1518 INFO Probing CD Image Mirrors
1519 INFO No mirrors to probe.
1520 INFO Done.
1521@@ -628,7 +628,7 @@
1522 >>> print stdout
1523 <BLANKLINE>
1524 >>> print stderr
1525- INFO creating lockfile
1526+ INFO Creating lockfile: /var/lock/launchpad-distributionmirror-prober.lock
1527 INFO Probing CD Image Mirrors
1528 INFO Probed 4 mirrors.
1529 INFO Done.
1530@@ -647,7 +647,7 @@
1531 >>> transaction.commit()
1532 >>> prober, stdout, stderr = run_prober('--content-type=cdimage --force')
1533 >>> print stderr
1534- INFO creating lockfile
1535+ INFO Creating lockfile: /var/lock/launchpad-distributionmirror-prober.lock
1536 INFO Probing CD Image Mirrors
1537 INFO Probed 4 mirrors.
1538 INFO Re-enabling 1 mirror(s):
1539
1540=== modified file 'lib/lp/registry/doc/person-karma.txt'
1541--- lib/lp/registry/doc/person-karma.txt 2010-03-15 12:32:37 +0000
1542+++ lib/lp/registry/doc/person-karma.txt 2010-04-07 18:05:36 +0000
1543@@ -131,7 +131,7 @@
1544 ... stderr=subprocess.PIPE)
1545 >>> (out, err) = process.communicate()
1546 >>> print err
1547- INFO creating lockfile
1548+ INFO Creating lockfile: /var/lock/launchpad-karma-update.lock
1549 INFO Updating Launchpad karma caches
1550 INFO Step A: Calculating individual KarmaCache entries
1551 INFO Scaling bugs by a factor of 2.6667 (capped to 2.0000)
1552
1553=== modified file 'lib/lp/registry/doc/sourceforge-remote-products.txt'
1554--- lib/lp/registry/doc/sourceforge-remote-products.txt 2009-06-02 08:20:49 +0000
1555+++ lib/lp/registry/doc/sourceforge-remote-products.txt 2010-04-07 18:05:36 +0000
1556@@ -117,7 +117,7 @@
1557 0
1558
1559 >>> print err
1560- INFO creating lockfile
1561+ INFO Creating lockfile: /var/lock/launchpad-updateremoteproduct.lock
1562 INFO No Products to update.
1563 INFO Time for this run: ... seconds.
1564 DEBUG Removing lock file:...
1565
1566=== modified file 'lib/lp/registry/doc/standing.txt'
1567--- lib/lp/registry/doc/standing.txt 2009-08-13 19:03:36 +0000
1568+++ lib/lp/registry/doc/standing.txt 2010-04-07 18:05:36 +0000
1569@@ -260,7 +260,7 @@
1570 >>> print stdout
1571 <BLANKLINE>
1572 >>> print stderr
1573- INFO creating lockfile
1574+ INFO Creating lockfile: /var/lock/launchpad-update-personal-standing.lock
1575 INFO Updating personal standings
1576 INFO Done.
1577 <BLANKLINE>
1578@@ -294,7 +294,7 @@
1579 >>> print stdout
1580 <BLANKLINE>
1581 >>> print stderr
1582- INFO creating lockfile
1583+ INFO Creating lockfile: /var/lock/launchpad-update-personal-standing.lock
1584 INFO Updating personal standings
1585 INFO Done.
1586 <BLANKLINE>
1587
1588=== modified file 'lib/lp/services/job/tests/test_runner.py'
1589--- lib/lp/services/job/tests/test_runner.py 2010-03-11 16:37:22 +0000
1590+++ lib/lp/services/job/tests/test_runner.py 2010-04-07 18:05:36 +0000
1591@@ -297,6 +297,10 @@
1592 def __init__(self):
1593 self.entries = []
1594
1595+ def debug(self, input, *args):
1596+ # We don't care about debug messages.
1597+ pass
1598+
1599 def info(self, input, *args):
1600 self.entries.append(input)
1601
1602@@ -338,7 +342,7 @@
1603 @classmethod
1604 def runFromSource(cls, source, dbuser, logger):
1605 expected_config = errorlog.ErrorReportingUtility()
1606- expected_config.configure('update_preview_diffs')
1607+ expected_config.configure('merge_proposal_jobs')
1608 self.assertEqual(
1609 errorlog.globalErrorUtility.oops_prefix,
1610 expected_config.oops_prefix)
1611@@ -348,7 +352,7 @@
1612 incomplete_jobs = []
1613
1614 class JobCronScriptSubclass(JobCronScript):
1615- config_name = 'update_preview_diffs'
1616+ config_name = 'merge_proposal_jobs'
1617 source_interface = IUpdatePreviewDiffJobSource
1618
1619 def __init__(self):
1620
1621=== modified file 'lib/lp/services/mail/sendmail.py'
1622--- lib/lp/services/mail/sendmail.py 2010-04-07 18:05:11 +0000
1623+++ lib/lp/services/mail/sendmail.py 2010-04-07 18:05:36 +0000
1624@@ -45,10 +45,10 @@
1625 from zope.security.proxy import isinstance as zisinstance
1626
1627 from canonical.config import config
1628+from canonical.launchpad import versioninfo
1629+from canonical.launchpad.helpers import is_ascii_only
1630 from canonical.lp import isZopeless
1631-from canonical.launchpad.helpers import is_ascii_only
1632 from lp.services.mail.stub import TestMailer
1633-from canonical.launchpad import versioninfo
1634
1635 # email package by default ends up encoding UTF-8 messages using base64,
1636 # which sucks as they look like spam to stupid spam filters. We define
1637@@ -409,21 +409,28 @@
1638 message['X-Launchpad-Hash'] = hash.hexdigest()
1639
1640 raw_message = message.as_string()
1641- if isZopeless():
1642- # Zopeless email sending is not unit tested, and won't be.
1643- # The zopeless specific stuff is pretty simple though so this
1644- # should be fine.
1645
1646- if config.instance_name == 'testrunner':
1647- # when running in the testing environment, store emails
1648- TestMailer().send(
1649- config.canonical.bounce_address, to_addrs, raw_message)
1650- else:
1651- return raw_sendmail(
1652- config.canonical.bounce_address, to_addrs, raw_message)
1653+ if isZopeless() and config.instance_name == 'testrunner':
1654+ # when running in the testing environment, store emails
1655+ TestMailer().send(
1656+ config.canonical.bounce_address, to_addrs, raw_message)
1657 # Strip the angle brackets to the return a Message-Id consistent with
1658 # raw_sendmail (which doesn't include them).
1659 return message['message-id'][1:-1]
1660+ elif isZopeless() and config.instance_name == 'testrunner-appserver':
1661+ if config.zopeless.send_email:
1662+ # Note that we simply throw away dud recipients. This is fine,
1663+ # as it emulates the Z3 API which doesn't report this either
1664+ # (because actual delivery is done later).
1665+ smtp = SMTP(
1666+ config.zopeless.smtp_host, config.zopeless.smtp_port)
1667+
1668+ # The "MAIL FROM" is set to the bounce address, to behave in a
1669+ # way similar to mailing list software.
1670+ smtp.sendmail(
1671+ config.canonical.bounce_address, to_addrs, raw_message)
1672+ smtp.quit()
1673+ return message['message-id'][1:-1]
1674 else:
1675 # The "MAIL FROM" is set to the bounce address, to behave in a way
1676 # similar to mailing list software.
1677
1678=== modified file 'lib/lp/soyuz/doc/buildd-slavescanner.txt'
1679--- lib/lp/soyuz/doc/buildd-slavescanner.txt 2010-03-24 04:51:25 +0000
1680+++ lib/lp/soyuz/doc/buildd-slavescanner.txt 2010-04-07 18:05:36 +0000
1681@@ -500,7 +500,7 @@
1682 * Build Log: http://.../...i386.mozilla-firefox_0.9_NEEDSBUILD.txt.gz
1683 ...
1684 Upload log:
1685- INFO creating lockfile
1686+ INFO Creating lockfile: /var/lock/process-upload-buildd.lock
1687 DEBUG Initialising connection.
1688 ...
1689 DEBUG Removing lock file: /var/lock/process-upload-buildd.lock
1690@@ -737,7 +737,7 @@
1691 ... 'uploader.log'))
1692
1693 >>> print uploader_log.read()
1694- INFO creating lockfile
1695+ INFO Creating lockfile: /var/lock/process-upload-buildd.lock
1696 DEBUG Initialising connection.
1697 DEBUG Beginning processing
1698 DEBUG Creating directory /var/tmp/builddmaster/accepted
1699
1700=== modified file 'lib/lp/soyuz/doc/gina.txt'
1701--- lib/lp/soyuz/doc/gina.txt 2010-03-17 05:48:45 +0000
1702+++ lib/lp/soyuz/doc/gina.txt 2010-04-07 18:05:36 +0000
1703@@ -730,7 +730,7 @@
1704 >>> proc = subprocess.Popen(gina_proc, stderr=subprocess.PIPE)
1705
1706 >>> print proc.stderr.read()
1707- INFO creating lockfile
1708+ INFO Creating lockfile: /var/lock/launchpad-gina.lock
1709 ...
1710 INFO === Processing debian/lenny/release ===
1711 ...
1712
1713=== modified file 'lib/lp/soyuz/doc/manage-chroot.txt'
1714--- lib/lp/soyuz/doc/manage-chroot.txt 2009-04-28 12:59:43 +0000
1715+++ lib/lp/soyuz/doc/manage-chroot.txt 2010-04-07 18:05:36 +0000
1716@@ -68,7 +68,7 @@
1717 >>> process.returncode
1718 0
1719 >>> print stderr
1720- INFO creating lockfile
1721+ INFO Creating lockfile: /var/lock/launchpad-mangage-chroot.lock
1722 DEBUG Initialising ChrootManager for 'The Hoary Hedgehog Release for i386 (x86)'
1723 DEBUG LibraryFileAlias: ..., 25 bytes, 04a60337a417012f7c51fb56d59d2d0d
1724 DEBUG PocketChroot for 'The Hoary Hedgehog Release for i386 (x86)' (1) added.
1725
1726=== modified file 'lib/lp/soyuz/doc/package-cache-script.txt'
1727--- lib/lp/soyuz/doc/package-cache-script.txt 2009-04-28 12:59:43 +0000
1728+++ lib/lp/soyuz/doc/package-cache-script.txt 2010-04-07 18:05:36 +0000
1729@@ -46,7 +46,7 @@
1730 >>> print stdout
1731
1732 >>> print stderr
1733- INFO creating lockfile
1734+ INFO Creating lockfile: /var/lock/launchpad-update-cache.lock
1735 INFO Updating ubuntu package counters
1736 INFO Updating ubuntu main archives
1737 ...
1738
1739=== modified file 'lib/lp/soyuz/scripts/tests/test_processupload.py'
1740--- lib/lp/soyuz/scripts/tests/test_processupload.py 2009-06-25 04:06:00 +0000
1741+++ lib/lp/soyuz/scripts/tests/test_processupload.py 2010-04-07 18:05:36 +0000
1742@@ -76,7 +76,7 @@
1743 # proper log message
1744 self.assertEqual(1, returncode)
1745 self.assertEqual(
1746- ['INFO creating lockfile',
1747+ ['INFO Creating lockfile: /var/lock/process-upload-insecure.lock',
1748 'DEBUG Lockfile /var/lock/process-upload-insecure.lock in use'
1749 ], err.splitlines())
1750
1751
1752=== modified file 'lib/lp/translations/doc/distroseries-translations-copy.txt'
1753--- lib/lp/translations/doc/distroseries-translations-copy.txt 2010-02-19 16:54:42 +0000
1754+++ lib/lp/translations/doc/distroseries-translations-copy.txt 2010-04-07 18:05:36 +0000
1755@@ -193,7 +193,8 @@
1756 >>> returnvalue
1757 1
1758 >>> print error_output
1759- INFO creating lockfile
1760+ INFO Creating lockfile:
1761+ /var/lock/launchpad-copy-missing-translations-foobuntu-darty.lock
1762 ERROR Before this process starts, set the hide_all_translations and
1763 defer_translation_imports flags for distribution foobuntu, series
1764 darty; or use the --force option to make it happen
1765@@ -219,7 +220,8 @@
1766 >>> returnvalue
1767 0
1768 >>> print error_output
1769- INFO creating lockfile
1770+ INFO Creating lockfile:
1771+ /var/lock/launchpad-copy-missing-translations-foobuntu-darty.lock
1772 INFO Starting...
1773 INFO Populating blank distroseries darty with translations from barty.
1774 INFO Extracting from POTemplate into
1775
1776=== modified file 'lib/lp/translations/doc/fix_translation_credits.txt'
1777--- lib/lp/translations/doc/fix_translation_credits.txt 2009-11-06 09:41:12 +0000
1778+++ lib/lp/translations/doc/fix_translation_credits.txt 2010-04-07 18:05:36 +0000
1779@@ -9,7 +9,8 @@
1780 >>> print returncode
1781 0
1782 >>> print err
1783- INFO creating lockfile
1784+ INFO Creating lockfile:
1785+ /var/lock/launchpad-fix-translation-credits.lock
1786 INFO Figuring out POFiles that need fixing: this may take a while...
1787 INFO Marking up a total of 3 credits as translated.
1788 INFO Processed ...
1789
1790=== modified file 'lib/lp/translations/doc/poexport-language-pack.txt'
1791--- lib/lp/translations/doc/poexport-language-pack.txt 2009-11-17 09:50:33 +0000
1792+++ lib/lp/translations/doc/poexport-language-pack.txt 2010-04-07 18:05:36 +0000
1793@@ -546,7 +546,8 @@
1794 >>> print err
1795 INFO Setting lockfile name to
1796 launchpad-language-pack-exporter__ubuntu__hoary.lock.
1797- INFO creating lockfile
1798+ INFO Creating lockfile:
1799+ /var/lock/launchpad-language-pack-exporter__ubuntu__hoary.lock
1800 INFO Exporting translations for series hoary of distribution ubuntu.
1801 INFO Number of PO files to export: 12
1802 INFO Exporting XPI template files.
1803
1804=== modified file 'lib/lp/translations/doc/poexport-request.txt'
1805--- lib/lp/translations/doc/poexport-request.txt 2010-03-05 20:40:40 +0000
1806+++ lib/lp/translations/doc/poexport-request.txt 2010-04-07 18:05:36 +0000
1807@@ -266,7 +266,7 @@
1808 ... )
1809 >>> (output, empty) = process.communicate()
1810 >>> print output
1811- INFO creating lockfile
1812+ INFO Creating lockfile: /var/lock/launchpad-rosetta-export-queue.lock
1813 DEBUG Exporting objects for Happy Downloader, related to template
1814 evolution-2.2 in Evolution trunk
1815 DEBUG Exporting objects for Happy Downloader, related to template
1816
1817=== modified file 'lib/lp/translations/doc/pofile-verify-stats.txt'
1818--- lib/lp/translations/doc/pofile-verify-stats.txt 2009-08-10 16:52:41 +0000
1819+++ lib/lp/translations/doc/pofile-verify-stats.txt 2010-04-07 18:05:36 +0000
1820@@ -176,7 +176,7 @@
1821 >>> print returncode
1822 0
1823 >>> print err
1824- INFO creating lockfile
1825+ INFO Creating lockfile: /var/lock/launchpad-pofile-stats-daily.lock
1826 INFO Verifying stats of POFiles updated in the last ... days.
1827 INFO Verifying a total of 1 POFiles.
1828 INFO Done.
1829@@ -192,7 +192,7 @@
1830 >>> print returncode
1831 0
1832 >>> print err
1833- INFO creating lockfile
1834+ INFO Creating lockfile: /var/lock/launchpad-pofile-stats.lock
1835 INFO Starting verification of POFile stats at id 99
1836 INFO Done.
1837
1838
1839=== modified file 'lib/lp/translations/doc/rosetta-poimport-script.txt'
1840--- lib/lp/translations/doc/rosetta-poimport-script.txt 2009-11-17 09:50:33 +0000
1841+++ lib/lp/translations/doc/rosetta-poimport-script.txt 2010-04-07 18:05:36 +0000
1842@@ -88,7 +88,7 @@
1843 >>> process.returncode
1844 0
1845 >>> print stderr
1846- INFO creating lockfile
1847+ INFO Creating lockfile: /var/lock/launchpad-rosetta-poimport.lock
1848 INFO Importing: Serbian (sr) translation of evolution-2.2 in Evolution trunk
1849 INFO Import requests completed.
1850 <BLANKLINE>
1851
1852=== modified file 'lib/lp/translations/doc/sourcepackagerelease-translations.txt'
1853--- lib/lp/translations/doc/sourcepackagerelease-translations.txt 2009-07-20 15:05:42 +0000
1854+++ lib/lp/translations/doc/sourcepackagerelease-translations.txt 2010-04-07 18:05:36 +0000
1855@@ -93,7 +93,8 @@
1856 ... )
1857 >>> (output, empty) = process.communicate()
1858 >>> print output
1859- INFO creating lockfile
1860+ INFO Creating lockfile:
1861+ /var/lock/launchpad-translations-import-queue-gardener.lock
1862 INFO The automatic approval system approved some entries.
1863 INFO Removed 2 entries from the queue.
1864 <BLANKLINE>
1865@@ -108,7 +109,7 @@
1866 ... )
1867 >>> (output, empty) = process.communicate()
1868 >>> print output
1869- INFO creating lockfile
1870+ INFO Creating lockfile: /var/lock/launchpad-rosetta-poimport.lock
1871 INFO Importing: Spanish (es) translation of pmount in Ubuntu Hoary package "pmount"
1872 ...
1873
1874
1875=== modified file 'lib/lp/translations/doc/translations-export-to-branch.txt'
1876--- lib/lp/translations/doc/translations-export-to-branch.txt 2010-03-09 04:35:26 +0000
1877+++ lib/lp/translations/doc/translations-export-to-branch.txt 2010-04-07 18:05:36 +0000
1878@@ -12,7 +12,7 @@
1879 >>> stdout
1880 ''
1881 >>> print stderr
1882- INFO creating lockfile
1883+ INFO Creating lockfile: /var/lock/launchpad-translations-export-to-branch.lock
1884 INFO Exporting to translations branches.
1885 INFO Processed 0 item(s); 0 failure(s).
1886
1887
1888=== modified file 'lib/lp/translations/scripts/tests/test_translations_to_branch.py'
1889--- lib/lp/translations/scripts/tests/test_translations_to_branch.py 2010-03-08 16:18:45 +0000
1890+++ lib/lp/translations/scripts/tests/test_translations_to_branch.py 2010-04-07 18:05:36 +0000
1891@@ -77,7 +77,7 @@
1892
1893 self.assertEqual('', stdout)
1894 self.assertEqual(
1895- 'INFO creating lockfile\n'
1896+ 'INFO Creating lockfile: /var/lock/launchpad-translations-export-to-branch.lock\n'
1897 'INFO Exporting to translations branches.\n'
1898 'INFO Exporting Committobranch trunk series.\n'
1899 'INFO Processed 1 item(s); 0 failure(s).',

Subscribers

People subscribed via source and target branches

to status/vote changes: