Undo all file changes that happened between num_pre and num_post, leaving
    the files into the state of num_pre.

    .. warning::
        If one of the files has changes after num_post, they will be overwritten
        The snapshots are used to determine the file list, but the current
        version of the files will be overwritten by the versions in num_pre.

        You to undo changes between num_pre and the current version of the
        files use num_post=0.

    CLI Example:

    .. code-block:: bash

        salt '*' snapper.undo

def undo(config='root', files=None, num_pre=None, num_post=None):
    '''
    Undo all file changes that happened between num_pre and num_post, leaving
    the files into the state of num_pre.

    .. warning::
        If one of the files has changes after num_post, they will be overwritten
        The snapshots are used to determine the file list, but the current
        version of the files will be overwritten by the versions in num_pre.

        You to undo changes between num_pre and the current version of the
        files use num_post=0.

    CLI Example:

    .. code-block:: bash

        salt '*' snapper.undo
    '''
    pre, post = _get_num_interval(config, num_pre, num_post)

    changes = status(config, pre, post)
    changed = set(changes.keys())
    requested = set(files or changed)

    if not requested.issubset(changed):
        raise CommandExecutionError(
            'Given file list contains files that are not present'
            'in the changed filelist: {0}'.format(changed - requested))

    cmdret = __salt__['cmd.run']('snapper -c {0} undochange {1}..{2} {3}'.format(
       config, pre, post, ' '.join(requested)))

    try:
        components = cmdret.split(' ')
        ret = {}
        for comp in components:
            key, val = comp.split(':')
            ret[key] = val
        return ret
    except ValueError as exc:
        raise CommandExecutionError(
            'Error while processing Snapper response: {0}'.format(cmdret))