Ensure all changes are fully qualified and affect only one file.
    This ensures that the diff output works and a state change is not
    incorrectly reported.

def _check_filepath(changes):
    '''
    Ensure all changes are fully qualified and affect only one file.
    This ensures that the diff output works and a state change is not
    incorrectly reported.
    '''
    filename = None
    for change_ in changes:
        try:
            cmd, arg = change_.split(' ', 1)

            if cmd not in METHOD_MAP:
                error = 'Command {0} is not supported (yet)'.format(cmd)
                raise ValueError(error)
            method = METHOD_MAP[cmd]
            parts = salt.utils.args.shlex_split(arg)
            if method in ['set', 'setm', 'move', 'remove']:
                filename_ = parts[0]
            else:
                _, _, filename_ = parts
            if not filename_.startswith('/files'):
                error = 'Changes should be prefixed with ' \
                        '/files if no context is provided,' \
                        ' change: {0}'.format(change_)
                raise ValueError(error)
            filename_ = re.sub('^/files|/$', '', filename_)
            if filename is not None:
                if filename != filename_:
                    error = 'Changes should be made to one ' \
                            'file at a time, detected changes ' \
                            'to {0} and {1}'.format(filename, filename_)
                    raise ValueError(error)
            filename = filename_
        except (ValueError, IndexError) as err:
            log.error(err)
            if 'error' not in locals():
                error = 'Invalid formatted command, ' \
                               'see debug log for details: {0}' \
                               .format(change_)
            else:
                error = six.text_type(err)
            raise ValueError(error)

    filename = _workout_filename(filename)

    return filename