cannot delete/merge a team with private branches

Bug #918754 reported by Curtis Hovey
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
Critical
Curtis Hovey

Bug Description

I tried to delete a team that had private branches in projects with branch visibility rules. Merge transfers artefacts that must have owners, such as as branches to ~registry. Merge oopses because ~registry does not have a policy for the project. Lp might want to ask the user to provide another team to transfer the branches too. Maybe Lp should explain the user might want to do a merge with a new team instead.

This error also happens when I attempt to merge the team into another team. I hoped that the branches and policies would be transferred to the new team. Lp really must support this case. The issue might be moot if branch branch visibility policies are replaced with project sharing policies and merge handles them properly.

OOPS-b2214aa38cea8f74df0b9d79b02ef765

  BranchCreationForbidden: You cannot create branches in "~registry/<PROJECT>"

    Traceback (most recent call last):
  Module lp.services.job.runner, line 267, in runJobHandleError
    self.runJob(job)
  Module lp.services.job.runner, line 225, in runJob
    job.run()
  Module lp.registry.model.persontransferjob, line 427, in run
    reviewer=self.reviewer)
  Module lp.registry.model.person, line 4063, in delete
    return self._merge(from_person, to_person, reviewer, True)
  Module lp.registry.model.person, line 4165, in _merge
    self._mergeBranches(from_person, to_person)
  Module lp.registry.model.person, line 3611, in _mergeBranches
    removeSecurityProxy(branch).setOwner(to_person, to_person)
  Module lp.code.model.branch, line 220, in setOwner
    new_namespace.moveBranch(self, user, rename_if_necessary=True)
  Module lp.code.model.branchnamespace, line 199, in moveBranch
    self.validateMove(branch, mover, new_name)
  Module lp.code.model.branchnamespace, line 186, in validateMove
    self.validateRegistrant(mover)
  Module lp.code.model.branchnamespace, line 166, in validateRegistrant
    'You cannot create branches in "%s"' % self.name)
BranchCreationForbidden: You cannot create branches in "~registry/<PROJECT>"

While this bug will disappear when BVP is removed. We do not want ~registry to own private branches. The delete page must explain that the team cannot be deleted until the team's private branches are deleted or the ownership is transferred to another person. Delete may need to delete merged branches...the user needs to find all the other branches.

Related branches

Curtis Hovey (sinzui)
description: updated
Revision history for this message
Curtis Hovey (sinzui) wrote :

There is a second manifestation for this bug. I took ownership the old team and manually added branch policies the new team. I Merge thought it completed, but the DB reported an Integrity error. Looks like it is impossible to merge a team with another team if they both have visibility policies for a project. OOPS-190f295665ef293127cdd356371fc0c4

  IntegrityError: duplicate key value violates unique constraint "branchvisibilitypolicy__unq"

    Traceback (most recent call last):
  Module lp.services.job.runner, line 267, in runJobHandleError
    self.runJob(job)
  Module lp.services.job.runner, line 225, in runJob
    job.run()
  Module lp.registry.model.persontransferjob, line 437, in run
    reviewer=self.reviewer)
  Module lp.registry.model.person, line 4067, in merge
    return self._merge(from_person, to_person, reviewer)
  Module lp.registry.model.person, line 4259, in _merge
    src_tab, src_col, to_person.id, src_col, from_person.id))
  Module lp.services.database.sqlbase, line 619, in execute
    self._result = self._connection.execute(query)
  Module storm.databases.postgres, line 261, in execute
    return Connection.execute(self, statement, params, noresult)
  Module storm.database, line 238, in execute
    raw_cursor = self.raw_execute(statement, params)
  Module storm.databases.postgres, line 271, in raw_execute
    return Connection.raw_execute(self, statement, params)
  Module storm.database, line 322, in raw_execute
    self._check_disconnect(raw_cursor.execute, *args)
  Module storm.database, line 371, in _check_disconnect
    return function(*args, **kwargs)
IntegrityError: duplicate key value violates unique constraint "branchvisibilitypolicy__unq"

Revision history for this message
Curtis Hovey (sinzui) wrote :

I am tagging this bug as disclosure because I believe that sharing policies will supersede branch visibility policies and we want to ensure merging works.

tags: added: disclosure
Revision history for this message
Curtis Hovey (sinzui) wrote :

This issue here that merge needs to reconcile branch privacy policies for the teams. This is not a simple merge operation. we need to drop the policies that intersect between the too teams. eg:
a-team has
    project-a, a-team, private-only
    project-b, a-team, private
b-team has
    project-b, b-team, private-only
    project-c, b-team, private-only

merge a-team => b-team
    project-a, b-team, private-only
    project-b, b-team, private-only
    project-c, b-team, private-only
creating/updating
    project-a, b-team, private-only
Dropping this rule because it conflicts
    project-b, a-team, private

There are several _mergeBranch* methods used by merge. I think we need a new method that runs before them so that they can complete.

Curtis Hovey (sinzui)
Changed in launchpad:
assignee: nobody → Steve Kowalik (stevenk)
status: Triaged → In Progress
Revision history for this message
Curtis Hovey (sinzui) wrote :

This will be fixed when Lp replaces branch permissions with project permissions.

Changed in launchpad:
assignee: Steve Kowalik (stevenk) → nobody
status: In Progress → Triaged
Curtis Hovey (sinzui)
tags: added: sharing
Curtis Hovey (sinzui)
description: updated
Curtis Hovey (sinzui)
Changed in launchpad:
assignee: nobody → Curtis Hovey (sinzui)
status: Triaged → In Progress
Revision history for this message
Launchpad QA Bot (lpqabot) wrote :
tags: added: qa-needstesting
Changed in launchpad:
status: In Progress → Fix Committed
Curtis Hovey (sinzui)
tags: added: qa-ok
removed: qa-needstesting
Steve Kowalik (stevenk)
Changed in launchpad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.