Merge lp:~rockstar/launchpad/upgrade-job-2.0-changes into lp:launchpad
- upgrade-job-2.0-changes
- Merge into devel
Status: | Merged |
---|---|
Approved by: | Edwin Grubbs |
Approved revision: | no longer in the source branch. |
Merged at revision: | not available |
Proposed branch: | lp:~rockstar/launchpad/upgrade-job-2.0-changes |
Merge into: | lp:launchpad |
Diff against target: |
425 lines (+209/-14) 11 files modified
lib/lp/code/browser/branch.py (+31/-1) lib/lp/code/browser/configure.zcml (+7/-0) lib/lp/code/bzr.py (+32/-0) lib/lp/code/configure.zcml (+1/-0) lib/lp/code/interfaces/branch.py (+2/-0) lib/lp/code/model/branch.py (+18/-5) lib/lp/code/model/branchjob.py (+2/-0) lib/lp/code/model/tests/test_branch.py (+51/-7) lib/lp/code/stories/branches/xx-upgrading-branches.txt (+49/-0) lib/lp/code/templates/branch-messages.pt (+6/-0) lib/lp/code/templates/branch-metadata.pt (+10/-1) |
To merge this branch: | bzr merge lp:~rockstar/launchpad/upgrade-job-2.0-changes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Edwin Grubbs (community) | code | Approve | |
Review via email: mp+17701@code.launchpad.net |
Commit message
Description of the change
Paul Hummer (rockstar) wrote : | # |
Paul Hummer (rockstar) wrote : | # |
Hrm, this diff seems confused. It has this branch's changes as well as the next branch's changes... Here's the real diff:
=== modified file 'lib/lp/
--- lib/lp/code/bzr.py 2009-06-30 16:56:07 +0000
+++ lib/lp/code/bzr.py 2010-01-16 07:38:47 +0000
@@ -8,6 +8,8 @@
'BranchFor
'BRANCH_
'ControlFo
+ 'CURRENT_
+ 'CURRENT_
'Repositor
'REPOSITOR
]
@@ -222,6 +224,36 @@
BZR_METADIR_1 = _format_enum(1, BzrDirMetaFormat1)
+# A tuple of branch formats that should not suggest upgrading.
+CURRENT_
+ BranchFormat.
+ BranchFormat.
+ BranchFormat.
+ BranchFormat.
+ BranchFormat.
+ BranchFormat.
+)
+
+# A tuple of repository formats that should not suggest upgrading.
+CURRENT_
+ RepositoryForma
+ RepositoryForma
+ RepositoryForma
+ RepositoryForma
+ RepositoryForma
+ RepositoryForma
+ RepositoryForma
+ RepositoryForma
+ RepositoryForma
+ RepositoryForma
+ RepositoryForma
+ RepositoryForma
+ RepositoryForma
+ RepositoryForma
+ RepositoryForma
+
+)
+
BRANCH_
BranchForm
BranchForm
=== modified file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -487,6 +487,7 @@
+ upgrade_pending
=== modified file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -1057,6 +1057,8 @@
"""
needs_
+ upgrade_pending = Attribute(
+ "Whether a branch has had an upgrade requested.")
def requestUpgrade():
"""Create an IBranchUpgradeJob to upgrade this branch."""
=== modified file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -42,7 +42,8 @@
IStoreSele
from lp.code.bzr import (
- BranchFormat, BRANCH_
+ BranchFormat, BRANCH_
+ CURRENT_
REPOSITORY
from lp.code.enums import (
BranchLife
@@ -991,10 +992,22 @@
@property
...
Edwin Grubbs (edwin-grubbs) wrote : | # |
Hi Paul,
This is a nice improvement. Please change the zcml to require launchpad.Edit for requestUpgrade(). I just have one comment below.
merge-conditional
-Edwin
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -315,24 +315,33 @@
> SourcePackage(
> branch.
>
> + def test_needsUpgra
> + # A branch has a needs_upgrading attribute that returns whether or
> not
> + # a branch needs to be upgraded or not. If the format is
> + # unrecognized, we don't try to upgrade it.
> + branch = self.factory.
> + branch_
> + repository_
> + branch.
> +
> + self.assertFals
> +
> def test_needsUpgra
> # A branch has a needs_upgrading attribute that returns whether or
> not
> # a branch needs to be upgraded or not. If the format is
> # unrecognized, we don't try to upgrade it.
> branch = self.factory.
> - branch_
> + branch_
> + repository_
> self.assertFals
>
> def test_needsUpgra
> # A branch has a needs_upgrading attribute that returns whether or
> not
> # a branch needs to be upgraded or not. If a branch is up to date,
> it
s/up to date/up-to-date/
Preview Diff
1 | === modified file 'lib/lp/code/browser/branch.py' | |||
2 | --- lib/lp/code/browser/branch.py 2010-01-17 00:59:01 +0000 | |||
3 | +++ lib/lp/code/browser/branch.py 2010-01-20 00:20:29 +0000 | |||
4 | @@ -20,6 +20,7 @@ | |||
5 | 20 | 'BranchEditMenu', | 20 | 'BranchEditMenu', |
6 | 21 | 'BranchInProductView', | 21 | 'BranchInProductView', |
7 | 22 | 'BranchSparkView', | 22 | 'BranchSparkView', |
8 | 23 | 'BranchUpgradeView', | ||
9 | 23 | 'BranchURL', | 24 | 'BranchURL', |
10 | 24 | 'BranchView', | 25 | 'BranchView', |
11 | 25 | 'BranchSubscriptionsView', | 26 | 'BranchSubscriptionsView', |
12 | @@ -231,7 +232,7 @@ | |||
13 | 231 | links = [ | 232 | links = [ |
14 | 232 | 'add_subscriber', 'browse_revisions', 'link_bug', | 233 | 'add_subscriber', 'browse_revisions', 'link_bug', |
15 | 233 | 'link_blueprint', 'register_merge', 'source', 'subscription', | 234 | 'link_blueprint', 'register_merge', 'source', 'subscription', |
17 | 234 | 'edit_status'] | 235 | 'edit_status', 'upgrade_branch'] |
18 | 235 | 236 | ||
19 | 236 | @enabled_with_permission('launchpad.Edit') | 237 | @enabled_with_permission('launchpad.Edit') |
20 | 237 | def edit_status(self): | 238 | def edit_status(self): |
21 | @@ -298,6 +299,14 @@ | |||
22 | 298 | url = self.context.codebrowse_url('files') | 299 | url = self.context.codebrowse_url('files') |
23 | 299 | return Link(url, text, icon='info', enabled=enabled) | 300 | return Link(url, text, icon='info', enabled=enabled) |
24 | 300 | 301 | ||
25 | 302 | @enabled_with_permission('launchpad.Edit') | ||
26 | 303 | def upgrade_branch(self): | ||
27 | 304 | enabled = False | ||
28 | 305 | if self.context.needs_upgrading: | ||
29 | 306 | enabled = True | ||
30 | 307 | return Link( | ||
31 | 308 | '+upgrade', 'Upgrade this branch', icon='edit', enabled=enabled) | ||
32 | 309 | |||
33 | 301 | 310 | ||
34 | 302 | class DecoratedBug: | 311 | class DecoratedBug: |
35 | 303 | """Provide some additional attributes to a normal bug.""" | 312 | """Provide some additional attributes to a normal bug.""" |
36 | @@ -877,6 +886,27 @@ | |||
37 | 877 | return canonical_url(self.context) | 886 | return canonical_url(self.context) |
38 | 878 | 887 | ||
39 | 879 | 888 | ||
40 | 889 | class BranchUpgradeView(LaunchpadFormView): | ||
41 | 890 | """Used to upgrade a branch.""" | ||
42 | 891 | |||
43 | 892 | schema = IBranch | ||
44 | 893 | field_names = [] | ||
45 | 894 | |||
46 | 895 | @property | ||
47 | 896 | def page_title(self): | ||
48 | 897 | return smartquote('Upgrade branch "%s"' % self.context.displayname) | ||
49 | 898 | |||
50 | 899 | @property | ||
51 | 900 | def next_url(self): | ||
52 | 901 | return canonical_url(self.context) | ||
53 | 902 | |||
54 | 903 | cancel_url = next_url | ||
55 | 904 | |||
56 | 905 | @action('Upgrade', name='upgrade_branch') | ||
57 | 906 | def upgrade_branch_action(self, action, data): | ||
58 | 907 | self.context.requestUpgrade() | ||
59 | 908 | |||
60 | 909 | |||
61 | 880 | class BranchEditView(BranchEditFormView, BranchNameValidationMixin): | 910 | class BranchEditView(BranchEditFormView, BranchNameValidationMixin): |
62 | 881 | """The main branch view for editing the branch attributes.""" | 911 | """The main branch view for editing the branch attributes.""" |
63 | 882 | 912 | ||
64 | 883 | 913 | ||
65 | === modified file 'lib/lp/code/browser/configure.zcml' | |||
66 | --- lib/lp/code/browser/configure.zcml 2010-01-17 10:15:48 +0000 | |||
67 | +++ lib/lp/code/browser/configure.zcml 2010-01-20 00:20:29 +0000 | |||
68 | @@ -474,6 +474,13 @@ | |||
69 | 474 | permission="launchpad.Edit" | 474 | permission="launchpad.Edit" |
70 | 475 | template="../../app/templates/generic-edit.pt"/> | 475 | template="../../app/templates/generic-edit.pt"/> |
71 | 476 | <browser:page | 476 | <browser:page |
72 | 477 | name="+upgrade" | ||
73 | 478 | for="lp.code.interfaces.branch.IBranch" | ||
74 | 479 | class="lp.code.browser.branch.BranchUpgradeView" | ||
75 | 480 | facet="branches" | ||
76 | 481 | permission="launchpad.Edit" | ||
77 | 482 | template="../../app/templates/generic-edit.pt"/> | ||
78 | 483 | <browser:page | ||
79 | 477 | name="+reviewer" | 484 | name="+reviewer" |
80 | 478 | for="lp.code.interfaces.branch.IBranch" | 485 | for="lp.code.interfaces.branch.IBranch" |
81 | 479 | class="lp.code.browser.branch.BranchReviewerEditView" | 486 | class="lp.code.browser.branch.BranchReviewerEditView" |
82 | 480 | 487 | ||
83 | === modified file 'lib/lp/code/bzr.py' | |||
84 | --- lib/lp/code/bzr.py 2009-06-30 16:56:07 +0000 | |||
85 | +++ lib/lp/code/bzr.py 2010-01-20 00:20:29 +0000 | |||
86 | @@ -8,6 +8,8 @@ | |||
87 | 8 | 'BranchFormat', | 8 | 'BranchFormat', |
88 | 9 | 'BRANCH_FORMAT_UPGRADE_PATH', | 9 | 'BRANCH_FORMAT_UPGRADE_PATH', |
89 | 10 | 'ControlFormat', | 10 | 'ControlFormat', |
90 | 11 | 'CURRENT_BRANCH_FORMATS', | ||
91 | 12 | 'CURRENT_REPOSITORY_FORMATS', | ||
92 | 11 | 'RepositoryFormat', | 13 | 'RepositoryFormat', |
93 | 12 | 'REPOSITORY_FORMAT_UPGRADE_PATH', | 14 | 'REPOSITORY_FORMAT_UPGRADE_PATH', |
94 | 13 | ] | 15 | ] |
95 | @@ -222,6 +224,36 @@ | |||
96 | 222 | BZR_METADIR_1 = _format_enum(1, BzrDirMetaFormat1) | 224 | BZR_METADIR_1 = _format_enum(1, BzrDirMetaFormat1) |
97 | 223 | 225 | ||
98 | 224 | 226 | ||
99 | 227 | # A tuple of branch formats that should not suggest upgrading. | ||
100 | 228 | CURRENT_BRANCH_FORMATS = ( | ||
101 | 229 | BranchFormat.UNRECOGNIZED, | ||
102 | 230 | BranchFormat.BRANCH_REFERENCE, | ||
103 | 231 | BranchFormat.BZR_BRANCH_8, | ||
104 | 232 | BranchFormat.BZR_LOOM_1, | ||
105 | 233 | BranchFormat.BZR_LOOM_2, | ||
106 | 234 | BranchFormat.BZR_LOOM_3, | ||
107 | 235 | ) | ||
108 | 236 | |||
109 | 237 | # A tuple of repository formats that should not suggest upgrading. | ||
110 | 238 | CURRENT_REPOSITORY_FORMATS = ( | ||
111 | 239 | RepositoryFormat.UNRECOGNIZED, | ||
112 | 240 | RepositoryFormat.BZR_KNITPACK_3, | ||
113 | 241 | RepositoryFormat.BZR_KNITPACK_5, | ||
114 | 242 | RepositoryFormat.BZR_KNITPACK_5_RR, | ||
115 | 243 | RepositoryFormat.BZR_KNITPACK_6, | ||
116 | 244 | RepositoryFormat.BZR_KNITPACK_6_RR, | ||
117 | 245 | RepositoryFormat.BZR_PACK_DEV_0, | ||
118 | 246 | RepositoryFormat.BZR_PACK_DEV_0_SUBTREE, | ||
119 | 247 | RepositoryFormat.BZR_DEV_1, | ||
120 | 248 | RepositoryFormat.BZR_DEV_1_SUBTREE, | ||
121 | 249 | RepositoryFormat.BZR_DEV_2, | ||
122 | 250 | RepositoryFormat.BZR_DEV_2_SUBTREE, | ||
123 | 251 | RepositoryFormat.BZR_CHK1, | ||
124 | 252 | RepositoryFormat.BZR_CHK2, | ||
125 | 253 | RepositoryFormat.BZR_CHK_2A | ||
126 | 254 | |||
127 | 255 | ) | ||
128 | 256 | |||
129 | 225 | BRANCH_FORMAT_UPGRADE_PATH = { | 257 | BRANCH_FORMAT_UPGRADE_PATH = { |
130 | 226 | BranchFormat.UNRECOGNIZED: None, | 258 | BranchFormat.UNRECOGNIZED: None, |
131 | 227 | BranchFormat.BRANCH_REFERENCE: None, | 259 | BranchFormat.BRANCH_REFERENCE: None, |
132 | 228 | 260 | ||
133 | === modified file 'lib/lp/code/configure.zcml' | |||
134 | --- lib/lp/code/configure.zcml 2010-01-16 09:57:33 +0000 | |||
135 | +++ lib/lp/code/configure.zcml 2010-01-20 00:20:29 +0000 | |||
136 | @@ -487,6 +487,7 @@ | |||
137 | 487 | pending_writes | 487 | pending_writes |
138 | 488 | commitsForDays | 488 | commitsForDays |
139 | 489 | needs_upgrading | 489 | needs_upgrading |
140 | 490 | upgrade_pending | ||
141 | 490 | requestUpgrade | 491 | requestUpgrade |
142 | 491 | getUpgradeFormat | 492 | getUpgradeFormat |
143 | 492 | isBranchMergeable | 493 | isBranchMergeable |
144 | 493 | 494 | ||
145 | === modified file 'lib/lp/code/interfaces/branch.py' | |||
146 | --- lib/lp/code/interfaces/branch.py 2010-01-15 03:22:12 +0000 | |||
147 | +++ lib/lp/code/interfaces/branch.py 2010-01-20 00:20:29 +0000 | |||
148 | @@ -1068,6 +1068,8 @@ | |||
149 | 1068 | """ | 1068 | """ |
150 | 1069 | 1069 | ||
151 | 1070 | needs_upgrading = Attribute("Whether the branch needs to be upgraded.") | 1070 | needs_upgrading = Attribute("Whether the branch needs to be upgraded.") |
152 | 1071 | upgrade_pending = Attribute( | ||
153 | 1072 | "Whether a branch has had an upgrade requested.") | ||
154 | 1071 | 1073 | ||
155 | 1072 | def requestUpgrade(): | 1074 | def requestUpgrade(): |
156 | 1073 | """Create an IBranchUpgradeJob to upgrade this branch.""" | 1075 | """Create an IBranchUpgradeJob to upgrade this branch.""" |
157 | 1074 | 1076 | ||
158 | === modified file 'lib/lp/code/model/branch.py' | |||
159 | --- lib/lp/code/model/branch.py 2010-01-15 03:22:12 +0000 | |||
160 | +++ lib/lp/code/model/branch.py 2010-01-20 00:20:29 +0000 | |||
161 | @@ -42,7 +42,8 @@ | |||
162 | 42 | IStoreSelector, MAIN_STORE, SLAVE_FLAVOR) | 42 | IStoreSelector, MAIN_STORE, SLAVE_FLAVOR) |
163 | 43 | 43 | ||
164 | 44 | from lp.code.bzr import ( | 44 | from lp.code.bzr import ( |
166 | 45 | BranchFormat, BRANCH_FORMAT_UPGRADE_PATH, ControlFormat, RepositoryFormat, | 45 | BranchFormat, BRANCH_FORMAT_UPGRADE_PATH, ControlFormat, |
167 | 46 | CURRENT_BRANCH_FORMATS, CURRENT_REPOSITORY_FORMATS, RepositoryFormat, | ||
168 | 46 | REPOSITORY_FORMAT_UPGRADE_PATH) | 47 | REPOSITORY_FORMAT_UPGRADE_PATH) |
169 | 47 | from lp.code.enums import ( | 48 | from lp.code.enums import ( |
170 | 48 | BranchLifecycleStatus, BranchMergeControlStatus, | 49 | BranchLifecycleStatus, BranchMergeControlStatus, |
171 | @@ -995,10 +996,22 @@ | |||
172 | 995 | @property | 996 | @property |
173 | 996 | def needs_upgrading(self): | 997 | def needs_upgrading(self): |
174 | 997 | """See `IBranch`.""" | 998 | """See `IBranch`.""" |
179 | 998 | if (REPOSITORY_FORMAT_UPGRADE_PATH.get(self.repository_format, None) | 999 | if self.upgrade_pending: |
180 | 999 | or BRANCH_FORMAT_UPGRADE_PATH.get(self.branch_format, None)): | 1000 | return False |
181 | 1000 | return True | 1001 | return not ( |
182 | 1001 | return False | 1002 | self.branch_format in CURRENT_BRANCH_FORMATS and |
183 | 1003 | self.repository_format in CURRENT_REPOSITORY_FORMATS) | ||
184 | 1004 | |||
185 | 1005 | @property | ||
186 | 1006 | def upgrade_pending(self): | ||
187 | 1007 | """See `IBranch`.""" | ||
188 | 1008 | from lp.code.model.branchjob import BranchJob, BranchJobType | ||
189 | 1009 | store = Store.of(self) | ||
190 | 1010 | jobs = store.find( | ||
191 | 1011 | BranchJob, | ||
192 | 1012 | BranchJob.branch == self, | ||
193 | 1013 | BranchJob.job_type == BranchJobType.UPGRADE_BRANCH) | ||
194 | 1014 | return jobs.count() > 0 | ||
195 | 1002 | 1015 | ||
196 | 1003 | def requestUpgrade(self): | 1016 | def requestUpgrade(self): |
197 | 1004 | """See `IBranch`.""" | 1017 | """See `IBranch`.""" |
198 | 1005 | 1018 | ||
199 | === modified file 'lib/lp/code/model/branchjob.py' | |||
200 | --- lib/lp/code/model/branchjob.py 2010-01-15 03:32:46 +0000 | |||
201 | +++ lib/lp/code/model/branchjob.py 2010-01-20 00:20:29 +0000 | |||
202 | @@ -264,6 +264,8 @@ | |||
203 | 264 | """See `IBranchUpgradeJobSource`.""" | 264 | """See `IBranchUpgradeJobSource`.""" |
204 | 265 | if not branch.needs_upgrading: | 265 | if not branch.needs_upgrading: |
205 | 266 | raise AssertionError('Branch does not need upgrading.') | 266 | raise AssertionError('Branch does not need upgrading.') |
206 | 267 | if branch.upgrade_pending: | ||
207 | 268 | raise AssertionError('Branch already has upgrade pending.') | ||
208 | 267 | branch_job = BranchJob(branch, BranchJobType.UPGRADE_BRANCH, {}) | 269 | branch_job = BranchJob(branch, BranchJobType.UPGRADE_BRANCH, {}) |
209 | 268 | return cls(branch_job) | 270 | return cls(branch_job) |
210 | 269 | 271 | ||
211 | 270 | 272 | ||
212 | === modified file 'lib/lp/code/model/tests/test_branch.py' | |||
213 | --- lib/lp/code/model/tests/test_branch.py 2010-01-07 06:37:14 +0000 | |||
214 | +++ lib/lp/code/model/tests/test_branch.py 2010-01-20 00:20:29 +0000 | |||
215 | @@ -315,24 +315,33 @@ | |||
216 | 315 | SourcePackage(branch.sourcepackagename, branch.distroseries), | 315 | SourcePackage(branch.sourcepackagename, branch.distroseries), |
217 | 316 | branch.sourcepackage) | 316 | branch.sourcepackage) |
218 | 317 | 317 | ||
219 | 318 | def test_needsUpgrading_already_requested(self): | ||
220 | 319 | # A branch has a needs_upgrading attribute that returns whether or not | ||
221 | 320 | # a branch needs to be upgraded or not. If the format is | ||
222 | 321 | # unrecognized, we don't try to upgrade it. | ||
223 | 322 | branch = self.factory.makePersonalBranch( | ||
224 | 323 | branch_format=BranchFormat.BZR_BRANCH_6, | ||
225 | 324 | repository_format=RepositoryFormat.BZR_CHK_2A) | ||
226 | 325 | branch.requestUpgrade() | ||
227 | 326 | |||
228 | 327 | self.assertFalse(branch.needs_upgrading) | ||
229 | 328 | |||
230 | 318 | def test_needsUpgrading_branch_format_unrecognized(self): | 329 | def test_needsUpgrading_branch_format_unrecognized(self): |
231 | 319 | # A branch has a needs_upgrading attribute that returns whether or not | 330 | # A branch has a needs_upgrading attribute that returns whether or not |
232 | 320 | # a branch needs to be upgraded or not. If the format is | 331 | # a branch needs to be upgraded or not. If the format is |
233 | 321 | # unrecognized, we don't try to upgrade it. | 332 | # unrecognized, we don't try to upgrade it. |
234 | 322 | branch = self.factory.makePersonalBranch( | 333 | branch = self.factory.makePersonalBranch( |
236 | 323 | branch_format=BranchFormat.UNRECOGNIZED) | 334 | branch_format=BranchFormat.UNRECOGNIZED, |
237 | 335 | repository_format=RepositoryFormat.BZR_CHK_2A) | ||
238 | 324 | self.assertFalse(branch.needs_upgrading) | 336 | self.assertFalse(branch.needs_upgrading) |
239 | 325 | 337 | ||
240 | 326 | def test_needsUpgrading_branch_format_upgrade_not_needed(self): | 338 | def test_needsUpgrading_branch_format_upgrade_not_needed(self): |
241 | 327 | # A branch has a needs_upgrading attribute that returns whether or not | 339 | # A branch has a needs_upgrading attribute that returns whether or not |
242 | 328 | # a branch needs to be upgraded or not. If a branch is up to date, it | 340 | # a branch needs to be upgraded or not. If a branch is up to date, it |
243 | 329 | # doesn't need to be upgraded. | 341 | # doesn't need to be upgraded. |
244 | 330 | # | ||
245 | 331 | # XXX: JonathanLange 2009-06-06: This test needs to be changed every | ||
246 | 332 | # time Bazaar adds a new branch format. Surely we can think of a | ||
247 | 333 | # better way of testing this? | ||
248 | 334 | branch = self.factory.makePersonalBranch( | 342 | branch = self.factory.makePersonalBranch( |
250 | 335 | branch_format=BranchFormat.BZR_BRANCH_8) | 343 | branch_format=BranchFormat.BZR_BRANCH_8, |
251 | 344 | repository_format=RepositoryFormat.BZR_CHK_2A) | ||
252 | 336 | self.assertFalse(branch.needs_upgrading) | 345 | self.assertFalse(branch.needs_upgrading) |
253 | 337 | 346 | ||
254 | 338 | def test_needsUpgrading_branch_format_upgrade_needed(self): | 347 | def test_needsUpgrading_branch_format_upgrade_needed(self): |
255 | @@ -340,7 +349,8 @@ | |||
256 | 340 | # a branch needs to be upgraded or not. If a branch doesn't support | 349 | # a branch needs to be upgraded or not. If a branch doesn't support |
257 | 341 | # stacking, it needs to be upgraded. | 350 | # stacking, it needs to be upgraded. |
258 | 342 | branch = self.factory.makePersonalBranch( | 351 | branch = self.factory.makePersonalBranch( |
260 | 343 | branch_format=BranchFormat.BZR_BRANCH_6) | 352 | branch_format=BranchFormat.BZR_BRANCH_6, |
261 | 353 | repository_format=RepositoryFormat.BZR_CHK_2A) | ||
262 | 344 | self.assertTrue(branch.needs_upgrading) | 354 | self.assertTrue(branch.needs_upgrading) |
263 | 345 | 355 | ||
264 | 346 | def test_needsUpgrading_repository_format_unrecognized(self): | 356 | def test_needsUpgrading_repository_format_unrecognized(self): |
265 | @@ -348,6 +358,7 @@ | |||
266 | 348 | # a branch needs to be upgraded or not. In the repo format is | 358 | # a branch needs to be upgraded or not. In the repo format is |
267 | 349 | # unrecognized, we don't try to upgrade it. | 359 | # unrecognized, we don't try to upgrade it. |
268 | 350 | branch = self.factory.makePersonalBranch( | 360 | branch = self.factory.makePersonalBranch( |
269 | 361 | branch_format=BranchFormat.BZR_BRANCH_8, | ||
270 | 351 | repository_format=RepositoryFormat.UNRECOGNIZED) | 362 | repository_format=RepositoryFormat.UNRECOGNIZED) |
271 | 352 | self.assertFalse(branch.needs_upgrading) | 363 | self.assertFalse(branch.needs_upgrading) |
272 | 353 | 364 | ||
273 | @@ -356,6 +367,7 @@ | |||
274 | 356 | # branch needs to be upgraded or not. If the repo format is up to | 367 | # branch needs to be upgraded or not. If the repo format is up to |
275 | 357 | # date, there's no need to upgrade it. | 368 | # date, there's no need to upgrade it. |
276 | 358 | branch = self.factory.makePersonalBranch( | 369 | branch = self.factory.makePersonalBranch( |
277 | 370 | branch_format=BranchFormat.BZR_BRANCH_8, | ||
278 | 359 | repository_format=RepositoryFormat.BZR_KNITPACK_6) | 371 | repository_format=RepositoryFormat.BZR_KNITPACK_6) |
279 | 360 | self.assertFalse(branch.needs_upgrading) | 372 | self.assertFalse(branch.needs_upgrading) |
280 | 361 | 373 | ||
281 | @@ -364,6 +376,7 @@ | |||
282 | 364 | # branch needs to be upgraded or not. If the format doesn't support | 376 | # branch needs to be upgraded or not. If the format doesn't support |
283 | 365 | # stacking, it needs to be upgraded. | 377 | # stacking, it needs to be upgraded. |
284 | 366 | branch = self.factory.makePersonalBranch( | 378 | branch = self.factory.makePersonalBranch( |
285 | 379 | branch_format=BranchFormat.BZR_BRANCH_8, | ||
286 | 367 | repository_format=RepositoryFormat.BZR_REPOSITORY_4) | 380 | repository_format=RepositoryFormat.BZR_REPOSITORY_4) |
287 | 368 | self.assertTrue(branch.needs_upgrading) | 381 | self.assertTrue(branch.needs_upgrading) |
288 | 369 | 382 | ||
289 | @@ -378,6 +391,37 @@ | |||
290 | 378 | jobs, | 391 | jobs, |
291 | 379 | [job,]) | 392 | [job,]) |
292 | 380 | 393 | ||
293 | 394 | def test_requestUpgrade_no_upgrade_needed(self): | ||
294 | 395 | # If a branch doesn't need to be upgraded, requestUpgrade raises an | ||
295 | 396 | # AssertionError. | ||
296 | 397 | branch = self.factory.makeAnyBranch( | ||
297 | 398 | branch_format=BranchFormat.BZR_BRANCH_8, | ||
298 | 399 | repository_format=RepositoryFormat.BZR_CHK_2A) | ||
299 | 400 | self.assertRaises(AssertionError, branch.requestUpgrade) | ||
300 | 401 | |||
301 | 402 | def test_requestUpgrade_upgrade_pending(self): | ||
302 | 403 | # If there is a pending upgrade already requested, requestUpgrade | ||
303 | 404 | # raises an AssertionError. | ||
304 | 405 | branch = self.factory.makeAnyBranch( | ||
305 | 406 | branch_format=BranchFormat.BZR_BRANCH_6) | ||
306 | 407 | branch.requestUpgrade() | ||
307 | 408 | |||
308 | 409 | self.assertRaises(AssertionError, branch.requestUpgrade) | ||
309 | 410 | |||
310 | 411 | def test_upgradePending(self): | ||
311 | 412 | # If there is a BranchUpgradeJob pending for the branch, return True. | ||
312 | 413 | branch = self.factory.makeAnyBranch( | ||
313 | 414 | branch_format=BranchFormat.BZR_BRANCH_6) | ||
314 | 415 | branch.requestUpgrade() | ||
315 | 416 | |||
316 | 417 | self.assertTrue(branch.upgrade_pending) | ||
317 | 418 | |||
318 | 419 | def test_upgradePending_no_upgrade_requested(self): | ||
319 | 420 | # If the branch never had an upgrade requested, return False. | ||
320 | 421 | branch = self.factory.makeAnyBranch() | ||
321 | 422 | |||
322 | 423 | self.assertFalse(branch.upgrade_pending) | ||
323 | 424 | |||
324 | 381 | 425 | ||
325 | 382 | class TestBzrIdentity(TestCaseWithFactory): | 426 | class TestBzrIdentity(TestCaseWithFactory): |
326 | 383 | """Test IBranch.bzr_identity.""" | 427 | """Test IBranch.bzr_identity.""" |
327 | 384 | 428 | ||
328 | === added file 'lib/lp/code/stories/branches/xx-upgrading-branches.txt' | |||
329 | --- lib/lp/code/stories/branches/xx-upgrading-branches.txt 1970-01-01 00:00:00 +0000 | |||
330 | +++ lib/lp/code/stories/branches/xx-upgrading-branches.txt 2010-01-20 00:20:29 +0000 | |||
331 | @@ -0,0 +1,49 @@ | |||
332 | 1 | ================== | ||
333 | 2 | Upgrading Branches | ||
334 | 3 | ================== | ||
335 | 4 | |||
336 | 5 | Launchpad can upgrade branches that were in an older format to a more up to | ||
337 | 6 | date format. | ||
338 | 7 | |||
339 | 8 | |||
340 | 9 | Creating the branch | ||
341 | 10 | =================== | ||
342 | 11 | |||
343 | 12 | Branches are not available to be upgraded if they are in a more up to date | ||
344 | 13 | format. | ||
345 | 14 | |||
346 | 15 | >>> from lp.code.bzr import BranchFormat, RepositoryFormat | ||
347 | 16 | >>> login('foo.bar@canonical.com') | ||
348 | 17 | >>> domino = factory.makePerson( | ||
349 | 18 | ... name='domino', email="fats@domino.com", password="test") | ||
350 | 19 | >>> twist = factory.makeAnyBranch( | ||
351 | 20 | ... branch_format=BranchFormat.BZR_BRANCH_6, | ||
352 | 21 | ... repository_format=RepositoryFormat.BZR_CHK_2A, | ||
353 | 22 | ... owner=domino) | ||
354 | 23 | >>> branch_url = canonical_url(twist) | ||
355 | 24 | >>> logout() | ||
356 | 25 | |||
357 | 26 | |||
358 | 27 | Requesting an upgrade | ||
359 | 28 | ===================== | ||
360 | 29 | |||
361 | 30 | Only those with edit permissions on a branch can request an upgrade. | ||
362 | 31 | |||
363 | 32 | >>> nopriv_browser = setupBrowser( | ||
364 | 33 | ... auth='Basic nopriv@canonical.com:test') | ||
365 | 34 | >>> nopriv_browser.open(branch_url) | ||
366 | 35 | >>> link = nopriv_browser.getLink('Upgrade this branch') | ||
367 | 36 | Traceback (most recent call last): | ||
368 | 37 | LinkNotFoundError | ||
369 | 38 | |||
370 | 39 | >>> domino_browser = setupBrowser( | ||
371 | 40 | ... auth='Basic fats@domino.com:test') | ||
372 | 41 | >>> domino_browser.open(branch_url) | ||
373 | 42 | >>> domino_browser.getLink("Upgrade this branch").click() | ||
374 | 43 | >>> print domino_browser.url | ||
375 | 44 | http://code.launchpad.dev/~domino/.../+upgrade | ||
376 | 45 | >>> domino_browser.getControl('Upgrade').click() | ||
377 | 46 | |||
378 | 47 | >>> for msg in get_feedback_messages(domino_browser.contents): | ||
379 | 48 | ... print msg | ||
380 | 49 | An upgrade of this branch is in progress. | ||
381 | 0 | 50 | ||
382 | === modified file 'lib/lp/code/templates/branch-messages.pt' | |||
383 | --- lib/lp/code/templates/branch-messages.pt 2009-07-17 17:59:07 +0000 | |||
384 | +++ lib/lp/code/templates/branch-messages.pt 2010-01-20 00:20:29 +0000 | |||
385 | @@ -115,6 +115,12 @@ | |||
386 | 115 | tal:condition="branch/mirror_status_message" | 115 | tal:condition="branch/mirror_status_message" |
387 | 116 | tal:content="branch/mirror_status_message"> | 116 | tal:content="branch/mirror_status_message"> |
388 | 117 | </div> | 117 | </div> |
389 | 118 | <div id="upgrade-pending" | ||
390 | 119 | class="warning message" style="font-weight: normal" | ||
391 | 120 | tal:condition="branch/upgrade_pending"> | ||
392 | 121 | An upgrade of this branch is in progress. | ||
393 | 122 | </div> | ||
394 | 123 | |||
395 | 118 | </tal:hosted-branch> | 124 | </tal:hosted-branch> |
396 | 119 | 125 | ||
397 | 120 | </div> | 126 | </div> |
398 | 121 | 127 | ||
399 | === modified file 'lib/lp/code/templates/branch-metadata.pt' | |||
400 | --- lib/lp/code/templates/branch-metadata.pt 2009-09-08 21:26:03 +0000 | |||
401 | +++ lib/lp/code/templates/branch-metadata.pt 2010-01-20 00:20:29 +0000 | |||
402 | @@ -1,7 +1,8 @@ | |||
403 | 1 | <div | 1 | <div |
404 | 2 | xmlns:tal="http://xml.zope.org/namespaces/tal" | 2 | xmlns:tal="http://xml.zope.org/namespaces/tal" |
405 | 3 | xmlns:metal="http://xml.zope.org/namespaces/metal" | 3 | xmlns:metal="http://xml.zope.org/namespaces/metal" |
407 | 4 | xmlns:i18n="http://xml.zope.org/namespaces/i18n"> | 4 | xmlns:i18n="http://xml.zope.org/namespaces/i18n" |
408 | 5 | tal:define="context_menu context/menu:context"> | ||
409 | 5 | 6 | ||
410 | 6 | <div class="two-column-list"> | 7 | <div class="two-column-list"> |
411 | 7 | <dl id="branch-format" tal:condition="context/branch_format"> | 8 | <dl id="branch-format" tal:condition="context/branch_format"> |
412 | @@ -18,5 +19,13 @@ | |||
413 | 18 | <dd tal:content="structure context/stacked_on/fmt:bzr-link" /> | 19 | <dd tal:content="structure context/stacked_on/fmt:bzr-link" /> |
414 | 19 | </dl> | 20 | </dl> |
415 | 20 | </div> | 21 | </div> |
416 | 22 | <div class="actions"> | ||
417 | 23 | <div | ||
418 | 24 | tal:define="link context_menu/upgrade_branch" | ||
419 | 25 | tal:condition="link/enabled" | ||
420 | 26 | > | ||
421 | 27 | <a tal:replace="structure link/fmt:link" /> | ||
422 | 28 | </div> | ||
423 | 29 | </div> | ||
424 | 21 | 30 | ||
425 | 22 | </div> | 31 | </div> |
Hi there-
This branch makes some changes to the branch upgrade structure and the way a
branch determines whether or not it needs to be upgraded. Most of the original
code was pre-2.0, and now that bzr 2.0 has been released, the formats are a
little more stable, and we won't need to be concerned too much about changing
formats anymore.
Instead of saying X format needs to be upgraded to Y format, we can just
upgrade it and it'll go to the 2.0 format regardless of the original format (as
opposed to the potential downgrade of older bzr).
Cheers,
Paul