def allowed(repo, remote_user, config_group, config_item):
    """Read from repo config list to check if given user is allowed.

    within Heptapod, ``remote_user`` being ``None`` means that `hg` is invoked
    from the command line, or directly by a server-side process, such as
    the Rails application performing a merge.

    In these cases, the permission
    checking responsibility is on the caller. Hence a ``None`` remote user
    is always allowed.
    """
    allowed = repo.ui.configlist(config_group, config_item)
    if remote_user is None or '*' in allowed or remote_user in allowed:
        repo.ui.debug('user %r is allowed by %s.%s=%r' % (remote_user,
            config_group, config_item, allowed))
        return True
    return False
