launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #03137
[Merge] lp:~stevenk/launchpad/dsd-hide-child-diff into lp:launchpad
Steve Kowalik has proposed merging lp:~stevenk/launchpad/dsd-hide-child-diff into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~stevenk/launchpad/dsd-hide-child-diff/+merge/55685
Don't display the child difference diff if the child's source version is the same as the base version, because the generated diff will be empty.
--
https://code.launchpad.net/~stevenk/launchpad/dsd-hide-child-diff/+merge/55685
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/dsd-hide-child-diff into lp:launchpad.
=== modified file 'lib/lp/registry/browser/distroseriesdifference.py'
--- lib/lp/registry/browser/distroseriesdifference.py 2010-11-23 23:22:27 +0000
+++ lib/lp/registry/browser/distroseriesdifference.py 2011-03-31 06:03:34 +0000
@@ -132,6 +132,11 @@
return self.request.is_ajax and check_permission(
'launchpad.Edit', self.context)
+ @property
+ def display_child_diff(self):
+ """Only show the child diff if we need to."""
+ return (not self.context.source_version == self.context.base_version)
+
class DistroSeriesDifferenceDisplayComment:
"""Used simply to provide `IComment` for rendering."""
=== modified file 'lib/lp/registry/browser/tests/test_distroseriesdifference_views.py'
--- lib/lp/registry/browser/tests/test_distroseriesdifference_views.py 2011-03-28 20:45:09 +0000
+++ lib/lp/registry/browser/tests/test_distroseriesdifference_views.py 2011-03-31 06:03:34 +0000
@@ -5,17 +5,14 @@
__metaclass__ = type
+from BeautifulSoup import BeautifulSoup
import re
-
-from BeautifulSoup import BeautifulSoup
+import transaction
from zope.component import getUtility
from canonical.launchpad.webapp.servers import LaunchpadTestRequest
from canonical.launchpad.webapp.testing import verifyObject
-from canonical.testing import (
- DatabaseFunctionalLayer,
- LaunchpadFunctionalLayer,
- )
+from canonical.testing import LaunchpadFunctionalLayer
from lp.registry.browser.distroseriesdifference import (
DistroSeriesDifferenceDisplayComment,
)
@@ -44,7 +41,7 @@
class DistroSeriesDifferenceTestCase(TestCaseWithFactory):
- layer = DatabaseFunctionalLayer
+ layer = LaunchpadFunctionalLayer
def test_provides_conversation(self):
# The DSDView provides a conversation implementation.
@@ -164,6 +161,47 @@
ds_diff, '+listing-distroseries-extra', request=request)
self.assertFalse(view.show_edit_options)
+ def test_does_display_child_diff(self):
+ # If the child's latest published version is not the same as the base
+ # version, we display two links to two diffs.
+ changelog_lfa = self.factory.makeChangelog(
+ 'foo', ['0.1-1derived1', '0.1-1'])
+ parent_changelog_lfa = self.factory.makeChangelog(
+ 'foo', ['0.1-2', '0.1-1'])
+ transaction.commit() # Yay, librarian.
+ ds_diff = self.factory.makeDistroSeriesDifference(versions={
+ 'derived': '0.1-1derived1',
+ 'parent': '0.1-2',
+ }, changelogs={
+ 'derived': changelog_lfa,
+ 'parent': parent_changelog_lfa})
+
+ self.assertEqual('0.1-1', ds_diff.base_version)
+ view = create_initialized_view(ds_diff, '+listing-distroseries-extra')
+ soup = BeautifulSoup(view())
+ tags = soup.findAll('span')
+ self.assertEqual(2, len(tags))
+
+ def test_do_not_display_child_diff(self):
+ # If the child's latest published version is the same as the base
+ # version, we don't display the link to the diff.
+ changelog_lfa = self.factory.makeChangelog('foo', ['0.30-1'])
+ parent_changelog_lfa = self.factory.makeChangelog(
+ 'foo', ['0.32-1', '0.30-1'])
+ transaction.commit() # Yay, librarian.
+ ds_diff = self.factory.makeDistroSeriesDifference(versions={
+ 'derived': '0.30-1',
+ 'parent': '0.32-1',
+ }, changelogs={
+ 'derived': changelog_lfa,
+ 'parent': parent_changelog_lfa})
+
+ self.assertEqual('0.30-1', ds_diff.base_version)
+ view = create_initialized_view(ds_diff, '+listing-distroseries-extra')
+ soup = BeautifulSoup(view())
+ tags = soup.findAll('span')
+ self.assertEqual(1, len(tags))
+
class DistroSeriesDifferenceTemplateTestCase(TestCaseWithFactory):
=== modified file 'lib/lp/registry/templates/distroseriesdifference-listing-extra.pt'
--- lib/lp/registry/templates/distroseriesdifference-listing-extra.pt 2011-03-25 13:23:20 +0000
+++ lib/lp/registry/templates/distroseriesdifference-listing-extra.pt 2011-03-31 06:03:34 +0000
@@ -50,7 +50,7 @@
</dt>
<dd>
<ul class="package-diff-status">
- <tal:source-diff-option condition="context/source_pub">
+ <tal:source-diff-option condition="view/display_child_diff">
<li tal:condition="context/package_diff">
<span tal:condition="context/package_diff/status/enumvalue:PENDING"
class="sprite PENDING">