launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #03410
[Merge] lp:~rvb/launchpad/parent-pack-diff-computed-bug-768293 into lp:launchpad
Raphaël Victor Badin has proposed merging lp:~rvb/launchpad/parent-pack-diff-computed-bug-768293 into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #768293 in Launchpad itself: "Requesting some diffs in +localpackagediffs results in a 502 error"
https://bugs.launchpad.net/launchpad/+bug/768293
For more details, see:
https://code.launchpad.net/~rvb/launchpad/parent-pack-diff-computed-bug-768293/+merge/58665
The package diff between a parent and the base version should not be computed if the parent version is the same as the base version.
= Test =
./bin/test -cvv test_distroseriesdifference test_requestPackageDiffs_parent_is_base
= QA =
On dogfood (https://dogfood.launchpad.net/ubuntu/natty/+localpackagediffs)
Requesting package diffs for 'adplay' should not error with a 502 Proxy Error (due to a raise Integrity Error).
--
https://code.launchpad.net/~rvb/launchpad/parent-pack-diff-computed-bug-768293/+merge/58665
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/launchpad/parent-pack-diff-computed-bug-768293 into lp:launchpad.
=== modified file 'lib/lp/registry/model/distroseriesdifference.py'
--- lib/lp/registry/model/distroseriesdifference.py 2011-04-19 02:42:28 +0000
+++ lib/lp/registry/model/distroseriesdifference.py 2011-04-21 13:12:36 +0000
@@ -705,5 +705,6 @@
if self.source_version != self.base_version:
self.package_diff = base_spr.requestDiffTo(
requestor, to_sourcepackagerelease=derived_spr)
- self.parent_package_diff = base_spr.requestDiffTo(
- requestor, to_sourcepackagerelease=parent_spr)
+ if self.parent_source_version != self.base_version:
+ self.parent_package_diff = base_spr.requestDiffTo(
+ requestor, to_sourcepackagerelease=parent_spr)
=== modified file 'lib/lp/registry/tests/test_distroseriesdifference.py'
--- lib/lp/registry/tests/test_distroseriesdifference.py 2011-04-19 12:00:38 +0000
+++ lib/lp/registry/tests/test_distroseriesdifference.py 2011-04-21 13:12:36 +0000
@@ -654,23 +654,36 @@
self.assertEqual(
ds_diff.derived_series, ds_diff.base_source_pub.distroseries)
+ def _setupDSDsWithChangelog(self, derived_versions,
+ parent_versions,
+ status=None):
+ # Helper to create DSD with changelogs.
+ # {derived,parent}_changelog must be ordered (e.g. ['1.1',
+ # '1.2', '1.3']).
+ if status is None:
+ status=DistroSeriesDifferenceStatus.NEEDS_ATTENTION
+ derived_changelog = self.factory.makeChangelog(
+ versions=derived_versions)
+ parent_changelog = self.factory.makeChangelog(
+ versions=parent_versions)
+ transaction.commit() # Yay, librarian.
+ ds_diff = self.factory.makeDistroSeriesDifference(
+ status=status,
+ versions={
+ 'derived': derived_versions[-1],
+ 'parent': parent_versions[-1],
+ 'base': derived_versions[0],
+ },
+ changelogs={
+ 'derived': derived_changelog,
+ 'parent': parent_changelog,
+ })
+ return ds_diff
+
def test_requestPackageDiffs(self):
# IPackageDiffs are created for the corresponding versions.
- derived_changelog = self.factory.makeChangelog(
- versions=['1.0', '1.2'])
- parent_changelog = self.factory.makeChangelog(
- versions=['1.0', '1.3'])
- transaction.commit() # Yay, librarian.
- ds_diff = self.factory.makeDistroSeriesDifference(versions={
- 'derived': '1.2',
- 'parent': '1.3',
- 'base': '1.0',
- },
- changelogs={
- 'derived': derived_changelog,
- 'parent': parent_changelog,
- })
-
+ ds_diff = self._setupDSDsWithChangelog(
+ ['1.0', '1.2'], ['1.0', '1.3'])
person = self.factory.makePerson()
with person_logged_in(person):
ds_diff.requestPackageDiffs(person)
@@ -687,42 +700,32 @@
def test_requestPackageDiffs_child_is_base(self):
# When the child has the same version as the base version, when
# diffs are requested, child diffs aren't.
- derived_changelog = self.factory.makeChangelog(versions=['0.1-1'])
- parent_changelog = self.factory.makeChangelog(
- versions=['0.1-2', '0.1-1'])
- transaction.commit() # Yay, librarian.
- ds_diff = self.factory.makeDistroSeriesDifference(
- versions={
- 'derived': '0.1-1',
- 'parent': '0.1-2',
- 'base': '0.1-1',
- },
- changelogs={
- 'derived': derived_changelog,
- 'parent': parent_changelog,
- })
-
+ ds_diff = self._setupDSDsWithChangelog(
+ ['0.1-1'], ['0.1-1', '0.1-2'])
person = self.factory.makePerson()
with person_logged_in(person):
ds_diff.requestPackageDiffs(person)
+
self.assertIs(None, ds_diff.package_diff)
self.assertIsNot(None, ds_diff.parent_package_diff)
+ def test_requestPackageDiffs_parent_is_base(self):
+ # When the parent has the same version as the base version, when
+ # diffs are requested, parent diffs aren't.
+ ds_diff = self._setupDSDsWithChangelog(
+ ['0.1-1', '0.1-2'], ['0.1-1'])
+ person = self.factory.makePerson()
+ with person_logged_in(person):
+ ds_diff.requestPackageDiffs(person)
+
+ self.assertIsNot(None, ds_diff.package_diff)
+ self.assertIs(None, ds_diff.parent_package_diff)
+
def test_requestPackageDiffs_with_resolved_DSD(self):
# Diffs can't be requested for DSDs that are RESOLVED.
- changelog_lfa = self.factory.makeChangelog(versions=['0.1-1'])
- transaction.commit() # Yay, librarian.
- ds_diff = self.factory.makeDistroSeriesDifference(
- status=DistroSeriesDifferenceStatus.RESOLVED,
- versions={
- 'derived': '0.1-1',
- 'parent': '0.1-1',
- 'base': '0.1-1',
- },
- changelogs={
- 'derived': changelog_lfa,
- 'parent': changelog_lfa,
- })
+ ds_diff = self._setupDSDsWithChangelog(
+ ['0.1-1'], ['0.1-1'],
+ status=DistroSeriesDifferenceStatus.RESOLVED)
person = self.factory.makePerson()
with person_logged_in(person):
self.assertRaisesWithContent(