def _determine_name_from_url(fs, repo_url):
    """Return the string name of the repository for 'repo_url' or raise.

    If there is not exactly one repository config that refers to 'repo_url'
    then raise.

    :fs: abdt_fs.Accessor to use to determine the repo name from the url
    :repo_url: string clone url of the repository we fetch from / push to
    :returns: string name of the matching config

    """
    repo_config_path_list = fs.repo_config_path_list()
    repo_name_config_list = abdi_repoargs.parse_config_file_list(
        repo_config_path_list)

    candidate_names = []

    for repo_name, repo_config in repo_name_config_list:
        url = abdi_repoargs.get_repo_url(repo_config)
        if repo_url == url:
            candidate_names.append(repo_name)

    if not candidate_names:
        raise Exception("url '{url}' didn't match any names".format(
            url=repo_url))

    if 1 > len(candidate_names):
        raise Exception("url '{url}' matches many names:\n{names}\n".format(
            url=repo_url,
            names=candidate_names))

    return candidate_names[0]


# -----------------------------------------------------------------------------
# Copyright (C) 2014 Bloomberg Finance L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ------------------------------ END-OF-FILE ----------------------------------
dataset/ETHPy150Open bloomberg/phabricator-tools/py/abd/abdcmd_rmrepo.py/_determine_name_from_url/swapped operands of `>`