Merge lp://staging/~bac/launchpad/bug-524302 into lp://staging/launchpad/db-devel

Proposed by Brad Crittenden
Status: Merged
Approved by: Curtis Hovey
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp://staging/~bac/launchpad/bug-524302
Merge into: lp://staging/launchpad/db-devel
Prerequisite: lp://staging/~bac/launchpad/productseries-js
Diff against target: 1830 lines (+1077/-379)
23 files modified
lib/lp/app/templates/base-layout-macros.pt (+5/-2)
lib/lp/code/browser/bazaar.py (+3/-1)
lib/lp/code/browser/branch.py (+3/-2)
lib/lp/code/browser/configure.zcml (+0/-7)
lib/lp/code/interfaces/codeimport.py (+0/-10)
lib/lp/code/javascript/tests/test_productseries_setbranch.js (+3/-3)
lib/lp/code/model/codeimport.py (+1/-49)
lib/lp/code/model/tests/test_codeimport.py (+0/-194)
lib/lp/code/stories/branches/xx-bazaar-home.txt (+1/-1)
lib/lp/code/stories/branches/xx-branchmergeproposals.txt (+4/-1)
lib/lp/code/stories/branches/xx-propose-for-merging.txt (+2/-0)
lib/lp/code/stories/codeimport/xx-codeimport-list.txt (+0/-72)
lib/lp/code/stories/codeimport/xx-codeimport-view.txt (+3/-3)
lib/lp/code/templates/bazaar-index.pt (+1/-1)
lib/lp/code/templates/branchmergeproposal-pagelet-summary.pt (+4/-0)
lib/lp/registry/browser/configure.zcml (+7/-0)
lib/lp/registry/browser/productseries.py (+380/-24)
lib/lp/registry/browser/tests/productseries-setbranch-view.txt (+339/-0)
lib/lp/registry/stories/productseries/xx-productseries-set-branch.txt (+147/-0)
lib/lp/registry/templates/productseries-codesummary.pt (+3/-3)
lib/lp/registry/templates/productseries-linkbranch.pt (+38/-2)
lib/lp/registry/templates/productseries-setbranch.pt (+129/-0)
lib/lp/testing/factory.py (+4/-4)
To merge this branch: bzr merge lp://staging/~bac/launchpad/bug-524302
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code, ui Approve
Edwin Grubbs (community) code ui* Approve
Review via email: mp+22180@code.staging.launchpad.net

Commit message

Create a productseries/+setbranch page for setting/creating/importing a branch for the productseries.

Description of the change

Add productseries/+setbranch view to consolidate many other views dealing with creating/mirroring/importing branches. This view allows a user to do one of those things (though the terminology is hidden) and links the branch to the product series.

The view is not currently navigable from anywhere. Eventually it will replace +linkbranch.

A new view test has been created:

bin/test -vvt productseries-setbranch-views.txt

It may be preferred to roll that test into the productseries-views.txt test but it was expeditious to create it stand alone.

There are some known issues listed in the BRANCH.TODO file.

To demo, create a new project and go to https://launchpad.dev/<newproject>/trunk/+setbranch

To post a comment you must log in.
Revision history for this message
Edwin Grubbs (edwin-grubbs) wrote :
Download full text (31.1 KiB)

Hi Brad,

This interface is a nice improvement. I've only set the series for a
branch once before, and I totally did it wrong because I was on the wrong
form.

Since I don't know if you are planning a followup branch for your
BRANCH.TODO items, I'm marking this:
    needs-fixing

It seems odd that productseries-setbranch.pt is in lp.registry but
productseries-setbranch.js is in lp.code. There are some more
comments below.

-Edwin

