Merge lp:~stevenk/launchpad/dsd-base_source_pub-search-parent into lp:launchpad

Proposed by Steve Kowalik
Status: Merged
Approved by: Steve Kowalik
Approved revision: no longer in the source branch.
Merged at revision: 12592
Proposed branch: lp:~stevenk/launchpad/dsd-base_source_pub-search-parent
Merge into: lp:launchpad
Diff against target: 113 lines (+48/-11)
3 files modified
lib/lp/registry/interfaces/distroseriesdifference.py (+2/-1)
lib/lp/registry/model/distroseriesdifference.py (+11/-8)
lib/lp/registry/tests/test_distroseriesdifference.py (+35/-2)
To merge this branch: bzr merge lp:~stevenk/launchpad/dsd-base_source_pub-search-parent
Reviewer Review Type Date Requested Status
Henning Eggers (community) code Approve
Review via email: mp+53194@code.launchpad.net

Commit message

[r=henninge][bug=734719] DSD.base_source_pub now looks in the parent series first, and then the child distroseries.

Description of the change

DSD.base_source_pub should look in the parent series first, since that is most likely to contain the base version publication in the real world.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

This does two queries always - the count() (expensive) and then a first.

Better to just do a first:
result = pubs.first()
if result is None:
    result = ... other side query ... .first()
return result

Revision history for this message
Henning Eggers (henninge) wrote :
Download full text (3.5 KiB)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Steven,
thanks for the quick chat and explanation. I should have looked at more
context but I had hoped to do it quickly.

 review approve code

This looks fine to me, only the two issues mentioned on mumble. Please have a
look below.

Cheers,
Henning

Am 14.03.2011 06:23, schrieb Steve Kowalik:
> === modified file 'lib/lp/registry/interfaces/distroseriesdifference.py'
> === modified file 'lib/lp/registry/model/distroseriesdifference.py'
> === modified file 'lib/lp/registry/tests/test_distroseriesdifference.py'
> --- lib/lp/registry/tests/test_distroseriesdifference.py 2011-03-10 11:11:50 +0000
> +++ lib/lp/registry/tests/test_distroseriesdifference.py 2011-03-14 05:22:57 +0000
> @@ -474,7 +474,8 @@
[...]

> @@ -515,6 +517,36 @@
> self.assertEqual('1.0', ds_diff.base_version)
> self.assertIs(None, ds_diff.base_source_pub)
>
> + def test_base_source_pub_only_in_child(self):
> + # If the base version is only published in the child distroseries,
> + # the base source publication is still located and returned.
> + 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',
> + },
> + changelogs={
> + 'derived': derived_changelog,
> + 'parent': parent_changelog,
> + })

This is formatted a bit inconsistently that makes it harder to read. This
would be better, I think.

        ds_diff = self.factory.makeDistroSeriesDifference(
            versions={
                'derived': '1.2',
                'parent': '1.3',
                },
            changelogs={
                'derived': derived_changelog,
                'parent': parent_changelog,
                })

I *think* it is python style to place closing braces on the same level as the
content?

> +
> + # Passing in a base version to makeDistroSeriesDifference() creates
> + # it in both distroseries, so we need to do it ourselves.

So, the comment would be much clearer to me like this but maybe that's too
verbose?

# We do not pass in a 'base' version to makeDistroSeriesDifference()
# because it would be created in both distroseries and we don't want
# that. We rather create it ourselves in just the child series.

> + spr = self.factory.makeSourcePackageRelease(
> + sourcepackagename=ds_diff.source_package_name, version='1.0')
> + self.factory.makeSourcePackagePublishingHistory(
> + distroseries=ds_diff.derived_series, sourcepackagerelease=spr,
> + status=PackagePublishingStatus.SUPERSEDED)
> + ds_diff.update()
> + self.assertEqual('1.0', ds_diff.base_version)
> + self.assertEqual(
> + ds_diff.derived_series, ds_diff.base_source_pub.distroseries)
> +
> def test_requestPackageDiffs(self):
> # IPackageDiffs are created f...

