Thanks for the review. Here are the changes you asked for.
> Hey Edwin--
>
> 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?
I did something similar but a little bit shorter.
> > === 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.
Done.
> > === 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.
Done.
> > === modified file 'lib/lp/registry/model/person.py'
> > --- lib/lp/registry/model/person.py 2010-12-03 16:33:03 +0000
> > +++ lib/lp/registry/model/person.py 2010-12-08 18:32:00 +0000
> > + @property
> > + def has_ppa_with_published_packages(self):
> > + result = Store.of(self).find(
> > + Archive,
> > + SourcePackagePublishingHistory.archive == Archive.id,
> > + Archive.owner == self.id,
> > + Archive.purpose == ArchivePurpose.PPA,
> > + Archive.status.is_in(
> > + [ArchiveStatus.ACTIVE, ArchiveStatus.DELETING]))
> > + return not result.is_empty()
> > +
>
> Adding this to the model was a perfect idea; thanks for reducing the
> repetition in the merge path.
Diff:
------------------------------------------
=== modified file 'lib/lp/registry/browser/peoplemerge.py'
--- lib/lp/registry/browser/peoplemerge.py 2010-12-15 20:07:54 +0000
+++ lib/lp/registry/browser/peoplemerge.py 2010-12-15 20:09:11 +0000
@@ -136,8 +136,8 @@
# 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)))
+ "${name} has a PPA that must be removed before it "
+ "can be merged.", mapping=dict(name=dupe_person.name)))
def test_cannot_merge_team_with_ppa_containing_published_packages(self):
- # The PPA must be removed before the team can be merged.
+ # A team with a published PPA cannot be merged. login_celebrity('admin') self.dupe_team.subscriptionpolicy = TeamSubscriptionPolicy.MODERATED
archive = self.dupe_team.createPPA()
@@ -165,8 +165,8 @@ login_celebrity('registry_experts')
view = self.getView() self.assertEqual(
- [u"dupe-team has a PPA with published packages; "
- "we can't merge it."],
+ [u'dupe-team has a PPA that must be removed before '
+ 'it can be merged.'], view.errors)
def test_registry_delete_team_with_super_teams(self):
@@ -212,6 +212,6 @@ self.factory.makeSourcePackagePublishingHistory(archive=archive)
view = self.getView() self.assertEqual(
- [u"dupe-person has a PPA with published packages; "
- "we can't merge it."],
+ [u'dupe-person has a PPA that must be removed before '
+ 'it can be merged.'], view.errors)
Hi JC,
Thanks for the review. Here are the changes you asked for.
> Hey Edwin-- questions on comments 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)))
>
> I really like this branch. I just have some suggestions/
> below.
>
> > === modified file 'lib/lp/
> > --- 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?
I did something similar but a little bit shorter.
> > === modified file 'lib/lp/ registry/ browser/ tests/test_ peoplemerge. py' registry/ browser/ tests/test_ peoplemerge. py 2010-12-03 16:33:03 registry/ browser/ tests/test_ peoplemerge. py 2010-12-08 18:32:00 l([], view.errors) l(self. target_ team, self.dupe_ team.merged) merge_team_ with_ppa_ containing_ published_ packages( self): ('admin' ) team.subscripti onpolicy = nPolicy. MODERATED team.createPPA( ) makeSourcePacka gePublishingHis tory(archive= archive) ('registry_ experts' )
> > --- lib/lp/
> +0000
> > +++ lib/lp/
> +0000
> > @@ -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_
> TeamSubscriptio
> > + 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.
Done.
> > === 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, getByName( 'name16' )) super_teams: retractTeamMemb ership( team, test_team. teamowner) merge(test_ team, landscape) developers no new super teams, has 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)
> > --- lib/lp/
> > +++ lib/lp/
> > @@ -425,6 +425,8 @@
> > >>> test_team.
> personset.
> > >>> for team in test_team.
> > ... test_team.
> > +
> > +
> > >>> personset.
> >
> > # The resulting Landscape-
>
> Thanks for the cleanup.
>
> > @@ -438,3 +440,18 @@
> > []
> > >>> 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.
Done.
> > === 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.
Diff: ------- ------- ------- ------- -------
-------
=== modified file 'lib/lp/ registry/ browser/ peoplemerge. py' registry/ browser/ peoplemerge. py 2010-12-15 20:07:54 +0000 registry/ browser/ peoplemerge. py 2010-12-15 20:09:11 +0000 has_ppa_ with_published_ packages:
self. addError( _( dict(name= dupe_person. name))) dict(name= dupe_person. name)))
--- lib/lp/
+++ lib/lp/
@@ -136,8 +136,8 @@
# packages on the duplicate person, unless that PPA is removed.
if dupe_person.
- "${name} has a PPA with published packages; we "
- "can't merge it.", mapping=
+ "${name} has a PPA that must be removed before it "
+ "can be merged.", mapping=
def render(self):
=== modified file 'lib/lp/ registry/ browser/ tests/test_ peoplemerge. py' registry/ browser/ tests/test_ peoplemerge. py 2010-12-15 20:07:54 +0000 registry/ browser/ tests/test_ peoplemerge. py 2010-12-15 20:16:13 +0000
self. assertEqual( self.target_ team, self.dupe_ team.merged)
--- lib/lp/
+++ lib/lp/
@@ -157,7 +157,7 @@
def test_cannot_ merge_team_ with_ppa_ containing_ published_ packages( self):
login_ celebrity( 'admin' )
self. dupe_team. subscriptionpol icy = TeamSubscriptio nPolicy. MODERATED team.createPPA( )
login_ celebrity( 'registry_ experts' )
self. assertEqual(
view. errors)
- # The PPA must be removed before the team can be merged.
+ # A team with a published PPA cannot be merged.
archive = self.dupe_
@@ -165,8 +165,8 @@
view = self.getView()
- [u"dupe-team has a PPA with published packages; "
- "we can't merge it."],
+ [u'dupe-team has a PPA that must be removed before '
+ 'it can be merged.'],
def test_registry_ delete_ team_with_ super_teams( self):
self. factory. makeSourcePacka gePublishingHis tory(archive= archive)
self. assertEqual(
view. errors)
@@ -212,6 +212,6 @@
view = self.getView()
- [u"dupe-person has a PPA with published packages; "
- "we can't merge it."],
+ [u'dupe-person has a PPA that must be removed before '
+ 'it can be merged.'],
=== modified file 'lib/lp/ registry/ doc/person- merge.txt' registry/ doc/person- merge.txt 2010-12-08 04:54:34 +0000 registry/ doc/person- merge.txt 2010-12-15 20:12:07 +0000 t(landscape) .getAll( ))
--- lib/lp/
+++ lib/lp/
@@ -441,7 +441,7 @@
>>> list(IPollSubse
[]
-A person with a PPA can't be merged until the PPA is deleted.
+A person with a PPA can't be merged.
>>> person_with_ppa = factory. makePerson( ) makePerson( )
>>> other_person = factory.