def describe(cwd, rev='tip', user=None):
    '''
    Mimic git describe and return an identifier for the given revision

    cwd
        The path to the Mercurial repository

    rev: tip
        The path to the archive tarball

    user : None
        Run hg as a user other than what the minion runs as

    CLI Example:

    .. code-block:: bash

        salt '*' hg.describe /path/to/repo
    '''
    cmd = [
            'hg',
            'log',
            '-r',
            '{0}'.format(rev),
            '--template',
            "'{{latesttag}}-{{latesttagdistance}}-{{node|short}}'"
            ]
    desc = __salt__['cmd.run_stdout'](
            cmd,
            cwd=cwd,
            runas=user,
            python_shell=False)

    return desc or revision(cwd, rev, short=True)
Mimic git describe and return an identifier for the given revision

    cwd
        The path to the Mercurial repository

    rev: tip
        The path to the archive tarball

    user : None
        Run hg as a user other than what the minion runs as

    CLI Example:

    .. code-block:: bash

        salt '*' hg.describe /path/to/repo