Merge lp://staging/~bryce/launchpad/lp-617698-forwarding into lp://staging/launchpad/db-devel

Proposed by Bryce Harrington
Status: Rejected
Rejected by: Curtis Hovey
Proposed branch: lp://staging/~bryce/launchpad/lp-617698-forwarding
Merge into: lp://staging/launchpad/db-devel
Prerequisite: lp://staging/~bryce/launchpad/lp-617695-linkui
Diff against target: 1109 lines (+705/-45)
17 files modified
lib/canonical/launchpad/scripts/bzremotecomponentfinder.py (+6/-2)
lib/lp/bugs/browser/bugalsoaffects.py (+23/-7)
lib/lp/bugs/browser/bugtracker.py (+106/-4)
lib/lp/bugs/browser/configure.zcml (+9/-0)
lib/lp/bugs/browser/tests/bugtask-adding-views.txt (+1/-1)
lib/lp/bugs/browser/tests/test_bugtracker_component.py (+189/-0)
lib/lp/bugs/browser/widgets/bugtask.py (+20/-0)
lib/lp/bugs/doc/bugtracker.txt (+13/-20)
lib/lp/bugs/interfaces/bugtracker.py (+8/-2)
lib/lp/bugs/model/bugtracker.py (+29/-9)
lib/lp/bugs/templates/bugtracker-edit-component.pt (+16/-0)
lib/lp/bugs/templates/bugtracker-index.pt (+2/-0)
lib/lp/bugs/templates/bugtracker-portlet-components.pt (+36/-0)
lib/lp/registry/configure.zcml (+1/-0)
lib/lp/registry/interfaces/sourcepackage.py (+2/-0)
lib/lp/registry/model/sourcepackage.py (+11/-0)
lib/lp/services/features/scopes.py (+233/-0)
To merge this branch: bzr merge lp://staging/~bryce/launchpad/lp-617698-forwarding
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) code Approve
Bryce Harrington (community) Needs Resubmitting
Review via email: mp+41003@code.staging.launchpad.net

Commit message

Implement remote_component support when forwarding bugs.

Description of the change

Implement remote_component support when forwarding bugs.

This branch is dependent on the lp:~bryce/launchpad/lp-617695-linkui so that branch should be landed first.

This causes the 'component' field to be properly filled in for the bugzilla submission page when forwarding a bug report to a remote project.

lint has been checked. ec2 test has been run and passed successfully.

== Testing ==
For manual testing of this feature locally, I first ran cronscripts/update-bugzilla-remote-components.py to populate the mozilla and gnome bugzillas instances in the sample data.

