Update and streamline remote repository detection.
Review Request #11536 — Created March 21, 2021 and submitted
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 implementfind_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 oldRepositoryInfo.find_server_repository_info
method, which
always felt super ugly and clunky. In lieu of that,RepositoryInfo
subclasses can implementupdate_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. Thesetup-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.
Summary | ID |
---|---|
c107677bf3773742a6323bc59265975a03a0e1ac |
Description | From | Last Updated |
---|---|---|
E501 line too long (82 > 79 characters) |
reviewbot | |
E501 line too long (82 > 79 characters) |
reviewbot | |
E501 line too long (82 > 79 characters) |
reviewbot | |
E501 line too long (82 > 79 characters) |
reviewbot | |
F841 local variable 'e' is assigned to but never used |
reviewbot | |
E501 line too long (82 > 79 characters) |
reviewbot | |
E501 line too long (82 > 79 characters) |
reviewbot | |
E501 line too long (166 > 79 characters) |
reviewbot | |
E501 line too long (170 > 79 characters) |
reviewbot | |
E501 line too long (161 > 79 characters) |
reviewbot | |
E501 line too long (157 > 79 characters) |
reviewbot | |
E501 line too long (127 > 79 characters) |
reviewbot | |
E501 line too long (118 > 79 characters) |
reviewbot | |
E501 line too long (145 > 79 characters) |
reviewbot | |
E501 line too long (146 > 79 characters) |
reviewbot | |
E501 line too long (153 > 79 characters) |
reviewbot | |
E501 line too long (146 > 79 characters) |
reviewbot | |
E501 line too long (111 > 79 characters) |
reviewbot | |
Can you add a Version Added and Type (in that order)? |
chipx86 | |
Can we make this a list of strings instead? I feel like this would be a bit nicer. |
chipx86 | |
Can you add Version Added? |
chipx86 | |
Can you add Version Added? |
chipx86 | |
Can you add Deprecated in here? |
chipx86 | |
Can we move these private methods after the public ones? |
chipx86 | |
This needs to be a full class path. |
chipx86 | |
No blank line here. |
chipx86 | |
This also needs to be a full class path. |
chipx86 | |
Can you add Deprecated here, and any other methods that emit a deprecation warning? |
chipx86 | |
The pattern I've been moving to is to import kgb directly, so we don't have to bother updating the import … |
chipx86 | |
E501 line too long (166 > 79 characters) |
reviewbot | |
Review Bot is going to complain about this forever. We could maybe do: ('http://...... '......'): { .... }, ... Also, … |
chipx86 | |
E501 line too long (170 > 79 characters) |
reviewbot | |
E501 line too long (161 > 79 characters) |
reviewbot | |
E501 line too long (157 > 79 characters) |
reviewbot | |
E501 line too long (127 > 79 characters) |
reviewbot | |
E501 line too long (118 > 79 characters) |
reviewbot | |
While here, want to move to @self.spy_for(urlopen)? |
chipx86 | |
Can we move this to the top? Or is this leftover debugging? |
chipx86 | |
Can you add Version Added and Type (in that order)? |
chipx86 | |
Can these be keyword arguments? |
chipx86 | |
The description shouldn't be indented. |
chipx86 | |
Can you add a Version Added? |
chipx86 | |
Missing a trailing comma. |
chipx86 | |
Alternatively: query.pop('path', None) |
chipx86 | |
To render correctly, this needs to be above Args, so it fits with the doc body. |
chipx86 | |
I like the , deprecated. We haven't done that before, but I think that's a great tag. We should put … |
chipx86 | |
A bunch of args (these onward) are documented as non-optional, but have a preset value. I assume this is because … |
chipx86 | |
This will also need to move above Args. |
chipx86 | |
For new code, let's do import kgb and then reference kgb.SpyAgency. This makes it easy to later use kgb.SpyOpReturn or … |
chipx86 | |
No need for parens here, or in the ones below. |
chipx86 | |
E501 line too long (145 > 79 characters) |
reviewbot | |
E501 line too long (146 > 79 characters) |
reviewbot | |
E501 line too long (153 > 79 characters) |
reviewbot | |
E501 line too long (146 > 79 characters) |
reviewbot | |
E501 line too long (111 > 79 characters) |
reviewbot | |
Let's do: @self.spy_for(urlopen) |
chipx86 | |
Shouldn't these all say "Testing get_repository_resource"? |
chipx86 | |
E128 continuation line under-indented for visual indent |
reviewbot | |
E128 continuation line under-indented for visual indent |
reviewbot | |
E128 continuation line under-indented for visual indent |
reviewbot | |
E128 continuation line under-indented for visual indent |
reviewbot | |
E128 continuation line under-indented for visual indent |
reviewbot | |
E128 continuation line under-indented for visual indent |
reviewbot | |
E128 continuation line under-indented for visual indent |
reviewbot | |
E128 continuation line under-indented for visual indent |
reviewbot | |
Before "Args". "Args" and "Returns" are special, and must come after. |
chipx86 | |
E127 continuation line over-indented for visual indent |
reviewbot | |
E127 continuation line over-indented for visual indent |
reviewbot | |
E127 continuation line over-indented for visual indent |
reviewbot | |
E127 continuation line over-indented for visual indent |
reviewbot | |
E127 continuation line over-indented for visual indent |
reviewbot | |
E127 continuation line over-indented for visual indent |
reviewbot | |
This needs to move before Returns, since it'll be part of the description text. |
chipx86 | |
Same here. |
chipx86 | |
Can you update this to use the full class path? |
chipx86 | |
Missing space before "In". |
chipx86 | |
Looking at the latest revision, do we still have any reason to default api_client and api_root to None? |
chipx86 |
- Commits:
-
Summary ID e58825a8dd743ed366fb8abf405867f323fa2c0f 16e8dd25d59e9b914277b8144d6f486719376193
Checks run (1 failed, 1 succeeded)
flake8
-
David, this is great. It really came together.
My comments are almost entirely doc-related, with a couple small suggestions here and there. The overall architecture, what an improvement.
-
-
-
-
-
-
-
-
-
-
-
The pattern I've been moving to is to
import kgb
directly, so we don't have to bother updating the import list to use any specific kgb tooling. -
Review Bot is going to complain about this forever. We could maybe do:
('http://...... '......'): { .... }, ...
Also, maybe take the base URL out of these and put them into a variable to both shorten these and make that part more contextually apparent?
-
-
-
-
-
-
-
-
-
-
I like the
, deprecated
. We haven't done that before, but I think that's a great tag. We should put that in Notion. -
A bunch of args (these onward) are documented as non-optional, but have a preset value. I assume this is because of the deprecated parameters preceding them. We should make sure to enforce any that are indeed required through checks at the start of the function.
-
-
For new code, let's do
import kgb
and then referencekgb.SpyAgency
. This makes it easy to later usekgb.SpyOpReturn
or other methods without extending the import list. -
-
-
- Commits:
-
Summary ID 16e8dd25d59e9b914277b8144d6f486719376193 861dfeb24631c849a64c754eab8f9682e358c432
Checks run (1 failed, 1 succeeded)
flake8
- Commits:
-
Summary ID 861dfeb24631c849a64c754eab8f9682e358c432 2ddd45089f35337a6239e7a041747cb5800e46c5
Checks run (1 failed, 1 succeeded)
flake8
- Commits:
-
Summary ID 2ddd45089f35337a6239e7a041747cb5800e46c5 a8a053158fe2303fd0a3919eb07f0aa70d68e50e