From b7882d51f2da83d8062bbb0e353b41009bd25fcf Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 6 Nov 2024 13:19:53 +0100 Subject: [PATCH] Rename argument "final" to "result" to avoid ambiguity --- src/libfetchers/fetchers.cc | 60 ++++++++++++++++++------------------- src/libfetchers/fetchers.hh | 8 ++--- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/libfetchers/fetchers.cc b/src/libfetchers/fetchers.cc index 2aedb8a2eb5..5c06a6bcb80 100644 --- a/src/libfetchers/fetchers.cc +++ b/src/libfetchers/fetchers.cc @@ -178,24 +178,24 @@ std::pair Input::fetchToStore(ref store) const auto [storePath, input] = [&]() -> std::pair { 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; - 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 // getAccessorUnchecked(), but then we can't add // narHash. Or maybe narHash should be excluded from the // concept of "final" inputs? - final.attrs.insert_or_assign("__final", Explicit(true)); + result.attrs.insert_or_assign("__final", Explicit(true)); - assert(final.isFinal()); + assert(result.isFinal()); - checkLocks(*this, final); + checkLocks(*this, result); - return {storePath, final}; + return {storePath, result}; } catch (Error & e) { e.addTrace({}, "while fetching the input '%s'", to_string()); throw; @@ -205,12 +205,12 @@ std::pair Input::fetchToStore(ref store) const 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 original attributes, dropping any new fields returned by the - fetcher. However, any fields that are in both the original and - final input must be identical. */ + fetcher. However, any fields that are in both the specified and + result input must be identical. */ if (specified.isFinal()) { /* 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)); for (auto & field : specified.attrs) { - auto field2 = final.attrs.find(field.first); - if (field2 != final.attrs.end() && field.second != field2->second) - throw Error("mismatch in field '%s' of final input '%s', got '%s'", + auto field2 = result.attrs.find(field.first); + if (field2 != result.attrs.end() && field.second != field2->second) + throw Error("mismatch in field '%s' of input '%s', got '%s'", field.first, attrsToJSON(specified.attrs), - attrsToJSON(final.attrs)); + attrsToJSON(result.attrs)); } - final.attrs = specified.attrs; + result.attrs = specified.attrs; return; } if (auto prevNarHash = specified.getNarHash()) { - if (final.getNarHash() != prevNarHash) { - if (final.getNarHash()) + if (result.getNarHash() != prevNarHash) { + if (result.getNarHash()) 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 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)); @@ -246,32 +246,32 @@ void Input::checkLocks(Input specified, Input & final) } 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", - final.to_string(), *prevLastModified, final.getLastModified().value_or(-1)); + result.to_string(), *prevLastModified, result.getLastModified().value_or(-1)); } if (auto prevRev = specified.getRev()) { - if (final.getRev() != prevRev) + if (result.getRev() != prevRev) 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 (final.getRevCount() != prevRevCount) + if (result.getRevCount() != prevRevCount) throw Error("'revCount' attribute mismatch in input '%s', expected %d", - final.to_string(), *prevRevCount); + result.to_string(), *prevRevCount); } } std::pair, Input> Input::getAccessor(ref store) const { 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) { e.addTrace({}, "while fetching the input '%s'", to_string()); throw; @@ -315,12 +315,12 @@ std::pair, Input> Input::getAccessorUnchecked(ref sto } } - auto [accessor, final] = scheme->getAccessor(store, *this); + auto [accessor, result] = scheme->getAccessor(store, *this); 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( diff --git a/src/libfetchers/fetchers.hh b/src/libfetchers/fetchers.hh index 1ea75ba843b..b28ec456864 100644 --- a/src/libfetchers/fetchers.hh +++ b/src/libfetchers/fetchers.hh @@ -113,17 +113,17 @@ public: std::pair fetchToStore(ref 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 - * `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 `specified` is marked final (i.e. has the `__final` * 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). */ - static void checkLocks(Input specified, Input & final); + static void checkLocks(Input specified, Input & result); /** * Return a `SourceAccessor` that allows access to files in the