'Sync the version data in the repo (on the build server) with what we have in the database.
Returns the identifiers for the versions that have been deleted.'

def sync_versions(self, request, **kwargs):

    project = get_object_or_404(Project, pk=kwargs['pk'])
    try:
        post_data = self.deserialize(request, request.body, format=request.META.get('CONTENT_TYPE', 'application/json'))
        data = json.loads(post_data)
        self.method_check(request, allowed=['post'])
        self.is_authenticated(request)
        self.throttle_check(request)
        self.log_throttled_access(request)
        self._sync_versions(project, data['tags'])
        self._sync_versions(project, data['branches'])
        deleted_versions = self._delete_versions(project, data)
    except Exception as e:
        return self.create_response(request, {'exception': str(e)}, response_class=HttpApplicationError)
    return self.create_response(request, deleted_versions)
