Merge lp:~rockstar/launchpad/ibranch-upgrade into lp:launchpad

Proposed by Paul Hummer
Status: Merged
Merged at revision: not available
Proposed branch: lp:~rockstar/launchpad/ibranch-upgrade
Merge into: lp:launchpad
Diff against target: 71 lines
4 files modified
lib/lp/code/configure.zcml (+1/-0)
lib/lp/code/interfaces/branch.py (+3/-0)
lib/lp/code/model/branch.py (+5/-0)
lib/lp/code/model/tests/test_branch.py (+12/-0)
To merge this branch: bzr merge lp:~rockstar/launchpad/ibranch-upgrade
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle Approve
Review via email: mp+14201@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Paul Hummer (rockstar) wrote :

Hi Michael-

  This branch just adds IBranch.requestUpgrade to create a BranchUpgradeJob. That's it.

Cheers,
Paul

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

+ self.assertEqual(jobs.count(), 1)

This could be "self.assertEqual([job], list(jobs))" I think?

Otherwise fine.

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/configure.zcml'
2--- lib/lp/code/configure.zcml 2009-10-29 19:55:59 +0000
3+++ lib/lp/code/configure.zcml 2009-10-30 16:16:20 +0000
4@@ -484,6 +484,7 @@
5 pending_writes
6 commitsForDays
7 needs_upgrading
8+ requestUpgrade
9 getUpgradeFormat
10 isBranchMergeable
11 visibleByUser
12
13=== modified file 'lib/lp/code/interfaces/branch.py'
14--- lib/lp/code/interfaces/branch.py 2009-10-29 19:55:59 +0000
15+++ lib/lp/code/interfaces/branch.py 2009-10-30 16:16:20 +0000
16@@ -1044,6 +1044,9 @@
17
18 needs_upgrading = Attribute("Whether the branch needs to be upgraded.")
19
20+ def requestUpgrade():
21+ """Create an IBranchUpgradeJob to upgrade this branch."""
22+
23 def visibleByUser(user):
24 """Can the specified user see this branch?"""
25
26
27=== modified file 'lib/lp/code/model/branch.py'
28--- lib/lp/code/model/branch.py 2009-10-29 20:48:36 +0000
29+++ lib/lp/code/model/branch.py 2009-10-30 16:16:20 +0000
30@@ -978,6 +978,11 @@
31 return True
32 return False
33
34+ def requestUpgrade(self):
35+ """See `IBranch`."""
36+ from lp.code.interfaces.branchjob import IBranchUpgradeJobSource
37+ return getUtility(IBranchUpgradeJobSource).create(self)
38+
39 def _checkBranchVisibleByUser(self, user):
40 """Is *this* branch visible by the user.
41
42
43=== modified file 'lib/lp/code/model/tests/test_branch.py'
44--- lib/lp/code/model/tests/test_branch.py 2009-10-29 19:55:59 +0000
45+++ lib/lp/code/model/tests/test_branch.py 2009-10-30 16:16:20 +0000
46@@ -41,6 +41,7 @@
47 BranchCannotBePrivate, BranchCannotBePublic,
48 BranchCreatorNotMemberOfOwnerTeam, BranchCreatorNotOwner,
49 BranchTargetError, CannotDeleteBranch, DEFAULT_BRANCH_STATUS_IN_LISTING)
50+from lp.code.interfaces.branchjob import IBranchUpgradeJobSource
51 from lp.code.interfaces.branchlookup import IBranchLookup
52 from lp.code.interfaces.branchnamespace import IBranchNamespaceSet
53 from lp.code.interfaces.branchmergeproposal import (
54@@ -395,6 +396,17 @@
55 repository_format=RepositoryFormat.BZR_REPOSITORY_4)
56 self.assertTrue(branch.needs_upgrading)
57
58+ def test_requestUpgrade(self):
59+ # A BranchUpgradeJob can be created by calling IBranch.requestUpgrade.
60+ branch = self.factory.makeAnyBranch(
61+ branch_format=BranchFormat.BZR_BRANCH_6)
62+ job = removeSecurityProxy(branch.requestUpgrade())
63+
64+ jobs = list(getUtility(IBranchUpgradeJobSource).iterReady())
65+ self.assertEqual(
66+ jobs,
67+ [job,])
68+
69
70 class TestBzrIdentity(TestCaseWithFactory):
71 """Test IBranch.bzr_identity."""