[ Next I turned the feature flag on via the psql statement 'insert into featureflag (scope, priority, flag, value) values ('default', 1, 'bugtracker_components', 'on');'. However I had so much trouble getting feature flags to work properly that I've dropped this from the branch. ]

Next, I configured the alsa-utils project as using the gnome bugzilla, at https://bugs.launchpad.dev/alsa-utils/+configure-bugtracker by selecting "In a registered bug tracker" and typing in "gnome-bugs"; for the field "Project ID in bug tracker" I typed in "zenity" just to pick a random existing project.

Navigating to https://bugs.launchpad.dev/bugs/bugtrackers/gnome-bugs I scrolled down to the end and under the 'zenity' component group I clicked the icon next to 'general'. On the linking form I specified 'alsa-utils' as the package. I doublechecked that zenity/general now showed a link to 'alsa-utils'.

I logged out, and verified as anonymous that the edit links don't show up on https://bugs.launchpad.dev/bugs/bugtrackers/gnome-bugs.

Finally, after re-logging in, I filed a new bug report against alsa-utils, clicked "Also affects project", clicked the "bug filing form" link, and verified it filled in the component field in the bugzilla form properly.

To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :
Download full text (25.6 KiB)

Hi Bryce,

There's lots of stuff that I'm unfamiliar with here, so please forgive me for holding you up with a "Needs Information" vote. I have some big questions about the UI and test coverage.

Otherwise it would be Approved, with some smaller notes and superficial issues.

> === modified file 'lib/canonical/launchpad/scripts/bzremotecomponentfinder.py'
> --- lib/canonical/launchpad/scripts/bzremotecomponentfinder.py 2010-10-20 00:24:50 +0000
> +++ lib/canonical/launchpad/scripts/bzremotecomponentfinder.py 2010-11-16 19:54:52 +0000
> @@ -117,7 +117,6 @@
> self.static_bugzilla_text = static_bugzilla_text
>
> def getRemoteProductsAndComponents(self, bugtracker_name=None):
> - """"""

There's supposed to be a docstring. It looks as if this one was put in
as a placeholder: "I'll write one later, and if I forget, the reviewer
will spot it." Can you think of what they mant to write?

The fact that this got into the codebase may be a clue that we're
being too sloppy in our reviews.

> === modified file 'lib/canonical/widgets/bugtask.py'
> --- lib/canonical/widgets/bugtask.py 2010-11-08 12:52:43 +0000
> +++ lib/canonical/widgets/bugtask.py 2010-11-16 19:54:52 +0000
> @@ -495,6 +495,25 @@
> return distribution
>
>
> +class UbuntuSourcePackageNameWidget(
> + BugTaskSourcePackageNameWidget):

Why is this line broken? There's plenty of space. Did you rename this
from a longer original name?

> + """Package widget where the distribution can be assumed as Ubuntu

There should be a full stop at the end of the sentence.

> + distribution_name = "ubuntu"
> +
> + def getDistribution(self):
> + """See `BugTaskSourcePackageNameWidget`"""
> + distribution = getUtility(IDistributionSet).getByName(
> + self.distribution_name)
> + if distribution is None:
> + raise UnexpectedFormData(
> + "No such distribution: %s" % self.distribution_name)
> + return distribution

Would it be worth having a comment here to say why you have to override
this method?

Also, doesn't this method amount to a difficult spelling for

    return getUtility(ILaunchpadCelebrities).ubuntu

?

> === modified file 'lib/lp/bugs/browser/bugalsoaffects.py'
> --- lib/lp/bugs/browser/bugalsoaffects.py 2010-09-03 03:12:39 +0000
> +++ lib/lp/bugs/browser/bugalsoaffects.py 2010-11-16 19:54:52 +0000
> @@ -664,8 +664,20 @@
> title = bug.title
> description = u"Originally reported at:\n %s\n\n%s" % (
> canonical_url(bug), bug.description)
> + remote_component = ""
> + comp_group = target.bugtracker.getRemoteComponentGroup(
> + target.remote_product)
> +
> + # Look up the remote component if we have the necessary info
> + if comp_group is not None and data.get('add_packaging', False):
> + package_name = self.context.target.sourcepackagename
> + for component in comp_group.components:
> + if (component.distro_source_package is not None and
> + component.distro_source_package.name == package_name):
> + ...

review: Needs Information
9926. By Bryce Harrington

Review comments by Jeroen.

9927. By Bryce Harrington

Review by Jerone: Code can be simplified using the ubuntu celebrity

9928. By Bryce Harrington

Almost all of the method is now an "else" clause after an early
return; we can drop the else and make the code stand on its own.

9929. By Bryce Harrington

Review by Jerone: Make if statement easier to read

9930. By Bryce Harrington

Review by Jeroen: Split out lookup functionality to separate routine

9931. By Bryce Harrington

Review by Jeroen: Find way to maintain visual separation between the two
if conditions and the body

9932. By Bryce Harrington

Review by Jeroen: Note interface change in docstring

9933. By Bryce Harrington

Review by Jeroen: Paragraph is too detailed for a doctest and mostly is
just stating obvious stuff about a function's parameters that doesn't
belong here.

9934. By Bryce Harrington

Review by Jeroen: Simplify setup by using helper functions.

9935. By Bryce Harrington

Review by Jeroen: Split up linking test into two tests

9936. By Bryce Harrington

Review by Jeroen: Use dict to eliminate some if clauses

9937. By Bryce Harrington

Review by Jeroen: Put a space in "% ("

9938. By Bryce Harrington

Review by Jeroen: Construct full name in a variable to make easier to follow

9939. By Bryce Harrington

Review by Jeroen: Use more verbose but conventional way of calling find.

9940. By Bryce Harrington

Re-merge db-devel trunk

9941. By Bryce Harrington

Review by Jeroen: State how the view should behave in this situation.

9942. By Bryce Harrington

Unnecessary to re-test output from the first component since this was
tested previously and is just setup here.

9943. By Bryce Harrington

Review by Jeroen: It doesn't matter how the first component got linked
so just treat it as setup and link the package directly, so that this
test focuses just on testing one thing.

9944. By Bryce Harrington

Review by Jeroen: You could use
self.assertTextMatchesExpressionIgnoreWhitespace for the
verification.

9945. By Bryce Harrington

Avoid potential extra database call when there are no components

9946. By Bryce Harrington

Review by Jeroen: Use URL formatter for links

9947. By Bryce Harrington

Review by Jeroen: Only display editing links if there is a logged in user

9948. By Bryce Harrington

Omit the nonbreaking space for anonymous users

9949. By Bryce Harrington

Preliminary implementation of test for checking anonymous edits

9950. By Bryce Harrington

Re-merge db-devel trunk

9951. By Bryce Harrington

Fix typo in find conditional

9952. By Bryce Harrington

ILaunchpadCelebrities needs declared

9953. By Bryce Harrington

Fix up several test errors

Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Hi Bryce,

I see that you've done a lot of work on this branch since my initial review. Looks a lot better (though watch that double blank line below test_no_anonymous_edits ☺).

Please let me know when it's ready for the next round and hopefully we can get it landed!

9954. By Bryce Harrington

Use a store call to delete components.

9955. By Bryce Harrington

Enable testing generated links

Featureflags and testing view/user are interfering, so disable them
temporarily.

9956. By Bryce Harrington

Adjust create_initialized_view() call to set up proper logged in user

9957. By Bryce Harrington

Further experimentation with feature flags.

Just can't sort out how to make it work in a unittest. :-/

9958. By Bryce Harrington

Re-merge trunk

9959. By Bryce Harrington

Giving up on feature flags stuff and ripping it out.

The flags work fine in the browser when setting the flag manually, but
I just can't sort out how to get the unittests to recognize it. This
issue has been blocking progress on this branch for months now, and I've
failed to find anyone who can explain how to make it work properly.
Martin Pool suggested just dropping it and moving on, which sounds good
to me.

9960. By Bryce Harrington

Re-merge db-devel trunk

9961. By Bryce Harrington

Adjust to new widgets location

Revision history for this message
Bryce Harrington (bryce) wrote :

Hi Jeroen, yeah the extensiveness of the review made for a rather Herculean labor...

I'm afraid since returning from launchpad X.org has monopolized my attention, however I think this branch is more or less done and ready to go, but I haven't looked at it in a while; I'll check it over again.

9962. By Bryce Harrington

Compare string against the '.name' field of DSP rather than object itself.

9963. By Bryce Harrington

Revert Jeroen's change for component form so editing components works.

In review, Jeroen noticed I had an ugly if clause to look up the source
package name field for the component edit form, and suggested replacing
it with a dict to look up the fields.

Unfortunately, it's not so simple. The SourcePackageName object is not
a string property, so has to be handled differently than other kinds of
objects (we have to explicitly reference it's .name field to get the
string out of it). So the None check and special handling of this field
is required. Otherwise, an Oops occurs when it tries to fill in the
package name field with the object rather than the string.

9964. By Bryce Harrington

Re-merge db-devel trunk

Revision history for this message
Bryce Harrington (bryce) wrote :

Alright, I exercised the code for a while, found a couple issues that were introduced due to changes from the review and got them fixed up.

I also re-merged db-devel and fixed a minor conflict; unfortunately it seems launchpad has moved from postgres 8.3 to 8.4, and the upgrade scripts seem to have borked up my system, so I can no longer make schema or run tests locally. Hopefully it's correct though.

I don't know when I'll next get some spare moments to get back to launchpad work, so if there are any remaining minor niggles like whitespace or formatting or UI tweaks or whatnot, if you don't mind please feel free to correct those. Also, if someone else could handle testing and landing this baby I would *really* appreciate getting it off my plate.

review: Needs Resubmitting
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Bryce,

Thanks for sticking with it! I'm re-reviewing it. Meanwhile, to get your Launchpad instance working again:

 * Make sure your postgres config has 8.4 running on port 5432. If you install it side by side with an existing 8.3, it'll try to evade to port 5433 instead. Get rid of the 8.3.

 * There's a script called launchpad-database-setup that re-creates your entire database. This is highly destructive (so better not do it if you have any other postgres databases on that system) but tends to fix these problems.

Jeroen

Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :
Download full text (4.8 KiB)

= Approving =

This looks like Pretty Good Stuff now. The commit logs show lots of changes (and actually explain them, which is a nice touch).

I see just 2 things that need fixing, but I'm sure that won't be helped by any further nannying from me. See "Important" below. Some other notes that you may want to consider or improve at your option: nice to have but not worth further delay.

== Design ==

I see a few documented assumptions (very thoughtful, by the way!) about Ubuntu being involved. Does that fit with the ongoing work for supporting derived distributions? Probably depends on the requirements for derived distros.

If not, it may present some new development tasks for derived distros. I wouldn't hold up your branch for it unless it poses some kind of serious problem.

== Important ==

=== Jack-in-the-box file ===

According to the MP diff, you're _adding_ lib/lp/services/features/scopes.py. Which already exists, with contents apparently similar or identical to what's in the diff. How can that happen!?

=== Model/view boundaries ===

In lib/lp/bugs/browser/bugtracker.py, you query the database directly:

188 + def updateContextFromData(self, data, context=None):
[...]
208 + # Has this source package already been assigned to a component?
209 + pkgs = Store.of(component).find(
210 + BugTrackerComponent,
211 + BugTrackerComponent.distribution == distribution.id,
212 + BugTrackerComponent.source_package_name ==
213 + pkg.sourcepackagename.id)
214 + if pkgs.count() > 0:
215 + self.request.response.addNotification(
216 + "The %s source package is already linked to %s in %s" % (
217 + sourcepackagename, component_full_name, distro_name))
218 + return

Querying the database from browser code is frowned upon: it's a job for the model, not for the view.

This particular query does a job that can be concisely defined, so that's good. (In fact some say that a block of code like this with a defining comment on top should almost certainly be a method of its own). I didn't find any method that does exactly this, but there's no reason why there shouldn't be. I think SourcePackage would be a good place.

(Also note that a count() on the query can be relatively expensive and deliver more information than you need. If all you need to know is whether there are any at all, use is_empty() instead.)

== Style ==

In lib/lp/bugs/browser/bugalsoaffects.py:

62 + # Look up the remote component if we have the necessary info
63 + #if data.get('add_packaging', False):
64 + comp_group = target.bugtracker.getRemoteComponentGroup(
65 + target.remote_product)

There's still a commented-out line in there.

In lib/lp/bugs/browser/tests/test_bugtracker_component.py: setUp() still creates a few objects that most of the tests don't actually care about.

Also in lib/lp/bugs/browser/tests/test_bugtracker_component.py, test_no_anonymous_edits:

353 + expected_html = """
354 + <h2>Components</h2>
355 + <ul>
356 + <li>
357 + <strong>alpha</strong>
358 + <ul>
359 + <li>
360 + ...

Read more...

review: Approve (code)
Revision history for this message
Bryce Harrington (bryce) wrote :

"Finally, a question: in lib/lp/bugs/templates/bugtracker-edit-component.pt I notice that the root tag is bug-tracker-edit-component. Can we do that!? My TAL knowledge is mostly cribbed off existing templates, but I thought that for whatever reason we only make up our own tags in the tal/metal namespaces."

==> product-cvereport.pt <==
<product-cve-report

==> remotebug-index.pt <==
<bug-tracker-remote-bug-index

==> malone-index.pt <==
<malone-index

==> distribution-cvereport.pt <==
<distribution-cve-report

==> distribution-upstream-bug-report.pt <==
<distribution-upstream-bug-report

==> distroseries-cvereport.pt <==
<distroseries-cve-report

Seems there are a number of other instances where this is done... I was cribbing off the cve templates since they seemed close to what I was trying to do. If this style is wrong it looks like it'll need fixed in a number of places.

9965. By Bryce Harrington

Review from jeroen: "Also note that a count() on the query can be
relatively expensive and deliver more information than you need. If all
you need to know is whether there are any at all, use is_empty() instead"

9966. By Bryce Harrington

Review from jeroen: "Commented-out code is a bad thing."

9967. By Bryce Harrington

Review from jeroen: Typo for "searched"?

9968. By Bryce Harrington

Review from jeroen: Move component/sourcepackage check to a new
member function of SourcePackage.

Revision history for this message
Bryce Harrington (bryce) wrote :

"According to the MP diff, you're _adding_ lib/lp/services/features/scopes.py. Which already exists, with contents apparently similar or identical to what's in the diff. How can that happen!?"

According to my local tree, this only came in as part of a re-merge of db-devel and is not created locally. I certainly never added it myself. I have no idea why it's showing up in the merge proposal diff, nor any clue on how to correct that.

Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

To be honest, I get these things as well sometimes and don't know how to explain them. Often I'll just produce a diff, clean it up, and patch it into a new branch.

Revision history for this message
Robert Collins (lifeless) wrote :

File a bug about the odd diff?

Revision history for this message
Bryce Harrington (bryce) wrote :

I think there may have been some overlap in the review comments for this MP and the MP for the branch this depends on, https://code.launchpad.net/~bryce/launchpad/lp-617695-linkui/+merge/39679, so I'm going to wait until that branch lands (perhaps tomorrow?) and then do as Jeroen suggests and just generate a new diff and re-merge it into a new branch.

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

I marked this old review rejected because I think I see code that has already landed in devel. If I am wrong, please submit a new merge proposal with devel.

Unmerged revisions

9968. By Bryce Harrington

Review from jeroen: Move component/sourcepackage check to a new
member function of SourcePackage.

9967. By Bryce Harrington

Review from jeroen: Typo for "searched"?

9966. By Bryce Harrington

Review from jeroen: "Commented-out code is a bad thing."

9965. By Bryce Harrington

Review from jeroen: "Also note that a count() on the query can be
relatively expensive and deliver more information than you need. If all
you need to know is whether there are any at all, use is_empty() instead"

9964. By Bryce Harrington

Re-merge db-devel trunk

9963. By Bryce Harrington

Revert Jeroen's change for component form so editing components works.

In review, Jeroen noticed I had an ugly if clause to look up the source
package name field for the component edit form, and suggested replacing
it with a dict to look up the fields.

Unfortunately, it's not so simple. The SourcePackageName object is not
a string property, so has to be handled differently than other kinds of
objects (we have to explicitly reference it's .name field to get the
string out of it). So the None check and special handling of this field
is required. Otherwise, an Oops occurs when it tries to fill in the
package name field with the object rather than the string.

9962. By Bryce Harrington

Compare string against the '.name' field of DSP rather than object itself.

9961. By Bryce Harrington

Adjust to new widgets location

9960. By Bryce Harrington

Re-merge db-devel trunk

9959. By Bryce Harrington

Giving up on feature flags stuff and ripping it out.

The flags work fine in the browser when setting the flag manually, but
I just can't sort out how to get the unittests to recognize it. This
issue has been blocking progress on this branch for months now, and I've
failed to find anyone who can explain how to make it work properly.
Martin Pool suggested just dropping it and moving on, which sounds good
to me.

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: