Merge lp:~rockstar/launchpad/delete-recipes into lp:launchpad

Proposed by Paul Hummer
Status: Merged
Merged at revision: 11076
Proposed branch: lp:~rockstar/launchpad/delete-recipes
Merge into: lp:launchpad
Diff against target: 53 lines (+16/-6)
3 files modified
lib/lp/code/interfaces/sourcepackagerecipebuild.py (+3/-0)
lib/lp/code/model/sourcepackagerecipebuild.py (+7/-6)
lib/lp/code/model/tests/test_sourcepackagerecipebuild.py (+6/-0)
To merge this branch: bzr merge lp:~rockstar/launchpad/delete-recipes
Reviewer Review Type Date Requested Status
Leonard Richardson (community) Approve
Review via email: mp+28773@code.launchpad.net

Description of the change

This branch fixes bug #597376. Basically, in some cases, a SourcePackageRecipeBuild won't have a buildqueue entry. In the cases where it does, we'll need to delete the build queue entry and the job itself as part of deleting the build.

To post a comment you must log in.
Revision history for this message
Leonard Richardson (leonardr) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/interfaces/sourcepackagerecipebuild.py'
2--- lib/lp/code/interfaces/sourcepackagerecipebuild.py 2010-06-02 15:59:47 +0000
3+++ lib/lp/code/interfaces/sourcepackagerecipebuild.py 2010-06-29 17:21:31 +0000
4@@ -68,6 +68,9 @@
5 def getFileByName(filename):
6 """Return the file under +files with specified name."""
7
8+ def destroySelf():
9+ """Delete the build itself."""
10+
11
12 class ISourcePackageRecipeBuildSource(Interface):
13 """A utility of this interface be used to create source package builds."""
14
15=== modified file 'lib/lp/code/model/sourcepackagerecipebuild.py'
16--- lib/lp/code/model/sourcepackagerecipebuild.py 2010-06-12 13:34:11 +0000
17+++ lib/lp/code/model/sourcepackagerecipebuild.py 2010-06-29 17:21:31 +0000
18@@ -219,12 +219,13 @@
19
20 def destroySelf(self):
21 store = Store.of(self)
22- job = self.buildqueue_record.job
23- store.remove(self.buildqueue_record)
24- store.find(
25- SourcePackageRecipeBuildJob,
26- SourcePackageRecipeBuildJob.build == self.id).remove()
27- store.remove(job)
28+ if self.buildqueue_record is not None:
29+ job = self.buildqueue_record.job
30+ store.remove(self.buildqueue_record)
31+ store.find(
32+ SourcePackageRecipeBuildJob,
33+ SourcePackageRecipeBuildJob.build == self.id).remove()
34+ store.remove(job)
35 store.remove(self)
36
37 @classmethod
38
39=== modified file 'lib/lp/code/model/tests/test_sourcepackagerecipebuild.py'
40--- lib/lp/code/model/tests/test_sourcepackagerecipebuild.py 2010-06-12 13:34:11 +0000
41+++ lib/lp/code/model/tests/test_sourcepackagerecipebuild.py 2010-06-29 17:21:31 +0000
42@@ -240,6 +240,12 @@
43 removeSecurityProxy(recent_build).datecreated += a_second
44 self.assertContentEqual([recent_build], get_recent())
45
46+ def test_destroySelf(self):
47+ # ISourcePackageRecipeBuild should make sure to remove jobs and build
48+ # queue entries and then invalidate itself.
49+ build = self.factory.makeSourcePackageRecipeBuild()
50+ build.destroySelf()
51+
52
53 class TestAsBuildmaster(TestCaseWithFactory):
54