>=== modified file 'BRANCH.TODO'
>--- BRANCH.TODO 2010-03-19 07:13:15 +0000
>+++ BRANCH.TODO 2010-03-26 15:28:25 +0000
>@@ -2,3 +2,10 @@
> # landing. There is a test to ensure it is empty in trunk. If there is
> # stuff still here when you are ready to land, the items should probably
> # be converted to bugs so they can be scheduled.
>+
>+TODO:
>+
>+* validation errors give misleading messages
>+* uncaught constraint error on duplicate of code import URL
>+* code.lp.dev/proj/series displays the overview page but it should
>+ direct away from the code vhost
>=== modified file 'lib/lp/registry/browser/productseries.py'
>--- lib/lp/registry/browser/productseries.py 2010-03-23 00:39:45 +0000
>+++ lib/lp/registry/browser/productseries.py 2010-03-26 15:28:25 +0000
>@@ -644,7 +658,340 @@
> self.next_url = canonical_url(product)
>
>
>-class ProductSeriesLinkBranchView(LaunchpadEditFormView):
>+LINK_LP_BZR = 'link-lp-bzr'
>+CREATE_NEW = 'create-new'
>+IMPORT_EXTERNAL = 'import-external'
>+
>+
>+def _getBranchTypeVocabulary():
>+ items = (
>+ (LINK_LP_BZR,
>+ _("Link to a Bazaar branch already on Launchpad")),
>+ (CREATE_NEW,
>+ _("Create a new, empty branch in Launchpad and "
>+ "link to this series")),
>+ (IMPORT_EXTERNAL,
>+ _("Import a branch hosted somewhere else")),
>+ )
>+ terms = [
>+ SimpleTerm(name, name, label) for name, label in items]
>+ return SimpleVocabulary(terms)

Why is this a function instead of a constant? If you are
trying to avoid extra variables defined in the module, you could
just do:
  BRANCH_TYPE_VOCABULARY = SimpleVocabulary((
      SimpleTerm(LINK_LP_BZR, LINK_LP_BZR, 'foo'),
      ...

>+class RevisionControlSystemsExtended(RevisionControlSystems):
>+ """External RCS plus Bazaar."""
>+ BZR = DBItem(99, """
>+ Bazaar
>+
>+ External Bazaar branch.
>+ """)
>+
>+
>+class SetBranchForm(Interface):
>+ """The fields presented on the form for setting a branch."""
>+
>+ use_template(
>+ ICodeImport,
>+ ['cvs_module'])
>+
>+ rcs_type = Choice(title=_("Type of RCS"),
>+ required=False, vocabulary=RevisionControlSystemsExtended,
>+ description=_(
>+ "The version control system to import from. "))
>+
>+ repo_url = URIField(
>+ title=_("Branch URL"), required=True,
>+ description=_("The URL of the branch."),
>+ allowed_schemes=["http", "https"],
>+ allow_userinfo=False,
>+ allow_port=True,
>+ allow_query=False,
>+ allow_fragment=False,
>+ trailing_slash=False)
>+
>+ branch_location = copy_field(
>+ IProductSeries['branch'],
>+ __name__='branch_location',
>+ titl...

review: Needs Fixing
Revision history for this message
Brad Crittenden (bac) wrote :

Thanks for the excellent review Edwin. I've incorporated all of your suggestions. Having the view create the rendered items was a little more difficult due to the two different types of vocabularies.

I also took care of the items in my BRANCH.TODO list including not masking widget validation errors (which you also noted) and catching an error condition when an import URL has been requested before to avoid a db IntegrityError.

Finally I added a story test to show the high-level working of the new page.

Revision history for this message
Brad Crittenden (bac) wrote :
Revision history for this message
Edwin Grubbs (edwin-grubbs) wrote :
Download full text (19.5 KiB)

Hi Brad,

Thanks for making all the changes. This branch is definitely a lot harder than
I thought.

Since this branch is not linked anywhere yet, I would be ok with you deferring
items 2 and 3 below to a followup branch so you can land this before it gets
any bigger. I also have some comments inline, but they shouldn't be too hard
to fix in this branch.

merge-conditional

1. jslint: Lint found in '/home/egrubbs/canonical/lp-branches/review/lib/canonical/launchpad/javascript/code/tests/test_productseries_setbranch.js':
    Line 65 character 15: The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype.
                for (var sub in subscribers) {

    The easiest way to avoid this potential Javascript problem is:
                    Y.each(subscribers, function(sub) {

2. If the Branch name already exists, it appears as if the form does nothing.

3. If there is an existing imported SVN branch on a given URL, the form will
give you the correct error message, but if there is an existing imported BZR
branch on a given URL, it will give you this exception.

Traceback (most recent call last):
  File "/home/egrubbs/canonical/lp-sourcedeps/eggs/zope.publisher-3.10.0-py2.5.egg/zope/publisher/publish.py", line 134, in publish
    result = publication.callObject(request, obj)
  File "/home/egrubbs/canonical/lp-branches/review/lib/canonical/launchpad/webapp/publication.py", line 422, in callObject
    return mapply(ob, request.getPositionalArguments(), request)
  File "/home/egrubbs/canonical/lp-sourcedeps/eggs/zope.publisher-3.10.0-py2.5.egg/zope/publisher/publish.py", line 109, in mapply
    return debug_call(obj, args)
  File "/home/egrubbs/canonical/lp-sourcedeps/eggs/zope.publisher-3.10.0-py2.5.egg/zope/publisher/publish.py", line 115, in debug_call
    return obj(*args)
  File "/home/egrubbs/canonical/lp-branches/review/lib/canonical/launchpad/webapp/publisher.py", line 274, in __call__
    self.initialize()
  File "/home/egrubbs/canonical/lp-branches/review/lib/canonical/launchpad/webapp/launchpadform.py", line 111, in initialize
    self.form_result = action.success(data)
  File "/home/egrubbs/canonical/lp-sourcedeps/eggs/zope.formlib-3.6.0-py2.5.egg/zope/formlib/form.py", line 606, in success
    return self.success_handler(self.form, self, data)
  File "/home/egrubbs/canonical/lp-branches/review/lib/lp/registry/browser/productseries.py", line 993, in update_action
    data['repo_url'])
  File "/home/egrubbs/canonical/lp-branches/review/lib/lp/registry/browser/productseries.py", line 1040, in _createBzrBranch
    url=repo_url)
  File "/home/egrubbs/canonical/lp-branches/review/lib/lp/code/model/branchnamespace.py", line 103, in createBranch
    implicit_subscription = self.getPrivacySubscriber()
  File "/home/egrubbs/canonical/lp-branches/review/lib/lp/code/model/branchnamespace.py", line 343, in getPrivacySubscriber
    rule = self.product.getBranchVisibilityRuleForTeam(self.owner)
  File "/home/egrubbs/canonical/lp-branches/review/lib/lp/code/model/branchvisibilitypolicy.py", line 108, in getBranchVisibilityRuleForTeam
    item = self._selectOneBranchVisibilityTeamPolicy(team)
  File "/home/...

review: Approve (code ui*)
Revision history for this message
Brad Crittenden (bac) wrote :

Edwin,

Thanks for the review and the ideas about cleaning up the render() method.

I am going to defer the other two items for another, quick follow-on branch.

The incremental is at:
http://pastebin.ubuntu.com/409614/

Revision history for this message
Brad Crittenden (bac) wrote :

Curtis a screenshot is available at http://people.canonical.com/~bac/setbranch.png

Revision history for this message
Curtis Hovey (sinzui) wrote :

Hi Brad.

I think Branch name and owner are confusing. I think they subordinate to importing or creating a new branch but they appear to be enabled for setting the series to an existing branch. I know I cannot change the owner or name for the first option. I expect these two options to be, and appear to be, disbaled when I choose Link to a bazaar branch in Launchpad.

I do not see any test to verify the script is loaded on the page. Either we need to show that the
script is in the page or use windmill to verify it executed.

review: Needs Information (code, ui)
Revision history for this message
Brad Crittenden (bac) wrote :

As we discussed, the branch name and owner are conditionally disabled correctly, though the screen shot does not show it well.

The extra windmill test will be added to the follow up branch.

Revision history for this message
Curtis Hovey (sinzui) :
review: Approve (code, ui)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to status/vote changes: