def try_to_replace(self, provider, other, problems):
rlist = self.reqts[other]<EOL>unmatched = set()<EOL>for s in rlist:<EOL><INDENT>matcher = self.get_matcher(s)<EOL>if not matcher.match(provider.version):<EOL><INDENT>unmatched.add(s)<EOL><DEDENT><DEDENT>if unmatched:<EOL><INDENT>problems.add(('<STR_LIT>', provider, other,<EOL>frozenset(unmatched)))<EOL>result = False<EOL><DEDENT>else:<EOL><INDENT>self.remove_distribution(other)<EOL>del self.reqts[other]<EOL>for s in rlist:<EOL><INDENT>self.reqts.setdefault(provider, set()).add(s)<EOL><DEDENT>self.add_distribution(provider)<EOL>result = True<EOL><DEDENT>return result<EOL>
Attempt to replace one provider with another. This is typically used
when resolving dependencies from multiple sources, e.g. A requires
(B >= 1.0) while C requires (B >= 1.1).

For successful replacement, ``provider`` must meet all the requirements
which ``other`` fulfills.

:param provider: The provider we are trying to replace with.
:param other: The provider we're trying to replace.
:param problems: If False is returned, this will contain what
                 problems prevented replacement. This is currently
                 a tuple of the literal string 'cantreplace',
                 ``provider``, ``other``  and the set of requirements
                 that ``provider`` couldn't fulfill.
:return: True if we can replace ``other`` with ``provider``, else
         False.