Example #1
0
File: util.py Project: jw/vonk
def repository_exists(path):
    o = urlparse(path)
    valid = False
    # local
    if o.scheme == '' or o.scheme == 'file':
        if exists(path):
            # exists, but is it a repository?
            repo = Repo(path)
            try:
                repo.hg_status()
                # is indeed a valid repository
                valid = True
            except HgException:
                pass
    # remote
    elif o.scheme == 'http' or o.scheme == 'https' or o.scheme == 'ssh':
        print("remote: {} -> {}".format(o, o.scheme))
        repo = Repo(path, user=o.username)
        try:
            repo.hg_status()
            # is indeed a valid repository
            valid = True
        except HgException:
            pass
    return valid