~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/model/person.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-11-22 00:54:31 UTC
  • mfrom: (14186.7.11 observer-merging)
  • Revision ID: launchpad@pqm.canonical.com-20111122005431-sv2g5bsg6r75zl5m
[r=stevenk][no-qa] Make the person merger and branch deleter cope
        with the AccessPolicy tables.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3656
3656
        skip.append(
3657
3657
            (decorator_table.lower(), person_pointer_column.lower()))
3658
3658
 
 
3659
    def _mergeAccessPolicyGrant(self, cur, from_id, to_id):
 
3660
        # Update only the AccessPolicyGrants that will not conflict.
 
3661
        cur.execute('''
 
3662
            UPDATE AccessPolicyGrant
 
3663
            SET grantee=%(to_id)d
 
3664
            WHERE grantee = %(from_id)d AND (
 
3665
                policy NOT IN
 
3666
                    (
 
3667
                    SELECT policy
 
3668
                    FROM AccessPolicyGrant
 
3669
                    WHERE grantee = %(to_id)d
 
3670
                    )
 
3671
                OR artifact NOT IN
 
3672
                    (
 
3673
                    SELECT artifact
 
3674
                    FROM AccessPolicyGrant
 
3675
                    WHERE grantee = %(to_id)d
 
3676
                    )
 
3677
                )
 
3678
            ''' % vars())
 
3679
        # and delete those left over.
 
3680
        cur.execute('''
 
3681
            DELETE FROM AccessPolicyGrant WHERE grantee = %(from_id)d
 
3682
            ''' % vars())
 
3683
 
3659
3684
    def _mergeBranches(self, from_person, to_person):
3660
3685
        # This shouldn't use removeSecurityProxy.
3661
3686
        branches = getUtility(IBranchCollection).ownedBy(from_person)
4209
4234
            % vars())
4210
4235
        skip.append(('gpgkey', 'owner'))
4211
4236
 
 
4237
        self._mergeAccessPolicyGrant(cur, from_id, to_id)
 
4238
        skip.append(('accesspolicygrant', 'grantee'))
 
4239
 
4212
4240
        # Update the Branches that will not conflict, and fudge the names of
4213
4241
        # ones that *do* conflict.
4214
4242
        self._mergeBranches(from_person, to_person)