Merge pull request #10517 from edolstra/path-display

Add missing setPathDisplay() calls
This commit is contained in:
Eelco Dolstra 2024-04-17 15:36:08 +02:00 committed by GitHub
commit d53ad516e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 20 additions and 5 deletions

View file

@ -38,7 +38,7 @@ std::string FilteringInputAccessor::readLink(const CanonPath & path)
std::string FilteringInputAccessor::showPath(const CanonPath & path)
{
return next->showPath(prefix / path);
return displayPrefix + next->showPath(prefix / path) + displaySuffix;
}
void FilteringInputAccessor::checkAccess(const CanonPath & path)

View file

@ -27,7 +27,9 @@ struct FilteringInputAccessor : InputAccessor
: next(src.accessor)
, prefix(src.path)
, makeNotAllowedError(std::move(makeNotAllowedError))
{ }
{
displayPrefix.clear();
}
std::string readFile(const CanonPath & path) override;

View file

@ -24,7 +24,10 @@ ref<InputAccessor> makeStorePathAccessor(
const StorePath & storePath)
{
// FIXME: should use `store->getFSAccessor()`
return makeFSInputAccessor(std::filesystem::path { store->toRealPath(storePath) });
auto root = std::filesystem::path { store->toRealPath(storePath) };
auto accessor = makeFSInputAccessor(root);
accessor->setPathDisplay(root);
return accessor;
}
SourcePath getUnfilteredRootPath(CanonPath path)

View file

@ -9,6 +9,8 @@ struct MountedInputAccessor : InputAccessor
MountedInputAccessor(std::map<CanonPath, ref<InputAccessor>> _mounts)
: mounts(std::move(_mounts))
{
displayPrefix.clear();
// Currently we require a root filesystem. This could be relaxed.
assert(mounts.contains(CanonPath::root));
@ -48,7 +50,7 @@ struct MountedInputAccessor : InputAccessor
std::string showPath(const CanonPath & path) override
{
auto [accessor, subpath] = resolve(path);
return accessor->showPath(subpath);
return displayPrefix + accessor->showPath(subpath) + displaySuffix;
}
std::pair<ref<InputAccessor>, CanonPath> resolve(CanonPath path)

View file

@ -645,6 +645,7 @@ struct GitInputScheme : InputScheme
auto submoduleInput = fetchers::Input::fromAttrs(std::move(attrs));
auto [submoduleAccessor, submoduleInput2] =
submoduleInput.getAccessor(store);
submoduleAccessor->setPathDisplay("«" + submoduleInput.to_string() + "»");
mounts.insert_or_assign(submodule.path, submoduleAccessor);
}
@ -681,6 +682,8 @@ struct GitInputScheme : InputScheme
exportIgnore,
makeNotAllowedError(repoInfo.url));
accessor->setPathDisplay(repoInfo.url);
/* If the repo has submodules, return a mounted input accessor
consisting of the accessor for the top-level repo and the
accessors for the submodule workdirs. */
@ -697,6 +700,7 @@ struct GitInputScheme : InputScheme
auto submoduleInput = fetchers::Input::fromAttrs(std::move(attrs));
auto [submoduleAccessor, submoduleInput2] =
submoduleInput.getAccessor(store);
submoduleAccessor->setPathDisplay("«" + submoduleInput.to_string() + "»");
/* If the submodule is dirty, mark this repo dirty as
well. */

View file

@ -352,7 +352,11 @@ struct MercurialInputScheme : InputScheme
auto storePath = fetchToStore(store, input);
return {makeStorePathAccessor(store, storePath), input};
auto accessor = makeStorePathAccessor(store, storePath);
accessor->setPathDisplay("«" + input.to_string() + "»");
return {accessor, input};
}
bool isLocked(const Input & input) const override