From fa01db9626a2e7ba97d9fea013f2f80f14251987 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 15 Apr 2024 17:38:29 +0200 Subject: [PATCH 1/4] StorePathAccessor: Fix path display Set the prefix to the store path to fix messages like "copying '/' to the store" to "copying '/nix/store/bla' to the store". --- src/libfetchers/fs-input-accessor.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libfetchers/fs-input-accessor.cc b/src/libfetchers/fs-input-accessor.cc index ee24c621a..d85363808 100644 --- a/src/libfetchers/fs-input-accessor.cc +++ b/src/libfetchers/fs-input-accessor.cc @@ -24,7 +24,10 @@ ref 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) From 6df58a0891ecec7beb09b6459d432a005aafc7d4 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 15 Apr 2024 18:22:33 +0200 Subject: [PATCH 2/4] MercurialInputScheme: Improve path display --- src/libfetchers/unix/mercurial.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libfetchers/unix/mercurial.cc b/src/libfetchers/unix/mercurial.cc index a2702338f..4e0b26274 100644 --- a/src/libfetchers/unix/mercurial.cc +++ b/src/libfetchers/unix/mercurial.cc @@ -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 From 79363b22730cb1a0e20e34b9c9f63f5568217926 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 16 Apr 2024 15:38:44 +0200 Subject: [PATCH 3/4] MountedInputAccessor, FilteringInputAccessor: Respect the path display prefix/suffix This was causing Git paths not to be rendered correctly. --- src/libfetchers/filtering-input-accessor.cc | 2 +- src/libfetchers/filtering-input-accessor.hh | 4 +++- src/libfetchers/mounted-input-accessor.cc | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/libfetchers/filtering-input-accessor.cc b/src/libfetchers/filtering-input-accessor.cc index 32343abc4..e0cbfd905 100644 --- a/src/libfetchers/filtering-input-accessor.cc +++ b/src/libfetchers/filtering-input-accessor.cc @@ -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) diff --git a/src/libfetchers/filtering-input-accessor.hh b/src/libfetchers/filtering-input-accessor.hh index 8111a72c5..133a6cee3 100644 --- a/src/libfetchers/filtering-input-accessor.hh +++ b/src/libfetchers/filtering-input-accessor.hh @@ -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; diff --git a/src/libfetchers/mounted-input-accessor.cc b/src/libfetchers/mounted-input-accessor.cc index 6f397eb17..b1eeaa97d 100644 --- a/src/libfetchers/mounted-input-accessor.cc +++ b/src/libfetchers/mounted-input-accessor.cc @@ -9,6 +9,8 @@ struct MountedInputAccessor : InputAccessor MountedInputAccessor(std::map> _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, CanonPath> resolve(CanonPath path) From 6892c9803c1559a7bfda57b7a5afdd6b62c4516e Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 16 Apr 2024 16:11:57 +0200 Subject: [PATCH 4/4] GitInputScheme: Fix path display for workdirs and submodules --- src/libfetchers/unix/git.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libfetchers/unix/git.cc b/src/libfetchers/unix/git.cc index 45e62ebe1..18915c0a7 100644 --- a/src/libfetchers/unix/git.cc +++ b/src/libfetchers/unix/git.cc @@ -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. */