Skip to content

[VFS] Add a "redirecting-with" field to overlays #3909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

bnbarham
Copy link

@bnbarham bnbarham commented Feb 7, 2022

Cherry-picks 502f14d and a5cff6a in order to add a new "redirecting-with" field to overlays.

The new field can be used to specify which filesystem and path the RedirectingFileSystem should try first.

Resolves rdar://87906715.

Extend "fallthrough" to allow a third option: "fallback". Fallthrough
allows the original path to used if the redirected (or mapped) path
fails. Fallback is the reverse of this, ie. use the original path and
fallback to the mapped path otherwise.

While this result *can* be achieved today using multiple overlays, this
adds a much more intuitive option. As an example, take two directories
"A" and "B". We would like files from "A" to be used, unless they don't
exist, in which case the VFS should fallback to those in "B".

With the current fallthrough option this is possible by adding two
overlays: one mapping from A -> B and another mapping from B -> A. Since
the frontend *nests* the two RedirectingFileSystems, the result will
be that "A" is mapped to "B" and back to "A", unless it isn't in "A" in
which case it fallsthrough to "B" (or fails if it exists in neither).

Using "fallback" semantics allows a single overlay instead: one mapping
from "A" to "B" but only using that mapping if the operation in "A"
fails first.

"redirect-only" is used to represent the current "fallthrough: false"
case.

Differential Revision: https://reviews.llvm.org/D117937
This fixes lldb's build. We can remove this in the future if we want but
for now this will be nicer to existing consumers.
@bnbarham bnbarham requested a review from akyrtzi February 7, 2022 22:48
@bnbarham
Copy link
Author

bnbarham commented Feb 7, 2022

@swift-ci please test

@bnbarham bnbarham merged commit 2eb19b6 into swiftlang:stable/20211026 Feb 8, 2022
@bnbarham bnbarham deleted the cherry-redirecting-with branch February 8, 2022 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants