• 
      

    Modernize .reviewboardrc configuration management through rbtools.config.

    Review Request #13028 — Created May 10, 2023 and submitted — Latest diff uploaded

    Information

    RBTools
    release-5.x

    Reviewers

    This introduces a new rbtools.config module that's responsible for all
    configuration management for RBTools. It handles scanning for
    .reviewboardrc files, loading them, and providing an object that can
    be used for looking up settings.

    Half of this is code moved out from rbtools.utils.filesystem and
    updated (for typing, cleanup, and moving out config merging support to
    the other half).

    The other half is the new wrapper for configuration state.

    rbtools.config.config.RBToolsConfig (which is not at all a
    redundant-sunding namespace) is an object that wraps a loaded
    dictionary. This provides a few advantages over the old dictionary:

    • For any RBTools-provided settings, we now have type annotations.
    • We also have default values, which no longer have to live in Option
      or be handled by codepath-specific .get(..., default) calls.
    • Keys can be accessed via dictionary key access as before, or via
      attribute access now.
    • All keys are now documented in one place, with version information.

    Custom settings not known to the RBTools codebase are still loaded and
    can be accessed.

    This will make it easier to create and maintain settings going forward.

    Some initial plans for this change were scrapped, such as type
    validation on load and config-driven option construction. For the latter
    case, the thought was to make parameters, help output, and defaults all
    come from the central config, but upon reflection, it was ultimately
    decided that that would box us in if we ever wanted to make larger
    changes to options. These will remain independent, but a future change
    will update options to get their defaults from the central
    configuration.

    As of now, code is still using the now-deprecated functions for loading
    configuration. That will be updated in a separate change.

    Unit tests pass.

    Used this to post this change, verifying it relied on my aliases and
    my Markdown setting in my home directory and the repository settings
    in the repository.

    Commits

    Files