Code review comment for lp:~rockstar/launchpad/upgrade-ui

Revision history for this message
Paul Hummer (rockstar) wrote :

Hrm, the diff seems to be confused... Here's the real diff:

=== modified file 'lib/lp/code/browser/branch.py'
--- lib/lp/code/browser/branch.py 2010-01-07 05:03:46 +0000
+++ lib/lp/code/browser/branch.py 2010-01-20 00:19:44 +0000
@@ -20,6 +20,7 @@
     'BranchEditMenu',
     'BranchInProductView',
     'BranchSparkView',
+ 'BranchUpgradeView',
     'BranchURL',
     'BranchView',
     'BranchSubscriptionsView',
@@ -230,7 +231,7 @@
     links = [
         'add_subscriber', 'browse_revisions', 'link_bug',
         'link_blueprint', 'register_merge', 'source', 'subscription',
- 'edit_status']
+ 'edit_status', 'upgrade_branch']

     @enabled_with_permission('launchpad.Edit')
     def edit_status(self):
@@ -297,6 +298,14 @@
         url = self.context.codebrowse_url('files')
         return Link(url, text, icon='info', enabled=enabled)

+ @enabled_with_permission('launchpad.Edit')
+ def upgrade_branch(self):
+ enabled = False
+ if self.context.needs_upgrading:
+ enabled = True
+ return Link(
+ '+upgrade', 'Upgrade this branch', icon='edit', enabled=enabled)
+

 class DecoratedBug:
     """Provide some additional attributes to a normal bug."""
@@ -876,6 +885,27 @@
         return canonical_url(self.context)

+class BranchUpgradeView(LaunchpadFormView):
+ """Used to upgrade a branch."""
+
+ schema = IBranch
+ field_names = []
+
+ @property
+ def page_title(self):
+ return smartquote('Upgrade branch "%s"' % self.context.displayname)
+
+ @property
+ def next_url(self):
+ return canonical_url(self.context)
+
+ cancel_url = next_url
+
+ @action('Upgrade', name='upgrade_branch')
+ def upgrade_branch_action(self, action, data):
+ self.context.requestUpgrade()
+
+
 class BranchEditView(BranchEditFormView, BranchNameValidationMixin):
     """The main branch view for editing the branch attributes."""

=== modified file 'lib/lp/code/browser/configure.zcml'
--- lib/lp/code/browser/configure.zcml 2010-01-14 01:48:19 +0000
+++ lib/lp/code/browser/configure.zcml 2010-01-20 00:19:44 +0000
@@ -474,6 +474,13 @@
         permission="launchpad.Edit"
         template="../../app/templates/generic-edit.pt"/>
     <browser:page
+ name="+upgrade"
+ for="lp.code.interfaces.branch.IBranch"
+ class="lp.code.browser.branch.BranchUpgradeView"
+ facet="branches"
+ permission="launchpad.Edit"
+ template="../../app/templates/generic-edit.pt"/>
+ <browser:page
         name="+reviewer"
         for="lp.code.interfaces.branch.IBranch"
         class="lp.code.browser.branch.BranchReviewerEditView"

=== 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:19:44 +0000
@@ -0,0 +1,49 @@
+==================
+Upgrading Branches
+==================
+
+Launchpad can upgrade branches that were in an older format to a more up to
+date format.
+
+
+Creating the branch
+===================
+
+Branches are not available to be upgraded if they are in a more up to date
+format.
+
+ >>> from lp.code.bzr import BranchFormat, RepositoryFormat
+ >>> login('<email address hidden>')
+ >>> domino = factory.makePerson(
+ ... name='domino', <email address hidden>", password="test")
+ >>> twist = factory.makeAnyBranch(
+ ... branch_format=BranchFormat.BZR_BRANCH_6,
+ ... repository_format=RepositoryFormat.BZR_CHK_2A,
+ ... owner=domino)
+ >>> branch_url = canonical_url(twist)
+ >>> logout()
+
+
+Requesting an upgrade
+=====================
+
+Only those with edit permissions on a branch can request an upgrade.
+
+ >>> nopriv_browser = setupBrowser(
+ ... auth='Basic <email address hidden>:test')
+ >>> nopriv_browser.open(branch_url)
+ >>> link = nopriv_browser.getLink('Upgrade this branch')
+ Traceback (most recent call last):
+ LinkNotFoundError
+
+ >>> domino_browser = setupBrowser(
+ ... auth='Basic <email address hidden>:test')
+ >>> domino_browser.open(branch_url)
+ >>> domino_browser.getLink("Upgrade this branch").click()
+ >>> print domino_browser.url
+ http://code.launchpad.dev/~domino/.../+upgrade
+ >>> domino_browser.getControl('Upgrade').click()
+
+ >>> for msg in get_feedback_messages(domino_browser.contents):
+ ... print msg
+ An upgrade of this branch is in progress.

=== 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:19:44 +0000
@@ -115,6 +115,12 @@
          tal:condition="branch/mirror_status_message"
          tal:content="branch/mirror_status_message">
     </div>
+ <div id="upgrade-pending"
+ class="warning message" style="font-weight: normal"
+ tal:condition="branch/upgrade_pending">
+ An upgrade of this branch is in progress.
+ </div>
+
   </tal:hosted-branch>

 </div>

=== 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:19:44 +0000
@@ -1,7 +1,8 @@
 <div
   xmlns:tal="http://xml.zope.org/namespaces/tal"
   xmlns:metal="http://xml.zope.org/namespaces/metal"
- xmlns:i18n="http://xml.zope.org/namespaces/i18n">
+ xmlns:i18n="http://xml.zope.org/namespaces/i18n"
+ tal:define="context_menu context/menu:context">

   <div class="two-column-list">
     <dl id="branch-format" tal:condition="context/branch_format">
@@ -18,5 +19,13 @@
       <dd tal:content="structure context/stacked_on/fmt:bzr-link" />
     </dl>
   </div>
+ <div class="actions">
+ <div
+ tal:define="link context_menu/upgrade_branch"
+ tal:condition="link/enabled"
+ >
+ <a tal:replace="structure link/fmt:link" />
+ </div>
+ </div>

 </div>

« Back to merge proposal