mirror of
https://github.com/NixOS/nix
synced 2025-07-07 18:31:49 +02:00
Rename argument "final" to "result" to avoid ambiguity
This commit is contained in:
parent
0401e2710f
commit
b7882d51f2
2 changed files with 34 additions and 34 deletions
|
@ -178,24 +178,24 @@ std::pair<StorePath, Input> Input::fetchToStore(ref<Store> store) const
|
||||||
|
|
||||||
auto [storePath, input] = [&]() -> std::pair<StorePath, Input> {
|
auto [storePath, input] = [&]() -> std::pair<StorePath, Input> {
|
||||||
try {
|
try {
|
||||||
auto [accessor, final] = getAccessorUnchecked(store);
|
auto [accessor, result] = getAccessorUnchecked(store);
|
||||||
|
|
||||||
auto storePath = nix::fetchToStore(*store, SourcePath(accessor), FetchMode::Copy, final.getName());
|
auto storePath = nix::fetchToStore(*store, SourcePath(accessor), FetchMode::Copy, result.getName());
|
||||||
|
|
||||||
auto narHash = store->queryPathInfo(storePath)->narHash;
|
auto narHash = store->queryPathInfo(storePath)->narHash;
|
||||||
final.attrs.insert_or_assign("narHash", narHash.to_string(HashFormat::SRI, true));
|
result.attrs.insert_or_assign("narHash", narHash.to_string(HashFormat::SRI, true));
|
||||||
|
|
||||||
// FIXME: we would like to mark inputs as final in
|
// FIXME: we would like to mark inputs as final in
|
||||||
// getAccessorUnchecked(), but then we can't add
|
// getAccessorUnchecked(), but then we can't add
|
||||||
// narHash. Or maybe narHash should be excluded from the
|
// narHash. Or maybe narHash should be excluded from the
|
||||||
// concept of "final" inputs?
|
// concept of "final" inputs?
|
||||||
final.attrs.insert_or_assign("__final", Explicit<bool>(true));
|
result.attrs.insert_or_assign("__final", Explicit<bool>(true));
|
||||||
|
|
||||||
assert(final.isFinal());
|
assert(result.isFinal());
|
||||||
|
|
||||||
checkLocks(*this, final);
|
checkLocks(*this, result);
|
||||||
|
|
||||||
return {storePath, final};
|
return {storePath, result};
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
e.addTrace({}, "while fetching the input '%s'", to_string());
|
e.addTrace({}, "while fetching the input '%s'", to_string());
|
||||||
throw;
|
throw;
|
||||||
|
@ -205,12 +205,12 @@ std::pair<StorePath, Input> Input::fetchToStore(ref<Store> store) const
|
||||||
return {std::move(storePath), input};
|
return {std::move(storePath), input};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Input::checkLocks(Input specified, Input & final)
|
void Input::checkLocks(Input specified, Input & result)
|
||||||
{
|
{
|
||||||
/* If the original input is final, then we just return the
|
/* If the original input is final, then we just return the
|
||||||
original attributes, dropping any new fields returned by the
|
original attributes, dropping any new fields returned by the
|
||||||
fetcher. However, any fields that are in both the original and
|
fetcher. However, any fields that are in both the specified and
|
||||||
final input must be identical. */
|
result input must be identical. */
|
||||||
if (specified.isFinal()) {
|
if (specified.isFinal()) {
|
||||||
|
|
||||||
/* Backwards compatibility hack: we had some lock files in the
|
/* Backwards compatibility hack: we had some lock files in the
|
||||||
|
@ -221,24 +221,24 @@ void Input::checkLocks(Input specified, Input & final)
|
||||||
specified.attrs.insert_or_assign("narHash", prevNarHash->to_string(HashFormat::SRI, true));
|
specified.attrs.insert_or_assign("narHash", prevNarHash->to_string(HashFormat::SRI, true));
|
||||||
|
|
||||||
for (auto & field : specified.attrs) {
|
for (auto & field : specified.attrs) {
|
||||||
auto field2 = final.attrs.find(field.first);
|
auto field2 = result.attrs.find(field.first);
|
||||||
if (field2 != final.attrs.end() && field.second != field2->second)
|
if (field2 != result.attrs.end() && field.second != field2->second)
|
||||||
throw Error("mismatch in field '%s' of final input '%s', got '%s'",
|
throw Error("mismatch in field '%s' of input '%s', got '%s'",
|
||||||
field.first,
|
field.first,
|
||||||
attrsToJSON(specified.attrs),
|
attrsToJSON(specified.attrs),
|
||||||
attrsToJSON(final.attrs));
|
attrsToJSON(result.attrs));
|
||||||
}
|
}
|
||||||
|
|
||||||
final.attrs = specified.attrs;
|
result.attrs = specified.attrs;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto prevNarHash = specified.getNarHash()) {
|
if (auto prevNarHash = specified.getNarHash()) {
|
||||||
if (final.getNarHash() != prevNarHash) {
|
if (result.getNarHash() != prevNarHash) {
|
||||||
if (final.getNarHash())
|
if (result.getNarHash())
|
||||||
throw Error((unsigned int) 102, "NAR hash mismatch in input '%s', expected '%s' but got '%s'",
|
throw Error((unsigned int) 102, "NAR hash mismatch in input '%s', expected '%s' but got '%s'",
|
||||||
specified.to_string(), prevNarHash->to_string(HashFormat::SRI, true), final.getNarHash()->to_string(HashFormat::SRI, true));
|
specified.to_string(), prevNarHash->to_string(HashFormat::SRI, true), result.getNarHash()->to_string(HashFormat::SRI, true));
|
||||||
else
|
else
|
||||||
throw Error((unsigned int) 102, "NAR hash mismatch in input '%s', expected '%s' but got none",
|
throw Error((unsigned int) 102, "NAR hash mismatch in input '%s', expected '%s' but got none",
|
||||||
specified.to_string(), prevNarHash->to_string(HashFormat::SRI, true));
|
specified.to_string(), prevNarHash->to_string(HashFormat::SRI, true));
|
||||||
|
@ -246,32 +246,32 @@ void Input::checkLocks(Input specified, Input & final)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto prevLastModified = specified.getLastModified()) {
|
if (auto prevLastModified = specified.getLastModified()) {
|
||||||
if (final.getLastModified() != prevLastModified)
|
if (result.getLastModified() != prevLastModified)
|
||||||
throw Error("'lastModified' attribute mismatch in input '%s', expected %d, got %d",
|
throw Error("'lastModified' attribute mismatch in input '%s', expected %d, got %d",
|
||||||
final.to_string(), *prevLastModified, final.getLastModified().value_or(-1));
|
result.to_string(), *prevLastModified, result.getLastModified().value_or(-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto prevRev = specified.getRev()) {
|
if (auto prevRev = specified.getRev()) {
|
||||||
if (final.getRev() != prevRev)
|
if (result.getRev() != prevRev)
|
||||||
throw Error("'rev' attribute mismatch in input '%s', expected %s",
|
throw Error("'rev' attribute mismatch in input '%s', expected %s",
|
||||||
final.to_string(), prevRev->gitRev());
|
result.to_string(), prevRev->gitRev());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto prevRevCount = specified.getRevCount()) {
|
if (auto prevRevCount = specified.getRevCount()) {
|
||||||
if (final.getRevCount() != prevRevCount)
|
if (result.getRevCount() != prevRevCount)
|
||||||
throw Error("'revCount' attribute mismatch in input '%s', expected %d",
|
throw Error("'revCount' attribute mismatch in input '%s', expected %d",
|
||||||
final.to_string(), *prevRevCount);
|
result.to_string(), *prevRevCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<ref<SourceAccessor>, Input> Input::getAccessor(ref<Store> store) const
|
std::pair<ref<SourceAccessor>, Input> Input::getAccessor(ref<Store> store) const
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
auto [accessor, final] = getAccessorUnchecked(store);
|
auto [accessor, result] = getAccessorUnchecked(store);
|
||||||
|
|
||||||
checkLocks(*this, final);
|
checkLocks(*this, result);
|
||||||
|
|
||||||
return {accessor, std::move(final)};
|
return {accessor, std::move(result)};
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
e.addTrace({}, "while fetching the input '%s'", to_string());
|
e.addTrace({}, "while fetching the input '%s'", to_string());
|
||||||
throw;
|
throw;
|
||||||
|
@ -315,12 +315,12 @@ std::pair<ref<SourceAccessor>, Input> Input::getAccessorUnchecked(ref<Store> sto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto [accessor, final] = scheme->getAccessor(store, *this);
|
auto [accessor, result] = scheme->getAccessor(store, *this);
|
||||||
|
|
||||||
assert(!accessor->fingerprint);
|
assert(!accessor->fingerprint);
|
||||||
accessor->fingerprint = scheme->getFingerprint(store, final);
|
accessor->fingerprint = scheme->getFingerprint(store, result);
|
||||||
|
|
||||||
return {accessor, std::move(final)};
|
return {accessor, std::move(result)};
|
||||||
}
|
}
|
||||||
|
|
||||||
Input Input::applyOverrides(
|
Input Input::applyOverrides(
|
||||||
|
|
|
@ -113,17 +113,17 @@ public:
|
||||||
std::pair<StorePath, Input> fetchToStore(ref<Store> store) const;
|
std::pair<StorePath, Input> fetchToStore(ref<Store> store) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check the locking attributes in `final` against
|
* Check the locking attributes in `result` against
|
||||||
* `specified`. E.g. if `specified` has a `rev` attribute, then
|
* `specified`. E.g. if `specified` has a `rev` attribute, then
|
||||||
* `final` must have the same `rev` attribute. Throw an exception
|
* `result` must have the same `rev` attribute. Throw an exception
|
||||||
* if there is a mismatch.
|
* if there is a mismatch.
|
||||||
*
|
*
|
||||||
* If `specified` is marked final (i.e. has the `__final`
|
* If `specified` is marked final (i.e. has the `__final`
|
||||||
* attribute), then the intersection of attributes in `specified`
|
* attribute), then the intersection of attributes in `specified`
|
||||||
* and `final` must be equal, and `final.attrs` is set to
|
* and `result` must be equal, and `final.attrs` is set to
|
||||||
* `specified.attrs` (i.e. we discard any new attributes).
|
* `specified.attrs` (i.e. we discard any new attributes).
|
||||||
*/
|
*/
|
||||||
static void checkLocks(Input specified, Input & final);
|
static void checkLocks(Input specified, Input & result);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a `SourceAccessor` that allows access to files in the
|
* Return a `SourceAccessor` that allows access to files in the
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue