mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2025-02-07 18:57:19 +02:00
Merge pull request #9411 from edolstra/path-display
Improve SourceAccessor path display
This commit is contained in:
commit
9cd69e1c39
6 changed files with 19 additions and 2 deletions
|
@ -532,6 +532,9 @@ EvalState::EvalState(
|
||||||
, baseEnv(allocEnv(128))
|
, baseEnv(allocEnv(128))
|
||||||
, staticBaseEnv{std::make_shared<StaticEnv>(false, nullptr)}
|
, staticBaseEnv{std::make_shared<StaticEnv>(false, nullptr)}
|
||||||
{
|
{
|
||||||
|
corepkgsFS->setPathDisplay("<nix", ">");
|
||||||
|
internalFS->setPathDisplay("«nix-internal»", "");
|
||||||
|
|
||||||
countCalls = getEnv("NIX_COUNT_CALLS").value_or("0") != "0";
|
countCalls = getEnv("NIX_COUNT_CALLS").value_or("0") != "0";
|
||||||
|
|
||||||
assert(gcInitialised);
|
assert(gcInitialised);
|
||||||
|
|
|
@ -18,6 +18,7 @@ struct FSInputAccessorImpl : FSInputAccessor, PosixSourceAccessor
|
||||||
, allowedPaths(std::move(allowedPaths))
|
, allowedPaths(std::move(allowedPaths))
|
||||||
, makeNotAllowedError(std::move(makeNotAllowedError))
|
, makeNotAllowedError(std::move(makeNotAllowedError))
|
||||||
{
|
{
|
||||||
|
displayPrefix = root.isRoot() ? "" : root.abs();
|
||||||
}
|
}
|
||||||
|
|
||||||
void readFile(
|
void readFile(
|
||||||
|
|
|
@ -585,6 +585,8 @@ struct GitInputScheme : InputScheme
|
||||||
|
|
||||||
auto accessor = repo->getAccessor(rev);
|
auto accessor = repo->getAccessor(rev);
|
||||||
|
|
||||||
|
accessor->setPathDisplay("«" + input.to_string() + "»");
|
||||||
|
|
||||||
/* If the repo has submodules, fetch them and return a mounted
|
/* If the repo has submodules, fetch them and return a mounted
|
||||||
input accessor consisting of the accessor for the top-level
|
input accessor consisting of the accessor for the top-level
|
||||||
repo and the accessors for the submodules. */
|
repo and the accessors for the submodules. */
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace nix {
|
||||||
/**
|
/**
|
||||||
* A source accessor that uses the Unix filesystem.
|
* A source accessor that uses the Unix filesystem.
|
||||||
*/
|
*/
|
||||||
struct PosixSourceAccessor : SourceAccessor
|
struct PosixSourceAccessor : virtual SourceAccessor
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The most recent mtime seen by lstat(). This is a hack to
|
* The most recent mtime seen by lstat(). This is a hack to
|
||||||
|
|
|
@ -7,6 +7,7 @@ static std::atomic<size_t> nextNumber{0};
|
||||||
|
|
||||||
SourceAccessor::SourceAccessor()
|
SourceAccessor::SourceAccessor()
|
||||||
: number(++nextNumber)
|
: number(++nextNumber)
|
||||||
|
, displayPrefix{"«unknown»"}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,9 +56,15 @@ SourceAccessor::Stat SourceAccessor::lstat(const CanonPath & path)
|
||||||
throw Error("path '%s' does not exist", showPath(path));
|
throw Error("path '%s' does not exist", showPath(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SourceAccessor::setPathDisplay(std::string displayPrefix, std::string displaySuffix)
|
||||||
|
{
|
||||||
|
this->displayPrefix = std::move(displayPrefix);
|
||||||
|
this->displaySuffix = std::move(displaySuffix);
|
||||||
|
}
|
||||||
|
|
||||||
std::string SourceAccessor::showPath(const CanonPath & path)
|
std::string SourceAccessor::showPath(const CanonPath & path)
|
||||||
{
|
{
|
||||||
return path.abs();
|
return displayPrefix + path.abs() + displaySuffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,8 @@ struct SourceAccessor
|
||||||
{
|
{
|
||||||
const size_t number;
|
const size_t number;
|
||||||
|
|
||||||
|
std::string displayPrefix, displaySuffix;
|
||||||
|
|
||||||
SourceAccessor();
|
SourceAccessor();
|
||||||
|
|
||||||
virtual ~SourceAccessor()
|
virtual ~SourceAccessor()
|
||||||
|
@ -117,6 +119,8 @@ struct SourceAccessor
|
||||||
return number < x.number;
|
return number < x.number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setPathDisplay(std::string displayPrefix, std::string displaySuffix = "");
|
||||||
|
|
||||||
virtual std::string showPath(const CanonPath & path);
|
virtual std::string showPath(const CanonPath & path);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue