Example #1
0
def main(argv):
    log = repolib.get_logger('validate-login')
    user = argv[-1]
    path = parse_path()

    log.info("Validating login for %r on %r", user, path)

    if path:
        repo = repolib.Repository(path)
        repo.repo_path = os.getcwd()
    else:
        log.error("Invalid command")
        return 1

    if not repo.exists:
        log.error("Repo %s does not exist", repo.full_path)
        return 1

    try:
        repo.load_from_hgrc()
    except IOError:
        log.error("Could not read repo config")
        return 1

    if not repo.can_be_read_by(user):
        log.error("You can not read this repository")
        return 1

    os.environ['SSH_HG_USER'] = user
    os.environ['SSH_HG_REPO'] = repo.full_path

    log.info("All checks passed, serving.")
    dispatch.dispatch(['-R', path, 'serve', '--stdio'])
Example #2
0
def main(argv):
    log = repolib.get_logger('lock-repo')

    try:
        return check_repo(os.environ, log)

    except IOError:
        log.error("Could not load repository config.")
        log.error("Failed to execute pre-lock checks.")
        return 1

    except KeyError:
        log.error("Incomplete or corrupted environment.")
        log.error("Failed to execute pre-lock checks.")
        return 1
Example #3
0
def main(argv):
    log = repolib.get_logger('sync-repo-config')

    try:
        cfg_file = argv[-1] if argv else "/etc/hgssh.cfg"
        cfg = repolib.ConfigLoader(cfg_file)
    except IOError:
        log.error("Config file %r doesn't exist", cfg_file)
        return 1

    sync_repository_config(cfg.repos, cfg.user_dict, log)

    try:
        sync_ssh_config(cfg.repo_user_authorized_keys, cfg.users, log)
    except ValueError, exc:
        log.error("%s", exc)
        return 1