Update and streamline remote repository detection.

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

Information

RBTools
master

Reviewers

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
resource.

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.

Diff Revision 2

This is not the most recent revision of the diff. The latest diff is revision 6. See what's changed.

orig
1
2
3
4
5
6

Commits

First Last Summary ID Author
Update and streamline remote repository detection.
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 resource. 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. Testing Done: - 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. Reviewed at https://reviews.reviewboard.org/r/11536/
16e8dd25d59e9b914277b8144d6f486719376193 David Trowbridge
rbtools/clients/__init__.py
rbtools/clients/bazaar.py
rbtools/clients/clearcase.py
rbtools/clients/cvs.py
rbtools/clients/git.py
rbtools/clients/mercurial.py
rbtools/clients/perforce.py
rbtools/clients/plastic.py
rbtools/clients/svn.py
rbtools/clients/tfs.py
rbtools/clients/tests/test_svn.py
rbtools/commands/__init__.py
rbtools/commands/land.py
rbtools/commands/patch.py
rbtools/commands/post.py
rbtools/commands/setup_repo.py
rbtools/commands/stamp.py
rbtools/commands/status.py
rbtools/commands/tests/test_setup_repo.py
rbtools/utils/repository.py
rbtools/utils/review_request.py
rbtools/utils/tests/test_repository.py
Loading...