def METHOD_NAME(cwd, rev, force=False, user=None):
    """
    Update to a given revision
    cwd
        The path to the Mercurial repository
    rev
        The revision to update to
    force : False
        Force an update
    user : None
        Run hg as a user other than what the minion runs as
    CLI Example:
    .. code-block:: bash
        salt devserver1 hg.update /path/to/repo somebranch
    """
    cmd = ["hg", "update", "{}".format(rev)]
    if force:
        cmd.append("-C")
    ret = __salt__["cmd.run_all"](cmd, cwd=cwd, runas=user, python_shell=False)
    if ret["retcode"] != 0:
        raise CommandExecutionError(
            "Hg command failed: {}".format(ret.get("stderr", ret["stdout"]))
        )
    return ret["stdout"]