Update and streamline local repository type detection.
Review Request #11503 — Created March 4, 2021 and submitted
The way that the local repository type was detected overly complicated
and inefficient. We would go through and assemble a complete
RepositoryInfo
for each possible repository, potentially doing excess
computation that would just be thrown away. In addition, there were some
situtations where a repository would be operating in a remote-only mode
(for example, using SVN with the--repository-url
option) where we
were scanning everything locally before finally using the remote.This change reworks the local repository detection in RBTools to
work in three phases:
- First we ask each tool if it's operating in "remote only" mode. At
the moment, SVN is the only such tool, but it's easy to imagine other
server-heavy services gaining this ability.- Second, we scan through each tool to see if it thinks there's an
active repository. This has been simplified to only fetch the local
working directory from the tool, rather than the full repository
info.- Finally, after having chosen a tool, we ask it for the repository
info structure.
- Ran unit tests.
- Smoke tested tools that use the repository.
Summary | ID |
---|---|
a4ce2a41da89265ae7b025fd02327baeb3453186 |
Description | From | Last Updated |
---|---|---|
E501 line too long (83 > 79 characters) |
reviewbot | |
Realizing it's kind of weird that we've been doing this based on path name length, and not number of directory … |
chipx86 | |
While here, can we change these to logging.warning? |
chipx86 | |
"Return ..." |
chipx86 | |
We can just return None at the end. Could even merge in the client_root check above with the client_root.lower() check, … |
chipx86 | |
We can skip the else: here, just return None. |
chipx86 | |
Since this is the Subversion code, we can probably make these docs more specific to Subversion's behavior. |
chipx86 | |
No need for parens. |
chipx86 | |
We can skip the else: and just return None. |
chipx86 | |
Totally your call here, but since we're almost certainly going to hvae a result from this call, if info is … |
chipx86 | |
Is this here so that Git and Mercurial can get access to it? Given how similar the name is to … |
chipx86 | |
Can you add a blank line between these? Any reason we can't import this at the top of the file? |
chipx86 | |
No need for the else:. |
chipx86 | |
We have a few versions of the docstring for this function. Let's copy/paste one summary for all of these, at … |
chipx86 | |
No need for the else:. |
chipx86 | |
No need for the else:. |
chipx86 | |
No need for the else:. |
chipx86 | |
No need for the else:. |
chipx86 | |
Why the direct comparison? Is None a valid option? |
chipx86 | |
Can you add Version Added? |
chipx86 | |
Can you add Version Added? |
chipx86 | |
There's a danger with this line (and any like it). One of the warts of Python. >>> d = {} … |
chipx86 | |
This could be: local_path = info.get('Working Copy Root Path') |
chipx86 | |
Can this use the new deprecated class? |
chipx86 | |
These still have to go before Returns, in order to render correctly. |
chipx86 | |
Same here. |
chipx86 |
- Commits:
-
Summary ID 4d2c52134ea2e68d48b3708237b234c1b7b25bb6 e8523194c8288854a22ec91f99a81442aca7f6a6
Checks run (2 succeeded)
-
Design looks great. Most of my comments are about consistency in docs and some logic flows.
-
Realizing it's kind of weird that we've been doing this based on path name length, and not number of directory components. Should we revisit that?
Right now, this:
/src/oh-boy-this-repository-name-is-long`
is considered deeper than:
/src/repos/libfoo/src
-
-
-
We can just
return None
at the end.Could even merge in the
client_root
check above with theclient_root.lower()
check, and simplify it all further. -
-
Since this is the Subversion code, we can probably make these docs more specific to Subversion's behavior.
-
-
-
Totally your call here, but since we're almost certainly going to hvae a result from this call, if
info
is set, we can skip the extra checks and do:try: path = info['Repository Root'] ... except KeyError: return None
-
Is this here so that Git and Mercurial can get access to it?
Given how similar the name is to the
SCMClient
version, maybe we should rename it. I was pretty confused for a second. -
-
-
We have a few versions of the docstring for this function. Let's copy/paste one summary for all of these, at least, so they don't diverge further down the road.
-
-
-
-
-
- Commits:
-
Summary ID e8523194c8288854a22ec91f99a81442aca7f6a6 213a192a6ed2f21901e6b575faf42c57735a9a91
Checks run (2 succeeded)
- Change Summary:
-
Fix remote-only mode with SVN.
- Commits:
-
Summary ID 213a192a6ed2f21901e6b575faf42c57735a9a91 27c20a7913520016edf2a9fc9c0b3323e7c56567
Checks run (2 succeeded)
-
-
-
-
There's a danger with this line (and any like it). One of the warts of Python.
>>> d = {} >>> print(d and 'key' in d) {} >>> n = None >>> print(n and 'key' in n) None
Due to the old-style ternary-ish statements Python allowed, we have to be very careful to explicitly compare each part of this if we're going to return it as a boolean. So,
info is not None
orbool(info)
or whatever makes sense here.I know we've done this wrong in places, and while it normally isn't an issue, I have fixed an obscure bug or two in the past due to this sort of quirk.
This might apply to other parts of the code. I haven't gone through carefully, just noticed this here.
-
-