Merge lp:~rockstar/launchpad/default-branch-upgrade-bad into lp:launchpad

Proposed by Paul Hummer
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~rockstar/launchpad/default-branch-upgrade-bad
Merge into: lp:launchpad
Diff against target: 68 lines (+29/-0)
3 files modified
lib/lp/code/bzr.py (+2/-0)
lib/lp/code/model/branch.py (+2/-0)
lib/lp/code/model/tests/test_branch.py (+25/-0)
To merge this branch: bzr merge lp:~rockstar/launchpad/default-branch-upgrade-bad
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle Approve
Review via email: mp+18483@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Paul Hummer (rockstar) wrote :

Hi there-

  This branch fixes bug #515776 - Basically, a branch that didn't know its own formats was claiming it needed to be upgraded. That's a wrong assertion, since we don't know what the formats are, so we don't know whether they are out of date or not. Also, while I was working on it, I realized that mirrored/remote/imported branches that couldn't/shouldn't be upgraded could still claim they needed to be upgraded. I fixed that while I was there.

Cheers,
Paul

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

Looks good, nice and simple :-)

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/bzr.py'
2--- lib/lp/code/bzr.py 2010-01-22 06:03:19 +0000
3+++ lib/lp/code/bzr.py 2010-02-02 22:34:20 +0000
4@@ -216,6 +216,7 @@
5
6 # A tuple of branch formats that should not suggest upgrading.
7 CURRENT_BRANCH_FORMATS = (
8+ None,
9 BranchFormat.UNRECOGNIZED,
10 BranchFormat.BRANCH_REFERENCE,
11 BranchFormat.BZR_BRANCH_7,
12@@ -226,6 +227,7 @@
13
14 # A tuple of repository formats that should not suggest upgrading.
15 CURRENT_REPOSITORY_FORMATS = (
16+ None,
17 RepositoryFormat.UNRECOGNIZED,
18 RepositoryFormat.BZR_PACK_DEV_0,
19 RepositoryFormat.BZR_PACK_DEV_0_SUBTREE,
20
21=== modified file 'lib/lp/code/model/branch.py'
22--- lib/lp/code/model/branch.py 2010-01-29 17:15:31 +0000
23+++ lib/lp/code/model/branch.py 2010-02-02 22:34:20 +0000
24@@ -1000,6 +1000,8 @@
25 @property
26 def needs_upgrading(self):
27 """See `IBranch`."""
28+ if self.branch_type is not BranchType.HOSTED:
29+ return False
30 if self.upgrade_pending:
31 return False
32 return not (
33
34=== modified file 'lib/lp/code/model/tests/test_branch.py'
35--- lib/lp/code/model/tests/test_branch.py 2010-01-26 02:24:27 +0000
36+++ lib/lp/code/model/tests/test_branch.py 2010-02-02 22:34:20 +0000
37@@ -322,6 +322,31 @@
38
39 layer = DatabaseFunctionalLayer
40
41+ def test_needsUpgrading_empty_formats(self):
42+ branch = self.factory.makePersonalBranch()
43+ self.assertFalse(branch.needs_upgrading)
44+
45+ def test_needsUpgrade_mirrored_branch(self):
46+ branch = self.factory.makeBranch(
47+ branch_type=BranchType.MIRRORED,
48+ branch_format=BranchFormat.BZR_BRANCH_6,
49+ repository_format=RepositoryFormat.BZR_REPOSITORY_4)
50+ self.assertFalse(branch.needs_upgrading)
51+
52+ def test_needsUpgrade_remote_branch(self):
53+ branch = self.factory.makeBranch(
54+ branch_type=BranchType.REMOTE,
55+ branch_format=BranchFormat.BZR_BRANCH_6,
56+ repository_format=RepositoryFormat.BZR_REPOSITORY_4)
57+ self.assertFalse(branch.needs_upgrading)
58+
59+ def test_needsUpgrade_import_branch(self):
60+ branch = self.factory.makeBranch(
61+ branch_type=BranchType.IMPORTED,
62+ branch_format=BranchFormat.BZR_BRANCH_6,
63+ repository_format=RepositoryFormat.BZR_REPOSITORY_4)
64+ self.assertFalse(branch.needs_upgrading)
65+
66 def test_needsUpgrading_already_requested(self):
67 # A branch has a needs_upgrading attribute that returns whether or not
68 # a branch needs to be upgraded or not. If the format is