async def do_tagging(config, task, repo_path):
    """Perform tagging, at ${repo_path}/src.

    This function will perform a mercurial tag, on 'default' head of target repository.
    It will tag the revision specified in the tag_info portion of the task payload, using
    the specified tags in that payload.

    Tags are forced to be created at the specified revision if they already existed.

    This function has the side affect of pulling the specified revision from the
    destination repository. This feature exists because mozilla-unified does not
    contain relbranches, though some releases are created on relbranches, so we must ensure
    the desired revision to tag is known to the local repository.

    Args:
        config (dict): the running config.
        task (dict): the running task.
        repo_path (str): The directory to place the resulting clone.

    Raises:
        FailedSubprocess: if the tag attempt doesn't succeed.

    Returns:
        bool: True if there are any changes.

    """
    tag_info = get_tag_info(task)
    desired_tags = await check_tags(config, tag_info, repo_path)
    if not desired_tags:
        log.info("No unique tags to add; skipping tagging.")
        return
    desired_rev = tag_info["revision"]
    dontbuild = get_dontbuild(task)
    dest_repo = get_source_repo(task)
    commit_msg = TAG_MSG.format(revision=desired_rev, tags=", ".join(desired_tags))
    if dontbuild:
        commit_msg += DONTBUILD_MSG
    log.info(
        "Pulling {revision} from {repo} explicitly.".format(
            revision=desired_rev, repo=dest_repo
        )
    )
    await run_hg_command(
        config, "pull", "-r", desired_rev, dest_repo, repo_path=repo_path
    )
    log.info(commit_msg)
    await run_hg_command(
        config,
        "tag",
        "-m",
        commit_msg,
        "-r",
        desired_rev,
        "-f",  # Todo only force if needed
        *desired_tags,
        repo_path=repo_path,
    )
    return True
예제 #2
0
async def do_tagging(context, directory):
    """Perform tagging, at ${directory}/src.

    This function will perform a mercurial tag, on 'default' head of target repository.
    It will tag the revision specified in the tag_info portion of the task payload, using
    the specified tags in that payload.

    Tags are forced to be created at the specified revision if they already existed.

    This function has the side affect of pulling the specified revision from the
    destination repository. This feature exists because mozilla-unified does not
    contain relbranches, though some releases are created on relbranches, so we must ensure
    the desired revision to tag is known to the local repository.

    Args:
        context (TreeScriptContext): the treescript context
        directory (str): The directory to place the resulting clone.

    Raises:
        FailedSubprocess: if the tag attempt doesn't succeed.

    """
    local_repo = os.path.join(directory, 'src')
    tag_info = get_tag_info(context.task)
    desired_tags = tag_info['tags']
    desired_rev = tag_info['revision']
    dontbuild = get_dontbuild(context.task)
    dest_repo = get_source_repo(context.task)
    commit_msg = TAG_MSG.format(revision=desired_rev,
                                tags=', '.join(desired_tags))
    if dontbuild:
        commit_msg += DONTBUILD_MSG
    log.info("Pulling {revision} from {repo} explicitly.".format(
        revision=desired_rev, repo=dest_repo))
    await run_hg_command(context,
                         'pull',
                         '-r',
                         desired_rev,
                         dest_repo,
                         local_repo=local_repo)
    log.info(commit_msg)
    await run_hg_command(
        context,
        'tag',
        '-m',
        commit_msg,
        '-r',
        desired_rev,
        '-f',  # Todo only force if needed
        *desired_tags,
        local_repo=local_repo)
예제 #3
0
async def do_tagging(context, directory):
    """Perform tagging, at ${directory}/src.

    This function will perform a mercurial tag, on 'default' head of target repository.
    It will tag the revision specified in the tag_info portion of the task payload, using
    the specified tags in that payload.

    Tags are forced to be created at the specified revision if they already existed.

    This function has the side affect of pulling the specified revision from the
    destination repository. This feature exists because mozilla-unified does not
    contain relbranches, though some releases are created on relbranches, so we must ensure
    the desired revision to tag is known to the local repository.

    Args:
        context (TreeScriptContext): the treescript context
        directory (str): The directory to place the resulting clone.

    Raises:
        FailedSubprocess: if the tag attempt doesn't succeed.

    """
    local_repo = os.path.join(directory, 'src')
    tag_info = get_tag_info(context.task)
    desired_tags = tag_info['tags']
    desired_rev = tag_info['revision']
    dest_repo = get_source_repo(context.task)
    commit_msg = TAG_MSG.format(revision=desired_rev, tags=', '.join(desired_tags))
    log.info("Pulling {revision} from {repo} explicitly.".format(
        revision=desired_rev, repo=dest_repo))
    await run_hg_command(context, 'pull', '-r', desired_rev, dest_repo,
                         local_repo=local_repo)
    log.info(commit_msg)
    await run_hg_command(context, 'tag', '-m', commit_msg, '-r', desired_rev,
                         '-f',  # Todo only force if needed
                         *desired_tags,
                         local_repo=local_repo)
예제 #4
0
def test_tag_missing_tag_info(task_defn):
    with pytest.raises(TaskVerificationError):
        ttask.get_tag_info(task_defn)
예제 #5
0
def test_tag_info(task_defn, tag_info):
    task_defn["payload"]["tag_info"] = tag_info
    tested_info = ttask.get_tag_info(task_defn)
    assert tested_info == tag_info
예제 #6
0
def test_tag_missing_tag_info(task_defn):
    with pytest.raises(TaskVerificationError):
        stask.get_tag_info(task_defn)
예제 #7
0
def test_tag_info(task_defn, tag_info):
    task_defn['payload']['tag_info'] = tag_info
    tested_info = stask.get_tag_info(task_defn)
    assert tested_info == tag_info