Avoid superfluous RepositoryContent records
When adding and removing the same content in a repository version, don't update the RepositoryContent record (resulting in an superfluous RepositoryContent for which version_added == version_removed == current version). Instead, just delete the existing record. This fixes two problems:
- Such content is shown as added and removed.
- Re-adding the content again in the same version leads to a IntegrityError because the uniqueness constraint is violated.
Handle the "remove then re-add" case analogously.
(cherry picked from commit 96b76e0687ac52e8bc68751ec414c9b6b4501dc2)