<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 async def populate_jsone_context(chain, parent_link, decision_link, tasks_for):
 """Populate the json-e context to rebuild ``parent_link``'s task definition. This defines the context that `.taskcluster.yml` expects to be rendered with. See comments at the top of that file for details. Args: chain (ChainOfTrust):
 the chain of trust to add to. parent_link (LinkOfTrust):
 the parent link to test. decision_link (LinkOfTrust):
 the parent link's decision task link. tasks_for (str):
 the reason the parent link was created (cron, hg-push, action) Raises: CoTError, KeyError, ValueError: on failure. Returns: dict: the json-e context. """

    task_ids = {
         "default": parent_link.task_id,
         "decision": decision_link.task_id,
    }
    source_url = get_source_url(decision_link)
    project = get_and_check_project(chain.context.config['valid_vcs_rules'], source_url)
    log.debug("task_ids: {}".format(task_ids))
    jsone_context = {
        'now': parent_link.task['created'],
        'as_slugid': lambda x: task_ids.get(x, task_ids['default']),
        'tasks_for': tasks_for,
        'repository': {
            'url': get_repo(decision_link.task, decision_link.context.config['source_env_prefix']),
            'project': project,
        },
        'ownTaskId': parent_link.task_id,
        'taskId': None
    }

    if chain.context.config['cot_product'] in ('mobile', 'application-services'):
        if tasks_for == 'github-release':
            jsone_context.update(
                await _get_additional_github_releases_jsone_context(decision_link)
            )
        elif tasks_for == 'cron':
            jsone_context.update(_get_additional_git_cron_jsone_context(decision_link))
        elif tasks_for == 'github-pull-request':
            jsone_context.update(
                await _get_additional_github_pull_request_jsone_context(decision_link)
            )
        elif tasks_for == 'github-push':
            jsone_context.update(
                await _get_additional_github_push_jsone_context(decision_link)
            )
        else:
            raise CoTError('Unknown tasks_for "{}" for cot_product "mobile"!'.format(tasks_for))
    else:
        jsone_context['repository']['level'] = await get_scm_level(chain.context, project)

        if tasks_for == 'action':
            jsone_context.update(
                await _get_additional_hg_action_jsone_context(parent_link, decision_link)
            )
        elif tasks_for == 'hg-push':
            jsone_context.update(
                await _get_additional_hg_push_jsone_context(parent_link, decision_link)
            )
        elif tasks_for == 'cron':
            jsone_context.update(
                await _get_additional_hg_cron_jsone_context(parent_link, decision_link)
            )
        else:
            raise CoTError("Unknown tasks_for {}!".format(tasks_for))

    log.debug("{} json-e context:".format(parent_link.name))
    # format_json() breaks on lambda values; use pprint.pformat here.
    log.debug(pprint.pformat(jsone_context))
    return jsone_context