def _revision_arg(value):
    """
    Validates the value of the optional revision argument.

    :raises ValueError: If revision number is invalid.
    :param value: Argument value.
    :return: Validated value.
    """
    if value == 'head':
        return 0
    value = int(value)
    if value >= 0:
        return value
    raise ValueError("Must be 'head' or an integer >= 0.")
