forked from lix-project/lix
Add helper function printInputPath()
This commit is contained in:
parent
29e0748847
commit
fc6c7af424
|
@ -291,7 +291,7 @@ LockedFlake lockFlake(
|
||||||
const InputPath & inputPathPrefix,
|
const InputPath & inputPathPrefix,
|
||||||
std::shared_ptr<const Node> oldNode)
|
std::shared_ptr<const Node> oldNode)
|
||||||
{
|
{
|
||||||
debug("computing lock file node '%s'", concatStringsSep("/", inputPathPrefix));
|
debug("computing lock file node '%s'", printInputPath(inputPathPrefix));
|
||||||
|
|
||||||
/* Get the overrides (i.e. attributes of the form
|
/* Get the overrides (i.e. attributes of the form
|
||||||
'inputs.nixops.inputs.nixpkgs.url = ...'). */
|
'inputs.nixops.inputs.nixpkgs.url = ...'). */
|
||||||
|
@ -311,8 +311,8 @@ LockedFlake lockFlake(
|
||||||
for (auto & [id, input2] : flakeInputs) {
|
for (auto & [id, input2] : flakeInputs) {
|
||||||
auto inputPath(inputPathPrefix);
|
auto inputPath(inputPathPrefix);
|
||||||
inputPath.push_back(id);
|
inputPath.push_back(id);
|
||||||
auto inputPathS = concatStringsSep("/", inputPath);
|
auto inputPathS = printInputPath(inputPath);
|
||||||
debug("computing input '%s'", concatStringsSep("/", inputPath));
|
debug("computing input '%s'", inputPathS);
|
||||||
|
|
||||||
/* Do we have an override for this input from one of the
|
/* Do we have an override for this input from one of the
|
||||||
ancestors? */
|
ancestors? */
|
||||||
|
@ -332,6 +332,7 @@ LockedFlake lockFlake(
|
||||||
/* Otherwise, it's relative to the current flake. */
|
/* Otherwise, it's relative to the current flake. */
|
||||||
InputPath path(inputPathPrefix);
|
InputPath path(inputPathPrefix);
|
||||||
for (auto & i : *input.follows) path.push_back(i);
|
for (auto & i : *input.follows) path.push_back(i);
|
||||||
|
debug("input '%s' follows '%s'", inputPathS, printInputPath(path));
|
||||||
follows.insert_or_assign(inputPath, path);
|
follows.insert_or_assign(inputPath, path);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -405,6 +406,7 @@ LockedFlake lockFlake(
|
||||||
} else {
|
} else {
|
||||||
/* We need to create a new lock file entry. So fetch
|
/* We need to create a new lock file entry. So fetch
|
||||||
this input. */
|
this input. */
|
||||||
|
debug("creating new input '%s'", inputPathS);
|
||||||
|
|
||||||
if (!lockFlags.allowMutable && !input.ref.input.isImmutable())
|
if (!lockFlags.allowMutable && !input.ref.input.isImmutable())
|
||||||
throw Error("cannot update flake input '%s' in pure mode", inputPathS);
|
throw Error("cannot update flake input '%s' in pure mode", inputPathS);
|
||||||
|
@ -460,8 +462,8 @@ LockedFlake lockFlake(
|
||||||
/* Insert edges for 'follows' overrides. */
|
/* Insert edges for 'follows' overrides. */
|
||||||
for (auto & [from, to] : follows) {
|
for (auto & [from, to] : follows) {
|
||||||
debug("adding 'follows' node from '%s' to '%s'",
|
debug("adding 'follows' node from '%s' to '%s'",
|
||||||
concatStringsSep("/", from),
|
printInputPath(from),
|
||||||
concatStringsSep("/", to));
|
printInputPath(to));
|
||||||
|
|
||||||
assert(!from.empty());
|
assert(!from.empty());
|
||||||
|
|
||||||
|
@ -474,8 +476,8 @@ LockedFlake lockFlake(
|
||||||
auto toNode = newLockFile.root->findInput(to);
|
auto toNode = newLockFile.root->findInput(to);
|
||||||
if (!toNode)
|
if (!toNode)
|
||||||
throw Error("flake input '%s' follows non-existent flake input '%s'",
|
throw Error("flake input '%s' follows non-existent flake input '%s'",
|
||||||
concatStringsSep("/", from),
|
printInputPath(from),
|
||||||
concatStringsSep("/", to));
|
printInputPath(to));
|
||||||
|
|
||||||
fromParentNode->inputs.insert_or_assign(from.back(), toNode);
|
fromParentNode->inputs.insert_or_assign(from.back(), toNode);
|
||||||
}
|
}
|
||||||
|
@ -483,11 +485,11 @@ LockedFlake lockFlake(
|
||||||
for (auto & i : lockFlags.inputOverrides)
|
for (auto & i : lockFlags.inputOverrides)
|
||||||
if (!overridesUsed.count(i.first))
|
if (!overridesUsed.count(i.first))
|
||||||
warn("the flag '--override-input %s %s' does not match any input",
|
warn("the flag '--override-input %s %s' does not match any input",
|
||||||
concatStringsSep("/", i.first), i.second);
|
printInputPath(i.first), i.second);
|
||||||
|
|
||||||
for (auto & i : lockFlags.inputUpdates)
|
for (auto & i : lockFlags.inputUpdates)
|
||||||
if (!updatesUsed.count(i))
|
if (!updatesUsed.count(i))
|
||||||
warn("the flag '--update-input %s' does not match any input", concatStringsSep("/", i));
|
warn("the flag '--update-input %s' does not match any input", printInputPath(i));
|
||||||
|
|
||||||
debug("new lock file: %s", newLockFile);
|
debug("new lock file: %s", newLockFile);
|
||||||
|
|
||||||
|
|
|
@ -236,15 +236,15 @@ std::string diffLockFiles(const LockFile & oldLocks, const LockFile & newLocks)
|
||||||
|
|
||||||
while (i != oldFlat.end() || j != newFlat.end()) {
|
while (i != oldFlat.end() || j != newFlat.end()) {
|
||||||
if (j != newFlat.end() && (i == oldFlat.end() || i->first > j->first)) {
|
if (j != newFlat.end() && (i == oldFlat.end() || i->first > j->first)) {
|
||||||
res += fmt("* Added '%s': '%s'\n", concatStringsSep("/", j->first), j->second->lockedRef);
|
res += fmt("* Added '%s': '%s'\n", printInputPath(j->first), j->second->lockedRef);
|
||||||
++j;
|
++j;
|
||||||
} else if (i != oldFlat.end() && (j == newFlat.end() || i->first < j->first)) {
|
} else if (i != oldFlat.end() && (j == newFlat.end() || i->first < j->first)) {
|
||||||
res += fmt("* Removed '%s'\n", concatStringsSep("/", i->first));
|
res += fmt("* Removed '%s'\n", printInputPath(i->first));
|
||||||
++i;
|
++i;
|
||||||
} else {
|
} else {
|
||||||
if (!(i->second->lockedRef == j->second->lockedRef)) {
|
if (!(i->second->lockedRef == j->second->lockedRef)) {
|
||||||
res += fmt("* Updated '%s': '%s' -> '%s'\n",
|
res += fmt("* Updated '%s': '%s' -> '%s'\n",
|
||||||
concatStringsSep("/", i->first),
|
printInputPath(i->first),
|
||||||
i->second->lockedRef,
|
i->second->lockedRef,
|
||||||
j->second->lockedRef);
|
j->second->lockedRef);
|
||||||
}
|
}
|
||||||
|
@ -256,4 +256,9 @@ std::string diffLockFiles(const LockFile & oldLocks, const LockFile & newLocks)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string printInputPath(const InputPath & path)
|
||||||
|
{
|
||||||
|
return concatStringsSep("/", path);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,8 @@ std::ostream & operator <<(std::ostream & stream, const LockFile & lockFile);
|
||||||
|
|
||||||
InputPath parseInputPath(std::string_view s);
|
InputPath parseInputPath(std::string_view s);
|
||||||
|
|
||||||
|
std::string printInputPath(const InputPath & path);
|
||||||
|
|
||||||
std::string diffLockFiles(const LockFile & oldLocks, const LockFile & newLocks);
|
std::string diffLockFiles(const LockFile & oldLocks, const LockFile & newLocks);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue