Merge lp:~rockstar/launchpad/upgrade-job-2.0-changes into lp:launchpad

Proposed by Paul Hummer
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
Reviewer Review Type Date Requested Status
Edwin Grubbs (community) code Approve
Review via email: mp+17701@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Paul Hummer (rockstar) wrote :

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

Revision history for this message
Paul Hummer (rockstar) wrote :
Download full text (9.6 KiB)

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/code/bzr.py'
--- 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 @@
     'BranchFormat',
     'BRANCH_FORMAT_UPGRADE_PATH',
     'ControlFormat',
+ 'CURRENT_BRANCH_FORMATS',
+ 'CURRENT_REPOSITORY_FORMATS',
     'RepositoryFormat',
     'REPOSITORY_FORMAT_UPGRADE_PATH',
     ]
@@ -222,6 +224,36 @@
     BZR_METADIR_1 = _format_enum(1, BzrDirMetaFormat1)

+# A tuple of branch formats that should not suggest upgrading.
+CURRENT_BRANCH_FORMATS = (
+ BranchFormat.UNRECOGNIZED,
+ BranchFormat.BRANCH_REFERENCE,
+ BranchFormat.BZR_BRANCH_8,
+ BranchFormat.BZR_LOOM_1,
+ BranchFormat.BZR_LOOM_2,
+ BranchFormat.BZR_LOOM_3,
+)
+
+# A tuple of repository formats that should not suggest upgrading.
+CURRENT_REPOSITORY_FORMATS = (
+ RepositoryFormat.UNRECOGNIZED,
+ RepositoryFormat.BZR_KNITPACK_3,
+ RepositoryFormat.BZR_KNITPACK_5,
+ RepositoryFormat.BZR_KNITPACK_5_RR,
+ RepositoryFormat.BZR_KNITPACK_6,
+ RepositoryFormat.BZR_KNITPACK_6_RR,
+ RepositoryFormat.BZR_PACK_DEV_0,
+ RepositoryFormat.BZR_PACK_DEV_0_SUBTREE,
+ RepositoryFormat.BZR_DEV_1,
+ RepositoryFormat.BZR_DEV_1_SUBTREE,
+ RepositoryFormat.BZR_DEV_2,
+ RepositoryFormat.BZR_DEV_2_SUBTREE,
+ RepositoryFormat.BZR_CHK1,
+ RepositoryFormat.BZR_CHK2,
+ RepositoryFormat.BZR_CHK_2A
+
+)
+
 BRANCH_FORMAT_UPGRADE_PATH = {
     BranchFormat.UNRECOGNIZED: None,
     BranchFormat.BRANCH_REFERENCE: None,

=== modified file 'lib/lp/code/configure.zcml'
--- lib/lp/code/configure.zcml 2010-01-06 14:14:35 +0000
+++ lib/lp/code/configure.zcml 2010-01-18 01:19:38 +0000
@@ -487,6 +487,7 @@
                     pending_writes
                     commitsForDays
                     needs_upgrading
+ upgrade_pending
                     requestUpgrade
                     getUpgradeFormat
                     isBranchMergeable

=== modified file 'lib/lp/code/interfaces/branch.py'
--- lib/lp/code/interfaces/branch.py 2010-01-06 12:15:42 +0000
+++ lib/lp/code/interfaces/branch.py 2010-01-18 01:19:39 +0000
@@ -1057,6 +1057,8 @@
         """

     needs_upgrading = Attribute("Whether the branch needs to be upgraded.")
+ upgrade_pending = Attribute(
+ "Whether a branch has had an upgrade requested.")

     def requestUpgrade():
         """Create an IBranchUpgradeJob to upgrade this branch."""

=== modified file 'lib/lp/code/model/branch.py'
--- lib/lp/code/model/branch.py 2009-12-11 00:56:16 +0000
+++ lib/lp/code/model/branch.py 2010-01-19 21:57:57 +0000
@@ -42,7 +42,8 @@
     IStoreSelector, MAIN_STORE, SLAVE_FLAVOR)

 from lp.code.bzr import (
- BranchFormat, BRANCH_FORMAT_UPGRADE_PATH, ControlFormat, RepositoryFormat,
+ BranchFormat, BRANCH_FORMAT_UPGRADE_PATH, ControlFormat,
+ CURRENT_BRANCH_FORMATS, CURRENT_REPOSITORY_FORMATS, RepositoryFormat,
     REPOSITORY_FORMAT_UPGRADE_PATH)
 from lp.code.enums import (
     BranchLifecycleStatus, BranchMergeControlStatus,
@@ -991,10 +992,22 @@
     @property
  ...

Read more...

Revision history for this message
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/code/model/tests/test_branch.py'
> --- lib/lp/code/model/tests/test_branch.py 2010-01-07 06:37:14 +0000
> +++ lib/lp/code/model/tests/test_branch.py 2010-01-19 22:00:02 +0000
> @@ -315,24 +315,33 @@
> SourcePackage(branch.sourcepackagename, branch.distroseries),
> branch.sourcepackage)
>
> + def test_needsUpgrading_already_requested(self):
> + # 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.makePersonalBranch(
> + branch_format=BranchFormat.BZR_BRANCH_6,
> + repository_format=RepositoryFormat.BZR_CHK_2A)
> + branch.requestUpgrade()
> +
> + self.assertFalse(branch.needs_upgrading)
> +
> def test_needsUpgrading_branch_format_unrecognized(self):
> # 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.makePersonalBranch(
> - branch_format=BranchFormat.UNRECOGNIZED)
> + branch_format=BranchFormat.UNRECOGNIZED,
> + repository_format=RepositoryFormat.BZR_CHK_2A)
> self.assertFalse(branch.needs_upgrading)
>
> def test_needsUpgrading_branch_format_upgrade_not_needed(self):
> # 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/

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/code/browser/branch.py'
--- lib/lp/code/browser/branch.py 2010-01-17 00:59:01 +0000
+++ lib/lp/code/browser/branch.py 2010-01-20 00:20:29 +0000
@@ -20,6 +20,7 @@
20 'BranchEditMenu',20 'BranchEditMenu',
21 'BranchInProductView',21 'BranchInProductView',
22 'BranchSparkView',22 'BranchSparkView',
23 'BranchUpgradeView',
23 'BranchURL',24 'BranchURL',
24 'BranchView',25 'BranchView',
25 'BranchSubscriptionsView',26 'BranchSubscriptionsView',
@@ -231,7 +232,7 @@
231 links = [232 links = [
232 'add_subscriber', 'browse_revisions', 'link_bug',233 'add_subscriber', 'browse_revisions', 'link_bug',
233 'link_blueprint', 'register_merge', 'source', 'subscription',234 'link_blueprint', 'register_merge', 'source', 'subscription',
234 'edit_status']235 'edit_status', 'upgrade_branch']
235236
236 @enabled_with_permission('launchpad.Edit')237 @enabled_with_permission('launchpad.Edit')
237 def edit_status(self):238 def edit_status(self):
@@ -298,6 +299,14 @@
298 url = self.context.codebrowse_url('files')299 url = self.context.codebrowse_url('files')
299 return Link(url, text, icon='info', enabled=enabled)300 return Link(url, text, icon='info', enabled=enabled)
300301
302 @enabled_with_permission('launchpad.Edit')
303 def upgrade_branch(self):
304 enabled = False
305 if self.context.needs_upgrading:
306 enabled = True
307 return Link(
308 '+upgrade', 'Upgrade this branch', icon='edit', enabled=enabled)
309
301310
302class DecoratedBug:311class DecoratedBug:
303 """Provide some additional attributes to a normal bug."""312 """Provide some additional attributes to a normal bug."""
@@ -877,6 +886,27 @@
877 return canonical_url(self.context)886 return canonical_url(self.context)
878887
879888
889class BranchUpgradeView(LaunchpadFormView):
890 """Used to upgrade a branch."""
891
892 schema = IBranch
893 field_names = []
894
895 @property
896 def page_title(self):
897 return smartquote('Upgrade branch "%s"' % self.context.displayname)
898
899 @property
900 def next_url(self):
901 return canonical_url(self.context)
902
903 cancel_url = next_url
904
905 @action('Upgrade', name='upgrade_branch')
906 def upgrade_branch_action(self, action, data):
907 self.context.requestUpgrade()
908
909
880class BranchEditView(BranchEditFormView, BranchNameValidationMixin):910class BranchEditView(BranchEditFormView, BranchNameValidationMixin):
881 """The main branch view for editing the branch attributes."""911 """The main branch view for editing the branch attributes."""
882912
883913
=== modified file 'lib/lp/code/browser/configure.zcml'
--- lib/lp/code/browser/configure.zcml 2010-01-17 10:15:48 +0000
+++ lib/lp/code/browser/configure.zcml 2010-01-20 00:20:29 +0000
@@ -474,6 +474,13 @@
474 permission="launchpad.Edit"474 permission="launchpad.Edit"
475 template="../../app/templates/generic-edit.pt"/>475 template="../../app/templates/generic-edit.pt"/>
476 <browser:page476 <browser:page
477 name="+upgrade"
478 for="lp.code.interfaces.branch.IBranch"
479 class="lp.code.browser.branch.BranchUpgradeView"
480 facet="branches"
481 permission="launchpad.Edit"
482 template="../../app/templates/generic-edit.pt"/>
483 <browser:page
477 name="+reviewer"484 name="+reviewer"
478 for="lp.code.interfaces.branch.IBranch"485 for="lp.code.interfaces.branch.IBranch"
479 class="lp.code.browser.branch.BranchReviewerEditView"486 class="lp.code.browser.branch.BranchReviewerEditView"
480487
=== modified file 'lib/lp/code/bzr.py'
--- lib/lp/code/bzr.py 2009-06-30 16:56:07 +0000
+++ lib/lp/code/bzr.py 2010-01-20 00:20:29 +0000
@@ -8,6 +8,8 @@
8 'BranchFormat',8 'BranchFormat',
9 'BRANCH_FORMAT_UPGRADE_PATH',9 'BRANCH_FORMAT_UPGRADE_PATH',
10 'ControlFormat',10 'ControlFormat',
11 'CURRENT_BRANCH_FORMATS',
12 'CURRENT_REPOSITORY_FORMATS',
11 'RepositoryFormat',13 'RepositoryFormat',
12 'REPOSITORY_FORMAT_UPGRADE_PATH',14 'REPOSITORY_FORMAT_UPGRADE_PATH',
13 ]15 ]
@@ -222,6 +224,36 @@
222 BZR_METADIR_1 = _format_enum(1, BzrDirMetaFormat1)224 BZR_METADIR_1 = _format_enum(1, BzrDirMetaFormat1)
223225
224226
227# A tuple of branch formats that should not suggest upgrading.
228CURRENT_BRANCH_FORMATS = (
229 BranchFormat.UNRECOGNIZED,
230 BranchFormat.BRANCH_REFERENCE,
231 BranchFormat.BZR_BRANCH_8,
232 BranchFormat.BZR_LOOM_1,
233 BranchFormat.BZR_LOOM_2,
234 BranchFormat.BZR_LOOM_3,
235)
236
237# A tuple of repository formats that should not suggest upgrading.
238CURRENT_REPOSITORY_FORMATS = (
239 RepositoryFormat.UNRECOGNIZED,
240 RepositoryFormat.BZR_KNITPACK_3,
241 RepositoryFormat.BZR_KNITPACK_5,
242 RepositoryFormat.BZR_KNITPACK_5_RR,
243 RepositoryFormat.BZR_KNITPACK_6,
244 RepositoryFormat.BZR_KNITPACK_6_RR,
245 RepositoryFormat.BZR_PACK_DEV_0,
246 RepositoryFormat.BZR_PACK_DEV_0_SUBTREE,
247 RepositoryFormat.BZR_DEV_1,
248 RepositoryFormat.BZR_DEV_1_SUBTREE,
249 RepositoryFormat.BZR_DEV_2,
250 RepositoryFormat.BZR_DEV_2_SUBTREE,
251 RepositoryFormat.BZR_CHK1,
252 RepositoryFormat.BZR_CHK2,
253 RepositoryFormat.BZR_CHK_2A
254
255)
256
225BRANCH_FORMAT_UPGRADE_PATH = {257BRANCH_FORMAT_UPGRADE_PATH = {
226 BranchFormat.UNRECOGNIZED: None,258 BranchFormat.UNRECOGNIZED: None,
227 BranchFormat.BRANCH_REFERENCE: None,259 BranchFormat.BRANCH_REFERENCE: None,
228260
=== modified file 'lib/lp/code/configure.zcml'
--- lib/lp/code/configure.zcml 2010-01-16 09:57:33 +0000
+++ lib/lp/code/configure.zcml 2010-01-20 00:20:29 +0000
@@ -487,6 +487,7 @@
487 pending_writes487 pending_writes
488 commitsForDays488 commitsForDays
489 needs_upgrading489 needs_upgrading
490 upgrade_pending
490 requestUpgrade491 requestUpgrade
491 getUpgradeFormat492 getUpgradeFormat
492 isBranchMergeable493 isBranchMergeable
493494
=== modified file 'lib/lp/code/interfaces/branch.py'
--- lib/lp/code/interfaces/branch.py 2010-01-15 03:22:12 +0000
+++ lib/lp/code/interfaces/branch.py 2010-01-20 00:20:29 +0000
@@ -1068,6 +1068,8 @@
1068 """1068 """
10691069
1070 needs_upgrading = Attribute("Whether the branch needs to be upgraded.")1070 needs_upgrading = Attribute("Whether the branch needs to be upgraded.")
1071 upgrade_pending = Attribute(
1072 "Whether a branch has had an upgrade requested.")
10711073
1072 def requestUpgrade():1074 def requestUpgrade():
1073 """Create an IBranchUpgradeJob to upgrade this branch."""1075 """Create an IBranchUpgradeJob to upgrade this branch."""
10741076
=== modified file 'lib/lp/code/model/branch.py'
--- lib/lp/code/model/branch.py 2010-01-15 03:22:12 +0000
+++ lib/lp/code/model/branch.py 2010-01-20 00:20:29 +0000
@@ -42,7 +42,8 @@
42 IStoreSelector, MAIN_STORE, SLAVE_FLAVOR)42 IStoreSelector, MAIN_STORE, SLAVE_FLAVOR)
4343
44from lp.code.bzr import (44from lp.code.bzr import (
45 BranchFormat, BRANCH_FORMAT_UPGRADE_PATH, ControlFormat, RepositoryFormat,45 BranchFormat, BRANCH_FORMAT_UPGRADE_PATH, ControlFormat,
46 CURRENT_BRANCH_FORMATS, CURRENT_REPOSITORY_FORMATS, RepositoryFormat,
46 REPOSITORY_FORMAT_UPGRADE_PATH)47 REPOSITORY_FORMAT_UPGRADE_PATH)
47from lp.code.enums import (48from lp.code.enums import (
48 BranchLifecycleStatus, BranchMergeControlStatus,49 BranchLifecycleStatus, BranchMergeControlStatus,
@@ -995,10 +996,22 @@
995 @property996 @property
996 def needs_upgrading(self):997 def needs_upgrading(self):
997 """See `IBranch`."""998 """See `IBranch`."""
998 if (REPOSITORY_FORMAT_UPGRADE_PATH.get(self.repository_format, None)999 if self.upgrade_pending:
999 or BRANCH_FORMAT_UPGRADE_PATH.get(self.branch_format, None)):1000 return False
1000 return True1001 return not (
1001 return False1002 self.branch_format in CURRENT_BRANCH_FORMATS and
1003 self.repository_format in CURRENT_REPOSITORY_FORMATS)
1004
1005 @property
1006 def upgrade_pending(self):
1007 """See `IBranch`."""
1008 from lp.code.model.branchjob import BranchJob, BranchJobType
1009 store = Store.of(self)
1010 jobs = store.find(
1011 BranchJob,
1012 BranchJob.branch == self,
1013 BranchJob.job_type == BranchJobType.UPGRADE_BRANCH)
1014 return jobs.count() > 0
10021015
1003 def requestUpgrade(self):1016 def requestUpgrade(self):
1004 """See `IBranch`."""1017 """See `IBranch`."""
10051018
=== modified file 'lib/lp/code/model/branchjob.py'
--- lib/lp/code/model/branchjob.py 2010-01-15 03:32:46 +0000
+++ lib/lp/code/model/branchjob.py 2010-01-20 00:20:29 +0000
@@ -264,6 +264,8 @@
264 """See `IBranchUpgradeJobSource`."""264 """See `IBranchUpgradeJobSource`."""
265 if not branch.needs_upgrading:265 if not branch.needs_upgrading:
266 raise AssertionError('Branch does not need upgrading.')266 raise AssertionError('Branch does not need upgrading.')
267 if branch.upgrade_pending:
268 raise AssertionError('Branch already has upgrade pending.')
267 branch_job = BranchJob(branch, BranchJobType.UPGRADE_BRANCH, {})269 branch_job = BranchJob(branch, BranchJobType.UPGRADE_BRANCH, {})
268 return cls(branch_job)270 return cls(branch_job)
269271
270272
=== modified file 'lib/lp/code/model/tests/test_branch.py'
--- lib/lp/code/model/tests/test_branch.py 2010-01-07 06:37:14 +0000
+++ lib/lp/code/model/tests/test_branch.py 2010-01-20 00:20:29 +0000
@@ -315,24 +315,33 @@
315 SourcePackage(branch.sourcepackagename, branch.distroseries),315 SourcePackage(branch.sourcepackagename, branch.distroseries),
316 branch.sourcepackage)316 branch.sourcepackage)
317317
318 def test_needsUpgrading_already_requested(self):
319 # A branch has a needs_upgrading attribute that returns whether or not
320 # a branch needs to be upgraded or not. If the format is
321 # unrecognized, we don't try to upgrade it.
322 branch = self.factory.makePersonalBranch(
323 branch_format=BranchFormat.BZR_BRANCH_6,
324 repository_format=RepositoryFormat.BZR_CHK_2A)
325 branch.requestUpgrade()
326
327 self.assertFalse(branch.needs_upgrading)
328
318 def test_needsUpgrading_branch_format_unrecognized(self):329 def test_needsUpgrading_branch_format_unrecognized(self):
319 # A branch has a needs_upgrading attribute that returns whether or not330 # A branch has a needs_upgrading attribute that returns whether or not
320 # a branch needs to be upgraded or not. If the format is331 # a branch needs to be upgraded or not. If the format is
321 # unrecognized, we don't try to upgrade it.332 # unrecognized, we don't try to upgrade it.
322 branch = self.factory.makePersonalBranch(333 branch = self.factory.makePersonalBranch(
323 branch_format=BranchFormat.UNRECOGNIZED)334 branch_format=BranchFormat.UNRECOGNIZED,
335 repository_format=RepositoryFormat.BZR_CHK_2A)
324 self.assertFalse(branch.needs_upgrading)336 self.assertFalse(branch.needs_upgrading)
325337
326 def test_needsUpgrading_branch_format_upgrade_not_needed(self):338 def test_needsUpgrading_branch_format_upgrade_not_needed(self):
327 # A branch has a needs_upgrading attribute that returns whether or not339 # A branch has a needs_upgrading attribute that returns whether or not
328 # a branch needs to be upgraded or not. If a branch is up to date, it340 # a branch needs to be upgraded or not. If a branch is up to date, it
329 # doesn't need to be upgraded.341 # doesn't need to be upgraded.
330 #
331 # XXX: JonathanLange 2009-06-06: This test needs to be changed every
332 # time Bazaar adds a new branch format. Surely we can think of a
333 # better way of testing this?
334 branch = self.factory.makePersonalBranch(342 branch = self.factory.makePersonalBranch(
335 branch_format=BranchFormat.BZR_BRANCH_8)343 branch_format=BranchFormat.BZR_BRANCH_8,
344 repository_format=RepositoryFormat.BZR_CHK_2A)
336 self.assertFalse(branch.needs_upgrading)345 self.assertFalse(branch.needs_upgrading)
337346
338 def test_needsUpgrading_branch_format_upgrade_needed(self):347 def test_needsUpgrading_branch_format_upgrade_needed(self):
@@ -340,7 +349,8 @@
340 # a branch needs to be upgraded or not. If a branch doesn't support349 # a branch needs to be upgraded or not. If a branch doesn't support
341 # stacking, it needs to be upgraded.350 # stacking, it needs to be upgraded.
342 branch = self.factory.makePersonalBranch(351 branch = self.factory.makePersonalBranch(
343 branch_format=BranchFormat.BZR_BRANCH_6)352 branch_format=BranchFormat.BZR_BRANCH_6,
353 repository_format=RepositoryFormat.BZR_CHK_2A)
344 self.assertTrue(branch.needs_upgrading)354 self.assertTrue(branch.needs_upgrading)
345355
346 def test_needsUpgrading_repository_format_unrecognized(self):356 def test_needsUpgrading_repository_format_unrecognized(self):
@@ -348,6 +358,7 @@
348 # a branch needs to be upgraded or not. In the repo format is358 # a branch needs to be upgraded or not. In the repo format is
349 # unrecognized, we don't try to upgrade it.359 # unrecognized, we don't try to upgrade it.
350 branch = self.factory.makePersonalBranch(360 branch = self.factory.makePersonalBranch(
361 branch_format=BranchFormat.BZR_BRANCH_8,
351 repository_format=RepositoryFormat.UNRECOGNIZED)362 repository_format=RepositoryFormat.UNRECOGNIZED)
352 self.assertFalse(branch.needs_upgrading)363 self.assertFalse(branch.needs_upgrading)
353364
@@ -356,6 +367,7 @@
356 # branch needs to be upgraded or not. If the repo format is up to367 # branch needs to be upgraded or not. If the repo format is up to
357 # date, there's no need to upgrade it.368 # date, there's no need to upgrade it.
358 branch = self.factory.makePersonalBranch(369 branch = self.factory.makePersonalBranch(
370 branch_format=BranchFormat.BZR_BRANCH_8,
359 repository_format=RepositoryFormat.BZR_KNITPACK_6)371 repository_format=RepositoryFormat.BZR_KNITPACK_6)
360 self.assertFalse(branch.needs_upgrading)372 self.assertFalse(branch.needs_upgrading)
361373
@@ -364,6 +376,7 @@
364 # branch needs to be upgraded or not. If the format doesn't support376 # branch needs to be upgraded or not. If the format doesn't support
365 # stacking, it needs to be upgraded.377 # stacking, it needs to be upgraded.
366 branch = self.factory.makePersonalBranch(378 branch = self.factory.makePersonalBranch(
379 branch_format=BranchFormat.BZR_BRANCH_8,
367 repository_format=RepositoryFormat.BZR_REPOSITORY_4)380 repository_format=RepositoryFormat.BZR_REPOSITORY_4)
368 self.assertTrue(branch.needs_upgrading)381 self.assertTrue(branch.needs_upgrading)
369382
@@ -378,6 +391,37 @@
378 jobs,391 jobs,
379 [job,])392 [job,])
380393
394 def test_requestUpgrade_no_upgrade_needed(self):
395 # If a branch doesn't need to be upgraded, requestUpgrade raises an
396 # AssertionError.
397 branch = self.factory.makeAnyBranch(
398 branch_format=BranchFormat.BZR_BRANCH_8,
399 repository_format=RepositoryFormat.BZR_CHK_2A)
400 self.assertRaises(AssertionError, branch.requestUpgrade)
401
402 def test_requestUpgrade_upgrade_pending(self):
403 # If there is a pending upgrade already requested, requestUpgrade
404 # raises an AssertionError.
405 branch = self.factory.makeAnyBranch(
406 branch_format=BranchFormat.BZR_BRANCH_6)
407 branch.requestUpgrade()
408
409 self.assertRaises(AssertionError, branch.requestUpgrade)
410
411 def test_upgradePending(self):
412 # If there is a BranchUpgradeJob pending for the branch, return True.
413 branch = self.factory.makeAnyBranch(
414 branch_format=BranchFormat.BZR_BRANCH_6)
415 branch.requestUpgrade()
416
417 self.assertTrue(branch.upgrade_pending)
418
419 def test_upgradePending_no_upgrade_requested(self):
420 # If the branch never had an upgrade requested, return False.
421 branch = self.factory.makeAnyBranch()
422
423 self.assertFalse(branch.upgrade_pending)
424
381425
382class TestBzrIdentity(TestCaseWithFactory):426class TestBzrIdentity(TestCaseWithFactory):
383 """Test IBranch.bzr_identity."""427 """Test IBranch.bzr_identity."""
384428
=== added file 'lib/lp/code/stories/branches/xx-upgrading-branches.txt'
--- lib/lp/code/stories/branches/xx-upgrading-branches.txt 1970-01-01 00:00:00 +0000
+++ lib/lp/code/stories/branches/xx-upgrading-branches.txt 2010-01-20 00:20:29 +0000
@@ -0,0 +1,49 @@
1==================
2Upgrading Branches
3==================
4
5Launchpad can upgrade branches that were in an older format to a more up to
6date format.
7
8
9Creating the branch
10===================
11
12Branches are not available to be upgraded if they are in a more up to date
13format.
14
15 >>> from lp.code.bzr import BranchFormat, RepositoryFormat
16 >>> login('foo.bar@canonical.com')
17 >>> domino = factory.makePerson(
18 ... name='domino', email="fats@domino.com", password="test")
19 >>> twist = factory.makeAnyBranch(
20 ... branch_format=BranchFormat.BZR_BRANCH_6,
21 ... repository_format=RepositoryFormat.BZR_CHK_2A,
22 ... owner=domino)
23 >>> branch_url = canonical_url(twist)
24 >>> logout()
25
26
27Requesting an upgrade
28=====================
29
30Only those with edit permissions on a branch can request an upgrade.
31
32 >>> nopriv_browser = setupBrowser(
33 ... auth='Basic nopriv@canonical.com:test')
34 >>> nopriv_browser.open(branch_url)
35 >>> link = nopriv_browser.getLink('Upgrade this branch')
36 Traceback (most recent call last):
37 LinkNotFoundError
38
39 >>> domino_browser = setupBrowser(
40 ... auth='Basic fats@domino.com:test')
41 >>> domino_browser.open(branch_url)
42 >>> domino_browser.getLink("Upgrade this branch").click()
43 >>> print domino_browser.url
44 http://code.launchpad.dev/~domino/.../+upgrade
45 >>> domino_browser.getControl('Upgrade').click()
46
47 >>> for msg in get_feedback_messages(domino_browser.contents):
48 ... print msg
49 An upgrade of this branch is in progress.
050
=== modified file 'lib/lp/code/templates/branch-messages.pt'
--- lib/lp/code/templates/branch-messages.pt 2009-07-17 17:59:07 +0000
+++ lib/lp/code/templates/branch-messages.pt 2010-01-20 00:20:29 +0000
@@ -115,6 +115,12 @@
115 tal:condition="branch/mirror_status_message"115 tal:condition="branch/mirror_status_message"
116 tal:content="branch/mirror_status_message">116 tal:content="branch/mirror_status_message">
117 </div>117 </div>
118 <div id="upgrade-pending"
119 class="warning message" style="font-weight: normal"
120 tal:condition="branch/upgrade_pending">
121 An upgrade of this branch is in progress.
122 </div>
123
118 </tal:hosted-branch>124 </tal:hosted-branch>
119125
120</div>126</div>
121127
=== modified file 'lib/lp/code/templates/branch-metadata.pt'
--- lib/lp/code/templates/branch-metadata.pt 2009-09-08 21:26:03 +0000
+++ lib/lp/code/templates/branch-metadata.pt 2010-01-20 00:20:29 +0000
@@ -1,7 +1,8 @@
1<div1<div
2 xmlns:tal="http://xml.zope.org/namespaces/tal"2 xmlns:tal="http://xml.zope.org/namespaces/tal"
3 xmlns:metal="http://xml.zope.org/namespaces/metal"3 xmlns:metal="http://xml.zope.org/namespaces/metal"
4 xmlns:i18n="http://xml.zope.org/namespaces/i18n">4 xmlns:i18n="http://xml.zope.org/namespaces/i18n"
5 tal:define="context_menu context/menu:context">
56
6 <div class="two-column-list">7 <div class="two-column-list">
7 <dl id="branch-format" tal:condition="context/branch_format">8 <dl id="branch-format" tal:condition="context/branch_format">
@@ -18,5 +19,13 @@
18 <dd tal:content="structure context/stacked_on/fmt:bzr-link" />19 <dd tal:content="structure context/stacked_on/fmt:bzr-link" />
19 </dl>20 </dl>
20 </div>21 </div>
22 <div class="actions">
23 <div
24 tal:define="link context_menu/upgrade_branch"
25 tal:condition="link/enabled"
26 >
27 <a tal:replace="structure link/fmt:link" />
28 </div>
29 </div>
2130
22</div>31</div>