def get_repo_url(pypirc, repository):
    """Fetch the RepositoryURL for a given repository, reading info from pypirc.

    Will try to find the repository in the .pypirc, including username/password.

    Args:
        pypirc (str): path to the .pypirc config file
        repository (str): URL or alias for the repository

    Returns:
        base.RepositoryURL for the repository
    """
    pypirc = os.path.abspath(os.path.expanduser(pypirc))
    pypi_config = base.PyPIConfig(pypirc)
    repo_config = pypi_config.get_repo_config(repository)
    if repo_config:
        return repo_config.get_clean_url()
    else:
        return base.RepositoryURL(repository)