diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-06-10 15:20:00 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-06-10 15:20:00 +0200 |
commit | fc6c7af4249bef4df8c729c71412ddbccfed5c77 (patch) | |
tree | d35b5c27df90c1985f10da27131b9a4701ed3531 /src/libexpr/flake | |
parent | 29e0748847dfeabbfaabbec8a588088fd1887fb1 (diff) |
Add helper function printInputPath()
Diffstat (limited to 'src/libexpr/flake')
-rw-r--r-- | src/libexpr/flake/flake.cc | 20 | ||||
-rw-r--r-- | src/libexpr/flake/lockfile.cc | 11 | ||||
-rw-r--r-- | src/libexpr/flake/lockfile.hh | 2 |
3 files changed, 21 insertions, 12 deletions
diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc index 5f021192b..73f94dae9 100644 --- a/src/libexpr/flake/flake.cc +++ b/src/libexpr/flake/flake.cc @@ -291,7 +291,7 @@ LockedFlake lockFlake( const InputPath & inputPathPrefix, 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 'inputs.nixops.inputs.nixpkgs.url = ...'). */ @@ -311,8 +311,8 @@ LockedFlake lockFlake( for (auto & [id, input2] : flakeInputs) { auto inputPath(inputPathPrefix); inputPath.push_back(id); - auto inputPathS = concatStringsSep("/", inputPath); - debug("computing input '%s'", concatStringsSep("/", inputPath)); + auto inputPathS = printInputPath(inputPath); + debug("computing input '%s'", inputPathS); /* Do we have an override for this input from one of the ancestors? */ @@ -332,6 +332,7 @@ LockedFlake lockFlake( /* Otherwise, it's relative to the current flake. */ InputPath path(inputPathPrefix); for (auto & i : *input.follows) path.push_back(i); + debug("input '%s' follows '%s'", inputPathS, printInputPath(path)); follows.insert_or_assign(inputPath, path); } continue; @@ -405,6 +406,7 @@ LockedFlake lockFlake( } else { /* We need to create a new lock file entry. So fetch this input. */ + debug("creating new input '%s'", inputPathS); if (!lockFlags.allowMutable && !input.ref.input.isImmutable()) throw Error("cannot update flake input '%s' in pure mode", inputPathS); @@ -460,8 +462,8 @@ LockedFlake lockFlake( /* Insert edges for 'follows' overrides. */ for (auto & [from, to] : follows) { debug("adding 'follows' node from '%s' to '%s'", - concatStringsSep("/", from), - concatStringsSep("/", to)); + printInputPath(from), + printInputPath(to)); assert(!from.empty()); @@ -474,8 +476,8 @@ LockedFlake lockFlake( auto toNode = newLockFile.root->findInput(to); if (!toNode) throw Error("flake input '%s' follows non-existent flake input '%s'", - concatStringsSep("/", from), - concatStringsSep("/", to)); + printInputPath(from), + printInputPath(to)); fromParentNode->inputs.insert_or_assign(from.back(), toNode); } @@ -483,11 +485,11 @@ LockedFlake lockFlake( for (auto & i : lockFlags.inputOverrides) if (!overridesUsed.count(i.first)) 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) 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); diff --git a/src/libexpr/flake/lockfile.cc b/src/libexpr/flake/lockfile.cc index 5c2f6f04c..9ba12bff7 100644 --- a/src/libexpr/flake/lockfile.cc +++ b/src/libexpr/flake/lockfile.cc @@ -236,15 +236,15 @@ std::string diffLockFiles(const LockFile & oldLocks, const LockFile & newLocks) while (i != oldFlat.end() || j != newFlat.end()) { 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; } 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; } else { if (!(i->second->lockedRef == j->second->lockedRef)) { res += fmt("* Updated '%s': '%s' -> '%s'\n", - concatStringsSep("/", i->first), + printInputPath(i->first), i->second->lockedRef, j->second->lockedRef); } @@ -256,4 +256,9 @@ std::string diffLockFiles(const LockFile & oldLocks, const LockFile & newLocks) return res; } +std::string printInputPath(const InputPath & path) +{ + return concatStringsSep("/", path); +} + } diff --git a/src/libexpr/flake/lockfile.hh b/src/libexpr/flake/lockfile.hh index 6b05e8c24..eb99ed997 100644 --- a/src/libexpr/flake/lockfile.hh +++ b/src/libexpr/flake/lockfile.hh @@ -69,6 +69,8 @@ std::ostream & operator <<(std::ostream & stream, const LockFile & lockFile); InputPath parseInputPath(std::string_view s); +std::string printInputPath(const InputPath & path); + std::string diffLockFiles(const LockFile & oldLocks, const LockFile & newLocks); } |