def METHOD_NAME(ret, name, target, clean, user, identity, rev, opts, update_head):
    """
    Update the repo to a given revision. Using clean passes -C to the hg up
    """
    log.debug('target %s is found, "hg pull && hg up is probably required"', target)
    current_rev = __salt__["hg.revision"](target, user=user, rev=".")
    if not current_rev:
        return _fail(ret, "Seems that {} is not a valid hg repo".format(target))
    if __opts__["test"]:
        return _neutral_test(
            ret,
            "Repository {} update is probably required (current revision is {})".format(
                target, current_rev
            ),
        )
    try:
        pull_out = __salt__["hg.pull"](
            target, user=user, identity=identity, opts=opts, repository=name
        )
    except CommandExecutionError as err:
        ret["result"] = False
        ret["comment"] = err
        return ret
    if update_head is False:
        changes = "no changes found" not in pull_out
        if changes:
            ret["comment"] = (
                "Update is probably required but update_head=False so we will skip"
                " updating."
            )
        else:
            ret[
                "comment"
            ] = "No changes found and update_head=False so will skip updating."
        return ret
    if rev:
        try:
            __salt__["hg.update"](target, rev, force=clean, user=user)
        except CommandExecutionError as err:
            ret["result"] = False
            ret["comment"] = err
            return ret
    else:
        try:
            __salt__["hg.update"](target, "tip", force=clean, user=user)
        except CommandExecutionError as err:
            ret["result"] = False
            ret["comment"] = err
            return ret
    new_rev = __salt__["hg.revision"](cwd=target, user=user, rev=".")
    if current_rev != new_rev:
        revision_text = "{} => {}".format(current_rev, new_rev)
        log.info("Repository %s updated: %s", target, revision_text)
        ret["comment"] = "Repository {} updated.".format(target)
        ret["changes"]["revision"] = revision_text
    elif "error:" in pull_out:
        return _fail(ret, "An error was thrown by hg:\n{}".format(pull_out))
    return ret