'Merge the dependency into this spec.
Caller should assume that this routine can owns the dep parameter
(i.e. it needs to be a copy of any internal structures like
dependencies on Package class objects).
This is the core of normalize().  There are some basic steps:
* If dep is virtual, evaluate whether it corresponds to an
existing concrete dependency, and merge if so.
* If it\'s real and it provides some virtual dep, see if it provides
what some virtual dependency wants and merge if so.
* Finally, if none of the above, merge dependency and its
constraints into this spec.
This method returns True if the spec was changed, False otherwise.'

def _merge_dependency(self, dep, deptypes, visited, spec_deps, provider_index):

    changed = False
    if dep.virtual:
        visited.add(dep.name)
        provider = self._find_provider(dep, provider_index)
        if provider:
            dep = provider
    else:
        index = ProviderIndex([dep], restrict=True)
        items = list(spec_deps.items())
        for (name, vspec) in items:
            if index.providers_for(vspec):
                vspec._replace_with(dep)
                del spec_deps[vspec.name]
                changed = True
            else:
                required = index.providers_for(vspec.name)
                if required:
                    raise UnsatisfiableProviderSpecError(required[0], dep)
        provider_index.update(dep)
    if (dep.name not in spec_deps):
        spec_deps[dep.name] = dep
        changed = True
    else:
        try:
            changed |= spec_deps[dep.name].constrain(dep)
        except UnsatisfiableSpecError as e:
            e.message = "Invalid    spec:    '%s'.    "
            e.message += 'Package    %s    requires    %s    %s,    but    spec    asked    for    %s'
            e.message %= (spec_deps[dep.name], dep.name, e.constraint_type, e.required, e.provided)
            raise e
    dependency = spec_deps[dep.name]
    if (dep.name not in self._dependencies):
        self._add_dependency(dependency, deptypes)
    changed |= dependency._normalize_helper(visited, spec_deps, provider_index)
    return changed
