I really like this branch. I just have some suggestions/questions on comments below.
> === modified file 'lib/lp/registry/browser/peoplemerge.py'
> --- lib/lp/registry/browser/peoplemerge.py 2010-12-03 16:33:03 +0000
> +++ lib/lp/registry/browser/peoplemerge.py 2010-12-08 18:32:00 +0000
> @@ -132,6 +132,13 @@
> if dupe_person == target_person and dupe_person is not None:
> self.addError(_("You can't merge ${name} into itself.",
> mapping=dict(name=dupe_person.name)))
> + # We cannot merge the teams if there is a PPA with published
> + # packages on the duplicate person, unless that PPA is removed.
> + if dupe_person.has_ppa_with_published_packages:
> + self.addError(_(
> + "${name} has a PPA with published packages; we "
> + "can't merge it.", mapping=dict(name=dupe_person.name)))
It might be good to direct someone to info on what they can do to get around this? In
other places where we throw an error in merging we indicate that a team needs to be removed or something; perhaps "the PPA must be deleted before we can merge ${name}, after the merge a new PPA can be recreated?
> === modified file 'lib/lp/registry/browser/tests/test_peoplemerge.py'
> --- lib/lp/registry/browser/tests/test_peoplemerge.py 2010-12-03 16:33:03 +0000
> +++ lib/lp/registry/browser/tests/test_peoplemerge.py 2010-12-08 18:32:00 +0000
> @@ -152,3 +155,51 @@
> view = self.getView()
> self.assertEqual([], view.errors)
> self.assertEqual(self.target_team, self.dupe_team.merged)
> +
> + def test_cannot_merge_team_with_ppa_containing_published_packages(self):
> + # The PPA must be removed before the team can be merged.
> + login_celebrity('admin')
> + self.dupe_team.subscriptionpolicy = TeamSubscriptionPolicy.MODERATED
> + archive = self.dupe_team.createPPA()
> + self.factory.makeSourcePackagePublishingHistory(archive=archive)
> + login_celebrity('registry_experts')
> + view = self.getView()
> + self.assertEqual(
> + [u"dupe-team has a PPA with published packages; "
> + "we can't merge it."],
> + view.errors)
I'd change the comment to just "A team cannot be merged with published PPA" since the test doesn't demonstrate removing the PPA to make it work.
> === modified file 'lib/lp/registry/doc/person-merge.txt'
> --- lib/lp/registry/doc/person-merge.txt 2010-12-01 23:39:05 +0000
> +++ lib/lp/registry/doc/person-merge.txt 2010-12-08 18:32:00 +0000
> @@ -425,6 +425,8 @@
> >>> test_team.deactivateAllMembers(comment, personset.getByName('name16'))
> >>> for team in test_team.super_teams:
> ... test_team.retractTeamMembership(team, test_team.teamowner)
> +
> +
> >>> personset.merge(test_team, landscape)
>
> # The resulting Landscape-developers no new super teams, has
Thanks for the cleanup.
> @@ -438,3 +440,18 @@
> []
> >>> list(IPollSubset(landscape).getAll())
> []
> +
> +A person with a PPA can't be merged until the PPA is deleted.
> +
> + >>> person_with_ppa = factory.makePerson()
> + >>> other_person = factory.makePerson()
> + >>> archive = person_with_ppa.createPPA()
> + >>> ignore = factory.makeSourcePackagePublishingHistory(archive=archive)
> + >>> email = IMasterObject(person_with_ppa.preferredemail)
> + >>> email.status = EmailAddressStatus.VALIDATED
> + >>> email.destroySelf()
> + >>> transaction.commit()
> + >>> personset.merge(person_with_ppa, other_person)
> + Traceback (most recent call last):
> + ...
> + AssertionError: from_person still has ppas with published packages.
Again, the comment and the demonstration aren't exactly in sync; I'd like the comment to be along the lines of just "A person with a PPA can't be merged" or to have the story show the merge working after the delete. Given how slow stories are, I think just changing the comment would be the better approach.
Hey Edwin--
I really like this branch. I just have some suggestions/ questions on comments below.
> === modified file 'lib/lp/ registry/ browser/ peoplemerge. py' registry/ browser/ peoplemerge. py 2010-12-03 16:33:03 +0000 registry/ browser/ peoplemerge. py 2010-12-08 18:32:00 +0000 _("You can't merge ${name} into itself.", dict(name= dupe_person. name))) has_ppa_ with_published_ packages: dict(name= dupe_person. name)))
> --- lib/lp/
> +++ lib/lp/
> @@ -132,6 +132,13 @@
> if dupe_person == target_person and dupe_person is not None:
> self.addError(
> mapping=
> + # We cannot merge the teams if there is a PPA with published
> + # packages on the duplicate person, unless that PPA is removed.
> + if dupe_person.
> + self.addError(_(
> + "${name} has a PPA with published packages; we "
> + "can't merge it.", mapping=
It might be good to direct someone to info on what they can do to get around this? In
other places where we throw an error in merging we indicate that a team needs to be removed or something; perhaps "the PPA must be deleted before we can merge ${name}, after the merge a new PPA can be recreated?
> === modified file 'lib/lp/ registry/ browser/ tests/test_ peoplemerge. py' registry/ browser/ tests/test_ peoplemerge. py 2010-12-03 16:33:03 +0000 registry/ browser/ tests/test_ peoplemerge. py 2010-12-08 18:32:00 +0000 l([], view.errors) l(self. target_ team, self.dupe_ team.merged) merge_team_ with_ppa_ containing_ published_ packages( self): ('admin' ) team.subscripti onpolicy = TeamSubscriptio nPolicy. MODERATED team.createPPA( ) makeSourcePacka gePublishingHis tory(archive= archive) ('registry_ experts' )
> --- lib/lp/
> +++ lib/lp/
> @@ -152,3 +155,51 @@
> view = self.getView()
> self.assertEqua
> self.assertEqua
> +
> + def test_cannot_
> + # The PPA must be removed before the team can be merged.
> + login_celebrity
> + self.dupe_
> + archive = self.dupe_
> + self.factory.
> + login_celebrity
> + view = self.getView()
> + self.assertEqual(
> + [u"dupe-team has a PPA with published packages; "
> + "we can't merge it."],
> + view.errors)
I'd change the comment to just "A team cannot be merged with published PPA" since the test doesn't demonstrate removing the PPA to make it work.
> === modified file 'lib/lp/ registry/ doc/person- merge.txt' registry/ doc/person- merge.txt 2010-12-01 23:39:05 +0000 registry/ doc/person- merge.txt 2010-12-08 18:32:00 +0000 deactivateAllMe mbers(comment, personset. getByName( 'name16' )) super_teams: retractTeamMemb ership( team, test_team. teamowner) merge(test_ team, landscape) developers no new super teams, has
> --- lib/lp/
> +++ lib/lp/
> @@ -425,6 +425,8 @@
> >>> test_team.
> >>> for team in test_team.
> ... test_team.
> +
> +
> >>> personset.
>
> # The resulting Landscape-
Thanks for the cleanup.
> @@ -438,3 +440,18 @@ t(landscape) .getAll( )) makePerson( ) makePerson( ) with_ppa. createPPA( ) makeSourcePacka gePublishingHis tory(archive= archive) person_ with_ppa. preferredemail) tus.VALIDATED commit( ) merge(person_ with_ppa, other_person)
> []
> >>> list(IPollSubse
> []
> +
> +A person with a PPA can't be merged until the PPA is deleted.
> +
> + >>> person_with_ppa = factory.
> + >>> other_person = factory.
> + >>> archive = person_
> + >>> ignore = factory.
> + >>> email = IMasterObject(
> + >>> email.status = EmailAddressSta
> + >>> email.destroySelf()
> + >>> transaction.
> + >>> personset.
> + Traceback (most recent call last):
> + ...
> + AssertionError: from_person still has ppas with published packages.
Again, the comment and the demonstration aren't exactly in sync; I'd like the comment to be along the lines of just "A person with a PPA can't be merged" or to have the story show the merge working after the delete. Given how slow stories are, I think just changing the comment would be the better approach.
> === modified file 'lib/lp/ registry/ model/person. py' registry/ model/person. py 2010-12-03 16:33:03 +0000 registry/ model/person. py 2010-12-08 18:32:00 +0000 with_published_ packages( self): self).find( blishingHistory .archive == Archive.id, status. is_in( ACTIVE, ArchiveStatus. DELETING] ))
> --- lib/lp/
> +++ lib/lp/
> + @property
> + def has_ppa_
> + result = Store.of(
> + Archive,
> + SourcePackagePu
> + Archive.owner == self.id,
> + Archive.purpose == ArchivePurpose.PPA,
> + Archive.
> + [ArchiveStatus.
> + return not result.is_empty()
> +
Adding this to the model was a perfect idea; thanks for reducing the repetition in the merge path.