launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #04917
[Merge] lp:~rvb/launchpad/sync-bug-827608-populate-ancestor into lp:launchpad
Raphaël Victor Badin has proposed merging lp:~rvb/launchpad/sync-bug-827608-populate-ancestor into lp:launchpad with lp:~rvb/launchpad/sync-bug-827608-spph-creator-code as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #827608 in Launchpad itself: "Sync requester isn't credited with upload"
https://bugs.launchpad.net/launchpad/+bug/827608
For more details, see:
https://code.launchpad.net/~rvb/launchpad/sync-bug-827608-populate-ancestor/+merge/74734
his branch populates the SourcePackagePublishingHistory's ancestor column when the new spph is created by being copied over. The ancestor field was first created to calculate a common ancestor given two spphs but then the common ancestor was calculated by looking at changelogs instead. The ancestor field was left non populated (the prod db was checked). This branch fixes this so that we can track where a spph was copied from. We will need this to be able to work out whether or not someone should get credits on ~/me/+related-software for having copied a package.
= Tests =
./bin/test -vvc test_publishing test_copyTo_sets_ancestor
= QA =
None.
--
https://code.launchpad.net/~rvb/launchpad/sync-bug-827608-populate-ancestor/+merge/74734
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/launchpad/sync-bug-827608-populate-ancestor into lp:launchpad.
=== modified file 'lib/lp/soyuz/interfaces/publishing.py'
--- lib/lp/soyuz/interfaces/publishing.py 2011-09-02 04:51:25 +0000
+++ lib/lp/soyuz/interfaces/publishing.py 2011-09-09 09:06:53 +0000
@@ -483,6 +483,14 @@
description=_('The previous release of this source package.'),
required=False, readonly=True)
+ creator = exported(
+ Reference(
+ IPerson,
+ title=_('Publication Creator'),
+ description=_('The IPerson who created this publication.'),
+ required=False, readonly=True
+ ))
+
# Really IBinaryPackagePublishingHistory, see below.
@operation_returns_collection_of(Interface)
@export_read_operation()
@@ -590,7 +598,7 @@
`IBinaryPackagePublishingHistory`.
"""
- def copyTo(distroseries, pocket, archive, overrides=None):
+ def copyTo(distroseries, pocket, archive, overrides=None, creator=None):
"""Copy this publication to another location.
:param distroseries: The `IDistroSeries` to copy the source
@@ -598,7 +606,9 @@
:param pocket: The `PackagePublishingPocket` to copy into.
:param archive: The `IArchive` to copy the source publication into.
:param overrides: A tuple of override data as returned from a
- `IOverridePolicy`
+ `IOverridePolicy`.
+ :param creator: the `IPerson` to use as the creator for the copied
+ publication.
:return: a `ISourcePackagePublishingHistory` record representing the
source in the destination location.
@@ -963,6 +973,8 @@
version of this publishing record
:param create_dsd_job: A boolean indicating whether or not a dsd job
should be created for the new source publication.
+ :param creator: An optional `IPerson`. If this is None, the
+ sourcepackagerelease's creator will be used.
datecreated will be UTC_NOW.
status will be PackagePublishingStatus.PENDING
=== modified file 'lib/lp/soyuz/model/publishing.py'
--- lib/lp/soyuz/model/publishing.py 2011-08-31 04:40:44 +0000
+++ lib/lp/soyuz/model/publishing.py 2011-09-09 09:06:53 +0000
@@ -451,6 +451,9 @@
ancestor = ForeignKey(
dbName="ancestor", foreignKey="SourcePackagePublishingHistory",
default=None)
+ creator = ForeignKey(
+ dbName='creator', foreignKey='Person',
+ storm_validator=validate_public_person, notNull=False, default=None)
@property
def package_creator(self):
@@ -795,7 +798,7 @@
archive=current.archive)
def copyTo(self, distroseries, pocket, archive, override=None,
- create_dsd_job=True):
+ create_dsd_job=True, creator=None):
"""See `ISourcePackagePublishingHistory`."""
component = self.component
section = self.section
@@ -811,8 +814,9 @@
component,
section,
pocket,
- ancestor=None,
- create_dsd_job=create_dsd_job)
+ ancestor=self,
+ create_dsd_job=create_dsd_job,
+ creator=creator)
def getStatusSummaryForBuilds(self):
"""See `ISourcePackagePublishingHistory`."""
@@ -1479,12 +1483,16 @@
def newSourcePublication(self, archive, sourcepackagerelease,
distroseries, component, section, pocket,
- ancestor=None, create_dsd_job=True):
+ ancestor=None, create_dsd_job=True,
+ creator=None):
"""See `IPublishingSet`."""
# Avoid circular import.
from lp.registry.model.distributionsourcepackage import (
DistributionSourcePackage)
+ if creator is None:
+ creator = sourcepackagerelease.creator
+
pub = SourcePackagePublishingHistory(
distroseries=distroseries,
pocket=pocket,
@@ -1494,7 +1502,8 @@
section=section,
status=PackagePublishingStatus.PENDING,
datecreated=UTC_NOW,
- ancestor=ancestor)
+ ancestor=ancestor,
+ creator=creator)
DistributionSourcePackage.ensure(pub)
if create_dsd_job:
=== modified file 'lib/lp/soyuz/scripts/packagecopier.py'
--- lib/lp/soyuz/scripts/packagecopier.py 2011-08-30 14:56:59 +0000
+++ lib/lp/soyuz/scripts/packagecopier.py 2011-09-09 09:06:53 +0000
@@ -642,7 +642,7 @@
source, archive, destination_series, pocket,
include_binaries, override, close_bugs=close_bugs,
create_dsd_job=create_dsd_job,
- close_bugs_since_version=old_version)
+ close_bugs_since_version=old_version, creator=person)
if send_email:
notify(
person, source.sourcepackagerelease, [], [], archive,
@@ -659,7 +659,7 @@
def _do_direct_copy(source, archive, series, pocket, include_binaries,
override=None, close_bugs=True, create_dsd_job=True,
- close_bugs_since_version=None):
+ close_bugs_since_version=None, creator=None):
"""Copy publishing records to another location.
Copy each item of the given list of `SourcePackagePublishingHistory`
@@ -685,6 +685,7 @@
:param close_bugs_since_version: If close_bugs is True,
then this parameter says which changelog entries to parse looking
for bugs to close. See `close_bugs_for_sourcepackagerelease`.
+ :param creator: the requester `IPerson`.
:return: a list of `ISourcePackagePublishingHistory` and
`BinaryPackagePublishingHistory` corresponding to the copied
@@ -714,7 +715,8 @@
"More than one override encountered, something is wrong.")
override = overrides[0]
source_copy = source.copyTo(
- series, pocket, archive, override, create_dsd_job=create_dsd_job)
+ series, pocket, archive, override, create_dsd_job=create_dsd_job,
+ creator=creator)
if close_bugs:
close_bugs_for_sourcepublication(
source_copy, close_bugs_since_version)
=== modified file 'lib/lp/soyuz/scripts/tests/test_copypackage.py'
--- lib/lp/soyuz/scripts/tests/test_copypackage.py 2011-08-30 12:11:41 +0000
+++ lib/lp/soyuz/scripts/tests/test_copypackage.py 2011-09-09 09:06:53 +0000
@@ -1603,6 +1603,27 @@
# Only the source package has been copied.
self.assertEqual(1, len(copies))
+ def test_copy_sets_creator(self):
+ # The creator for the copied SPPH is the person passed
+ # to do_copy.
+ archive = self.test_publisher.ubuntutest.main_archive
+ source = self.test_publisher.getPubSource(
+ archive=archive, version='1.0-2', architecturehintlist='any')
+ source.sourcepackagerelease.changelog_entry = '* Foo!'
+ nobby = self.createNobby(('i386', 'hppa'))
+ getUtility(ISourcePackageFormatSelectionSet).add(
+ nobby, SourcePackageFormat.FORMAT_1_0)
+ target_archive = self.factory.makeArchive(
+ distribution=self.test_publisher.ubuntutest)
+ [copied_source] = do_copy(
+ [source], target_archive, nobby, source.pocket, False,
+ person=target_archive.owner, check_permissions=False,
+ send_email=False)
+
+ self.assertEqual(
+ target_archive.owner,
+ copied_source.creator)
+
class TestDoDelayedCopy(TestCaseWithFactory, BaseDoCopyTests):
=== modified file 'lib/lp/soyuz/stories/webservice/xx-source-package-publishing.txt'
--- lib/lp/soyuz/stories/webservice/xx-source-package-publishing.txt 2010-12-08 16:02:58 +0000
+++ lib/lp/soyuz/stories/webservice/xx-source-package-publishing.txt 2011-09-09 09:06:53 +0000
@@ -117,6 +117,7 @@
>>> pprint_entry(pubs['entries'][0])
archive_link: u'http://.../~cprov/+archive/ppa'
component_name: u'main'
+ creator_link: u'http://api.launchpad.dev/beta/~name16'
date_created: ...
date_made_pending: None
date_published: None
=== modified file 'lib/lp/soyuz/tests/test_publishing.py'
--- lib/lp/soyuz/tests/test_publishing.py 2011-08-31 04:35:27 +0000
+++ lib/lp/soyuz/tests/test_publishing.py 2011-09-09 09:06:53 +0000
@@ -282,7 +282,8 @@
datepublished=datepublished,
scheduleddeletiondate=scheduleddeletiondate,
pocket=pocket,
- archive=archive)
+ archive=archive,
+ creator=creator)
return spph
@@ -1011,6 +1012,15 @@
# Section has no default so it comes from the old publication.
self.assertEqual(spph.section, copy.section)
+ def test_copyTo_sets_ancestor(self):
+ # SPPH's ancestor get's populated when a spph is copied over.
+ target_archive = self.factory.makeArchive()
+ spph = self.factory.makeSourcePackagePublishingHistory()
+ copy = spph.copyTo(
+ spph.distroseries, spph.pocket, target_archive)
+
+ self.assertEqual(spph, copy.ancestor)
+
class BuildRecordCreationTests(TestNativePublishingBase):
"""Test the creation of build records."""