import warnings


def update(data):
    """Update the data in place to remove deprecated properties.

    Args:
        data (dict): dictionary to be updated

    Returns:
        True if data was changed, False otherwise
    """
    updated = False
    if 'include' in data:
        msg = ("included configuration files should be updated manually"
               " [files={0}]")
        warnings.warn(msg.format(', '.join(data['include'])))

    # Spack 0.19 drops support for `spack:concretization` in favor of
    # `spack:concretizer:unify`. Here we provide an upgrade path that changes the former
    # into the latter, or warns when there's an ambiguity. Note that Spack 0.17 is not
    # forward compatible with `spack:concretizer:unify`.
    if 'concretization' in data:
        has_unify = 'unify' in data.get('concretizer', {})
        to_unify = {'together': True, 'separately': False}
        unify = to_unify[data['concretization']]

        if has_unify and data['concretizer']['unify'] != unify:
            warnings.warn(
                'The following configuration conflicts: '
                '`spack:concretization:{}` and `spack:concretizer:unify:{}`'
                '. Please update manually.'.format(
                    data['concretization'], data['concretizer']['unify']))
        else:
            data.update({'concretizer': {'unify': unify}})
            data.pop('concretization')
            updated = True

    return updated