Merge lp:~rockstar/launchpad/fix-branch-requestMirror into lp:launchpad

Proposed by Paul Hummer
Status: Merged
Merged at revision: 10995
Proposed branch: lp:~rockstar/launchpad/fix-branch-requestMirror
Merge into: lp:launchpad
Diff against target: 117 lines (+39/-13)
4 files modified
lib/lp/code/enums.py (+9/-0)
lib/lp/code/model/branchjob.py (+25/-1)
lib/lp/code/model/tests/test_branchjob.py (+1/-1)
lib/lp/code/xmlrpc/codehosting.py (+4/-11)
To merge this branch: bzr merge lp:~rockstar/launchpad/fix-branch-requestMirror
Reviewer Review Type Date Requested Status
Francis J. Lacoste (community) release-critical Approve
Tim Penhey (community) Approve
Review via email: mp+27317@code.launchpad.net

Description of the change

This branch makes BranchUpgradeJob stop calling IBranch.requestMirror. Instead, we use IBranch.branchChanged to change the formats. This is also better because a BranchScanJob doesn't have to be created. See bug #592496

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

Is it right to hard code the formats?

review: Needs Information
Revision history for this message
Tim Penhey (thumper) :
review: Approve
Revision history for this message
Francis J. Lacoste (flacoste) wrote :

Fine to CP once this has been QA on staging.

review: Approve (release-critical)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/enums.py'
2--- lib/lp/code/enums.py 2010-02-23 02:31:48 +0000
3+++ lib/lp/code/enums.py 2010-06-11 03:54:27 +0000
4@@ -22,6 +22,7 @@
5 'CodeImportReviewStatus',
6 'CodeReviewNotificationLevel',
7 'CodeReviewVote',
8+ 'match_enum_title',
9 'RevisionControlSystems',
10 'TeamBranchVisibilityRule',
11 'UICreatableBranchType',
12@@ -31,6 +32,14 @@
13 DBEnumeratedType, DBItem, EnumeratedType, Item, use_template)
14
15
16+def match_enum_title(enum, title, default):
17+ for value in enum.items:
18+ if value.title == title:
19+ return value
20+ else:
21+ return default
22+
23+
24 class BranchLifecycleStatus(DBEnumeratedType):
25 """Branch Lifecycle Status
26
27
28=== modified file 'lib/lp/code/model/branchjob.py'
29--- lib/lp/code/model/branchjob.py 2010-05-26 23:16:24 +0000
30+++ lib/lp/code/model/branchjob.py 2010-06-11 03:54:27 +0000
31@@ -46,6 +46,8 @@
32 from canonical.database.enumcol import EnumCol
33 from canonical.database.sqlbase import SQLBase
34 from canonical.launchpad.webapp import canonical_url, errorlog
35+from lp.code.bzr import BranchFormat, ControlFormat, RepositoryFormat
36+from lp.code.enums import match_enum_title
37 from lp.code.model.branch import Branch
38 from lp.code.model.branchmergeproposal import BranchMergeProposal
39 from lp.code.model.diff import StaticDiff
40@@ -363,7 +365,29 @@
41 upgrade_transport.clone('.bzr').copy_tree_to_transport(
42 source_branch_transport.clone('.bzr'))
43
44- self.branch.requestMirror()
45+ # Re-open the source branch again.
46+ source_branch = BzrBranch.open_from_transport(
47+ source_branch_transport)
48+
49+ control_format = match_enum_title(
50+ ControlFormat,
51+ source_branch.bzrdir._format.get_format_string(),
52+ ControlFormat.UNRECOGNIZED)
53+ branch_format = match_enum_title(
54+ BranchFormat,
55+ source_branch._format.get_format_string(),
56+ BranchFormat.UNRECOGNIZED)
57+ repository_format = match_enum_title(
58+ RepositoryFormat,
59+ source_branch.repository._format.get_format_string(),
60+ RepositoryFormat.UNRECOGNIZED)
61+
62+ self.branch.branchChanged(
63+ self.branch.stacked_on,
64+ self.branch.last_scanned_id,
65+ control_format,
66+ branch_format,
67+ repository_format)
68 finally:
69 shutil.rmtree(upgrade_branch_path)
70
71
72=== modified file 'lib/lp/code/model/tests/test_branchjob.py'
73--- lib/lp/code/model/tests/test_branchjob.py 2010-05-30 04:06:48 +0000
74+++ lib/lp/code/model/tests/test_branchjob.py 2010-06-11 03:54:27 +0000
75@@ -264,7 +264,7 @@
76 new_branch.repository._format.get_format_string(),
77 'Bazaar repository format 2a (needs bzr 1.16 or later)\n')
78
79- self.assertTrue(db_branch.pending_writes)
80+ self.assertFalse(db_branch.needs_upgrading)
81
82 def test_needs_no_upgrading(self):
83 # Branch upgrade job creation should raise an AssertionError if the
84
85=== modified file 'lib/lp/code/xmlrpc/codehosting.py'
86--- lib/lp/code/xmlrpc/codehosting.py 2010-04-21 04:17:23 +0000
87+++ lib/lp/code/xmlrpc/codehosting.py 2010-06-11 03:54:27 +0000
88@@ -33,7 +33,7 @@
89
90 from lp.code.errors import UnknownBranchTypeError
91 from lp.code.bzr import BranchFormat, ControlFormat, RepositoryFormat
92-from lp.code.enums import BranchType
93+from lp.code.enums import BranchType, match_enum_title
94 from lp.code.interfaces.branch import BranchCreationException
95 from lp.code.interfaces.branchlookup import IBranchLookup
96 from lp.code.interfaces.branchnamespace import (
97@@ -206,18 +206,11 @@
98 if branch is None:
99 return faults.NoBranchWithID(branch_id)
100
101- def match_title(enum, title, default):
102- for value in enum.items:
103- if value.title == title:
104- return value
105- else:
106- return default
107-
108- control_format = match_title(
109+ control_format = match_enum_title(
110 ControlFormat, control_string, ControlFormat.UNRECOGNIZED)
111- branch_format = match_title(
112+ branch_format = match_enum_title(
113 BranchFormat, branch_string, BranchFormat.UNRECOGNIZED)
114- repository_format = match_title(
115+ repository_format = match_enum_title(
116 RepositoryFormat, repository_string,
117 RepositoryFormat.UNRECOGNIZED)
118