Update and streamline remote repository detection.

Review Request #11536 — Created March 21, 2021 and submitted — Latest diff uploaded


This is a major rework of the remote repository detection mechanism
within RBTools. The old implementation had a lot of issues, worst of
which was that there was a lot of inconsistency across different tool
implementations (for example, rbt post had a lot of additional
detection code that wasn't shared with other tools).

In the new implementation, we first try to fetch remote repositories,
filtering by the configured repository name, or detected repository
path(s). If this returns a single result, we can immediately return
that. If that fails, it means we're in a situation where the configured
paths on the server are different from the local path (including any
mirror_path), and we need to match in a different way. Individual tools
may implement find_matching_server_repository in order to do
tool-specific comparisons (which right now is done by SVN with
repository UUID and ClearCase with VOB UUID). This new method replaces
the old RepositoryInfo.find_server_repository_info method, which
always felt super ugly and clunky. In lieu of that, RepositoryInfo
subclasses can implement update_from_remote, which allows them to
include information from the remote repository or repository info

Commands which want to make use of the repository can now set the
needs_repository attribute. In this case, the command initialization
will handle finding the remote repository and updating the
RepositoryInfo appropriately. This corrects a couple issues where
commands were using the repository but forgetting to call the old
find_server_repository_info, potentially ending up with incorrect
data. The setup-repo command works a little differently because it
needs to potentially do that multiple times, but it uses the same
underlying mechanism to attempt to pre-filter the list of matching
repositories in a useful way.

This includes several other improvements and cleanups along the way:

  • Various places that fetch repositories to find matches have all been
    updated to use the locally detected tool to filter the response from
    the server. In the case where the server has a mix of repository
    types, this will dramatically improve the results.
  • rbt setup-repo's server initialization has been fixed to merge
    handling of --server and interactive entry. This both improves the
    code, and has the side effect of making it so that if the server
    specified on the command line doesn't work, it will prompt the user.
  • Ran unit tests.
  • Verified that repository match fetches properly passed tool= for API
    requests to filter the responses based on the locally detected tool.
  • rbt land: Tested basic behavior.
  • rbt patch: Tested basic behavior.
  • rbt post: Posted new and updated changes against Git, including with
    -u. Created a remote SVN repository and posted purely remote commits
    using --repository-url.
  • rbt setup-repo: Tested with both --server and specifying the
    server name interactively.
  • rbt stamp: Tested basic behavior.
  • rbt status: tested both with and without --all. Verified that
    repository detection was making the most minimal API requests possible
    based on various .reviewboardrc configurations.