def METHOD_NAME(ret, target, name, user, identity, rev, opts):
    try:
        result = __salt__["hg.clone"](
            target, name, user=user, identity=identity, opts=opts
        )
    except CommandExecutionError as err:
        ret["result"] = False
        ret["comment"] = err
        return ret
    if not os.path.isdir(target):
        return _fail(ret, result)
    if rev:
        try:
            __salt__["hg.update"](target, rev, user=user)
        except CommandExecutionError as err:
            ret["result"] = False
            ret["comment"] = err
            return ret
    new_rev = __salt__["hg.revision"](cwd=target, user=user)
    message = "Repository {} cloned to {}".format(name, target)
    log.info(message)
    ret["comment"] = message
    ret["changes"]["new"] = name
    ret["changes"]["revision"] = new_rev
    return ret