'POST /api/repositories/{encoded_repository_id}/changeset_revision
Create a new tool shed repository commit - leaving PUT on parent
resource open for updating meta-attributes of the repository (and
Galaxy doesn\'t allow PUT multipart data anyway
https://trello.com/c/CQwmCeG6).
:param id: the encoded id of the Repository object
The following parameters may be included in the payload.
:param commit_message: hg commit message for update.'

@web.expose_api
def create_changeset_revision(self, trans, id, payload, **kwd):

    rdah = attribute_handlers.RepositoryDependencyAttributeHandler(self.app, unpopulate=False)
    tdah = attribute_handlers.ToolDependencyAttributeHandler(self.app, unpopulate=False)
    repository = repository_util.get_repository_in_tool_shed(self.app, id)
    if (not (trans.user_is_admin() or self.app.security_agent.user_can_administer_repository(trans.user, repository) or self.app.security_agent.can_push(self.app, trans.user, repository))):
        trans.response.status = 400
        return {'err_msg': 'You    do    not    have    permission    to    update    this    repository.'}
    repo_dir = repository.repo_path(self.app)
    repo = hg_util.get_repo_for_repository(self.app, repository=None, repo_path=repo_dir, create=False)
    upload_point = commit_util.get_upload_point(repository, **kwd)
    tip = repository.tip(self.app)
    file_data = payload.get('file')
    if isinstance(file_data, FieldStorage):
        assert (not isinstance(file_data.file, StringIO.StringIO))
        assert (file_data.file.name != '<fdopen>')
        local_filename = util.mkstemp_ln(file_data.file.name, 'upload_file_data_')
        file_data.file.close()
        file_data = dict(filename=file_data.filename, local_filename=local_filename)
    elif ((type(file_data) == dict) and ('local_filename' not in file_data)):
        raise Exception('Uploaded    file    was    encoded    in    a    way    not    understood.')
    commit_message = kwd.get('commit_message', 'Uploaded')
    uploaded_file = open(file_data['local_filename'], 'rb')
    uploaded_file_name = file_data['local_filename']
    isgzip = False
    isbz2 = False
    isgzip = checkers.is_gzip(uploaded_file_name)
    if (not isgzip):
        isbz2 = checkers.is_bz2(uploaded_file_name)
    if (isgzip or isbz2):
        tar = tarfile.open(uploaded_file_name, 'r:*')
    else:
        tar = tarfile.open(uploaded_file_name)
    new_repo_alert = False
    remove_repo_files_not_in_tar = True
    (ok, message, files_to_remove, content_alert_str, undesirable_dirs_removed, undesirable_files_removed) = repository_content_util.upload_tar(trans, rdah, tdah, repository, tar, uploaded_file, upload_point, remove_repo_files_not_in_tar, commit_message, new_repo_alert)
    if ok:
        hg_util.update_repository(repo)
        if (tip == repository.tip(self.app)):
            trans.response.status = 400
            message = 'No    changes    to    repository.'
            ok = False
        else:
            rmm = repository_metadata_manager.RepositoryMetadataManager(app=self.app, user=trans.user, repository=repository)
            (status, error_message) = rmm.set_repository_metadata_due_to_new_tip(trans.request.host, content_alert_str=content_alert_str, **kwd)
            if error_message:
                ok = False
                trans.response.status = 500
                message = error_message
    else:
        trans.response.status = 500
    if os.path.exists(uploaded_file_name):
        os.remove(uploaded_file_name)
    if (not ok):
        return {'err_msg': message}
    else:
        return {'message': message}