Read more...

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/registry/interfaces/distroseriesdifference.py'
--- lib/lp/registry/interfaces/distroseriesdifference.py 2010-10-07 14:59:21 +0000
+++ lib/lp/registry/interfaces/distroseriesdifference.py 2011-03-14 09:44:28 +0000
@@ -132,7 +132,8 @@
132 ISourcePackagePublishingHistory,132 ISourcePackagePublishingHistory,
133 title=_("Base source pub"), readonly=True,133 title=_("Base source pub"), readonly=True,
134 description=_(134 description=_(
135 "The common base version published in the derived series."))135 "The common base version published in the parent or the "
136 "derived series."))
136137
137 owner = Reference(138 owner = Reference(
138 IPerson, title=_("Owning team of the derived series"), readonly=True,139 IPerson, title=_("Owning team of the derived series"), readonly=True,
139140
=== modified file 'lib/lp/registry/model/distroseriesdifference.py'
--- lib/lp/registry/model/distroseriesdifference.py 2011-03-10 04:00:08 +0000
+++ lib/lp/registry/model/distroseriesdifference.py 2011-03-14 09:44:28 +0000
@@ -29,7 +29,6 @@
29 IMasterStore,29 IMasterStore,
30 IStore,30 IStore,
31 )31 )
32from lp.archivepublisher.debversion import Version
33from lp.registry.enum import (32from lp.registry.enum import (
34 DistroSeriesDifferenceStatus,33 DistroSeriesDifferenceStatus,
35 DistroSeriesDifferenceType,34 DistroSeriesDifferenceType,
@@ -154,14 +153,18 @@
154 def base_source_pub(self):153 def base_source_pub(self):
155 """See `IDistroSeriesDifference`."""154 """See `IDistroSeriesDifference`."""
156 if self.base_version is not None:155 if self.base_version is not None:
157 pubs = self.derived_series.main_archive.getPublishedSources(156 parent = self.derived_series.parent_series
157 result = parent.main_archive.getPublishedSources(
158 name=self.source_package_name.name,158 name=self.source_package_name.name,
159 version=self.base_version,159 version=self.base_version, distroseries=parent).first()
160 distroseries=self.derived_series)160 if result is None:
161 # We know there is a base version published in the distroseries'161 # If the base version isn't in the parent, it may be
162 # main archive.162 # published in the child distroseries.
163 return pubs.first()163 child = self.derived_series
164164 result = child.main_archive.getPublishedSources(
165 name=self.source_package_name.name,
166 version=self.base_version, distroseries=child).first()
167 return result
165 return None168 return None
166169
167 @property170 @property
168171
=== modified file 'lib/lp/registry/tests/test_distroseriesdifference.py'
--- lib/lp/registry/tests/test_distroseriesdifference.py 2011-03-10 11:11:50 +0000
+++ lib/lp/registry/tests/test_distroseriesdifference.py 2011-03-14 09:44:28 +0000
@@ -474,7 +474,8 @@
474 self.assertIs(None, ds_diff.base_source_pub)474 self.assertIs(None, ds_diff.base_source_pub)
475475
476 def test_base_source_pub(self):476 def test_base_source_pub(self):
477 # The publishing in the derived series with base_version is returned.477 # The publication in the parent series with the base version is
478 # returned.
478 derived_changelog = self.factory.makeChangelog(479 derived_changelog = self.factory.makeChangelog(
479 versions=['1.0', '1.2'])480 versions=['1.0', '1.2'])
480 parent_changelog = self.factory.makeChangelog(481 parent_changelog = self.factory.makeChangelog(
@@ -493,7 +494,8 @@
493494
494 base_pub = ds_diff.base_source_pub495 base_pub = ds_diff.base_source_pub
495 self.assertEqual('1.0', base_pub.source_package_version)496 self.assertEqual('1.0', base_pub.source_package_version)
496 self.assertEqual(ds_diff.derived_series, base_pub.distroseries)497 self.assertEqual(
498 ds_diff.derived_series.parent_series, base_pub.distroseries)
497499
498 def test_base_source_pub_not_published(self):500 def test_base_source_pub_not_published(self):
499 # If the base version isn't published, the base version is501 # If the base version isn't published, the base version is
@@ -515,6 +517,37 @@
515 self.assertEqual('1.0', ds_diff.base_version)517 self.assertEqual('1.0', ds_diff.base_version)
516 self.assertIs(None, ds_diff.base_source_pub)518 self.assertIs(None, ds_diff.base_source_pub)
517519
520 def test_base_source_pub_only_in_child(self):
521 # If the base version is only published in the child distroseries,
522 # the base source publication is still located and returned.
523 derived_changelog = self.factory.makeChangelog(
524 versions=['1.0', '1.2'])
525 parent_changelog = self.factory.makeChangelog(
526 versions=['1.0', '1.3'])
527 transaction.commit() # Yay, librarian.
528
529 ds_diff = self.factory.makeDistroSeriesDifference(
530 versions={
531 'derived': '1.2',
532 'parent': '1.3',
533 },
534 changelogs={
535 'derived': derived_changelog,
536 'parent': parent_changelog,
537 })
538
539 # Passing in a base version to makeDistroSeriesDifference() creates
540 # it in both distroseries, which we don't want, so we need to do it
541 # ourselves.
542 spr = self.factory.makeSourcePackageRelease(
543 sourcepackagename=ds_diff.source_package_name, version='1.0')
544 self.factory.makeSourcePackagePublishingHistory(
545 distroseries=ds_diff.derived_series, sourcepackagerelease=spr,
546 status=PackagePublishingStatus.SUPERSEDED)
547 self.assertEqual('1.0', ds_diff.base_version)
548 self.assertEqual(
549 ds_diff.derived_series, ds_diff.base_source_pub.distroseries)
550
518 def test_requestPackageDiffs(self):551 def test_requestPackageDiffs(self):
519 # IPackageDiffs are created for the corresponding versions.552 # IPackageDiffs are created for the corresponding versions.
520 dervied_changelog = self.factory.makeChangelog(553 dervied_changelog = self.factory.makeChangelog(