Make RBTools command initialization easier and more consistent.

Review Request #11480 — Created Feb. 22, 2021 and submitted — Latest diff uploaded

Information

RBTools
master

Reviewers

The different commands in RBTools have lots of differerent needs. Some
of them interact only with your local repository, some of them interact
only with the server API, some do both, and some do neither. We've
traditionally had a few methods to handle things like setting up the API
or the SCMClient, but usage of these was inconsistent and resulted in a
lot of repeated boilerplate. Because of this and the history of RBTools
development, usage of all of this was somewhat inconsistent, with many
commands doing more or less than they really needed to do.

This change is the first of a couple to clean this up. Two new
attributes have been added to the base Command class: needs_api and
needs_scm_client. Subclasses can set these to True depending on
their needs, and then prior to main being called, the initialization
process will set various attributes: api_client, api_root,
capabilities, repository_info, server_url, and tool.

This change handles most of the initialization process. The one major
remaining piece are the calls to find_server_repository_info, which
will require some more involved changes (for example, short-cutting in
the case when REPOSITORY_NAME or REPOSITORY_URL are defined).

  • Smoke tested basic functionality for all changed commands.
  • Verified rbt patch behavior was correct with both ID and full URL
    (ID only and ID + diff revision) arguments. Checked that
    rbt patch --print did not initialize any repository support.
  • Verified rbt land behavior was correct with both ID and full URL
    --review-request-id option.
  • Checked that rbt status --all did not initialize any repository
    support.

Commits

Files