aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-03-28 23:22:10 +0000
committerJohn Ericson <git@JohnEricson.me>2020-03-29 11:23:15 -0400
commit87b32bab05ff91981c8847d66cd5502feb44f3b5 (patch)
treeff77f6703185a8b9544f354de5853254ef88a4d8 /src/libexpr
parenteb1911e277bfcc1b161cb996205ae1696f496099 (diff)
Use `enum struct` and drop prefixes
This does a few enums; the rest will be gotten in subsequent commits.
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/eval.cc4
-rw-r--r--src/libexpr/function-trace.cc4
-rw-r--r--src/libexpr/parser.y2
-rw-r--r--src/libexpr/primops.cc22
-rw-r--r--src/libexpr/primops/fetchGit.cc8
-rw-r--r--src/libexpr/primops/fetchMercurial.cc10
6 files changed, 25 insertions, 25 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index dac32b6f5..b94035a60 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -1661,10 +1661,10 @@ string EvalState::copyPathToStore(PathSet & context, const Path & path)
else {
auto p = settings.readOnlyMode
? store->computeStorePathForPath(std::string(baseNameOf(path)), checkSourcePath(path)).first
- : store->addToStore(std::string(baseNameOf(path)), checkSourcePath(path), true, htSHA256, defaultPathFilter, repair);
+ : store->addToStore(std::string(baseNameOf(path)), checkSourcePath(path), true, HashType::SHA256, defaultPathFilter, repair);
dstPath = store->printStorePath(p);
srcToStore.insert_or_assign(path, std::move(p));
- printMsg(lvlChatty, "copied source '%1%' -> '%2%'", path, dstPath);
+ printMsg(Verbosity::Chatty, "copied source '%1%' -> '%2%'", path, dstPath);
}
context.insert(dstPath);
diff --git a/src/libexpr/function-trace.cc b/src/libexpr/function-trace.cc
index c6057b384..882da9937 100644
--- a/src/libexpr/function-trace.cc
+++ b/src/libexpr/function-trace.cc
@@ -6,13 +6,13 @@ namespace nix {
FunctionCallTrace::FunctionCallTrace(const Pos & pos) : pos(pos) {
auto duration = std::chrono::high_resolution_clock::now().time_since_epoch();
auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(duration);
- printMsg(lvlInfo, "function-trace entered %1% at %2%", pos, ns.count());
+ printMsg(Verbosity::Info, "function-trace entered %1% at %2%", pos, ns.count());
}
FunctionCallTrace::~FunctionCallTrace() {
auto duration = std::chrono::high_resolution_clock::now().time_since_epoch();
auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(duration);
- printMsg(lvlInfo, "function-trace exited %1% at %2%", pos, ns.count());
+ printMsg(Verbosity::Info, "function-trace exited %1% at %2%", pos, ns.count());
}
}
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y
index 9c769e803..acffc23e3 100644
--- a/src/libexpr/parser.y
+++ b/src/libexpr/parser.y
@@ -625,7 +625,7 @@ Expr * EvalState::parseExprFromString(std::string_view s, const Path & basePath)
Expr * EvalState::parseStdin()
{
- //Activity act(*logger, lvlTalkative, format("parsing standard input"));
+ //Activity act(*logger, Verbosity::Talkative, format("parsing standard input"));
return parseExprFromString(drainFD(0), absPath("."));
}
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 8de234951..1ddbe33c4 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -719,14 +719,14 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
if (outputs.size() != 1 || *(outputs.begin()) != "out")
throw Error(format("multiple outputs are not supported in fixed-output derivations, at %1%") % posDrvName);
- HashType ht = outputHashAlgo.empty() ? htUnknown : parseHashType(outputHashAlgo);
+ HashType ht = outputHashAlgo.empty() ? HashType::Unknown : parseHashType(outputHashAlgo);
Hash h(*outputHash, ht);
auto outPath = state.store->makeFixedOutputPath(outputHashRecursive, h, drvName);
if (!jsonObject) drv.env["out"] = state.store->printStorePath(outPath);
drv.outputs.insert_or_assign("out", DerivationOutput(std::move(outPath),
(outputHashRecursive ? "r:" : "") + printHashType(h.type),
- h.to_string(Base16, false)));
+ h.to_string(Base::Base16, false)));
}
else {
@@ -756,7 +756,7 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
auto drvPath = writeDerivation(state.store, drv, drvName, state.repair);
auto drvPathS = state.store->printStorePath(drvPath);
- printMsg(lvlChatty, "instantiated '%1%' -> '%2%'", drvName, drvPathS);
+ printMsg(Verbosity::Chatty, "instantiated '%1%' -> '%2%'", drvName, drvPathS);
/* Optimisation, but required in read-only mode! because in that
case we don't actually write store derivations, so we can't
@@ -933,13 +933,13 @@ static void prim_hashFile(EvalState & state, const Pos & pos, Value * * args, Va
{
string type = state.forceStringNoCtx(*args[0], pos);
HashType ht = parseHashType(type);
- if (ht == htUnknown)
+ if (ht == HashType::Unknown)
throw Error(format("unknown hash type '%1%', at %2%") % type % pos);
PathSet context; // discarded
Path p = state.coerceToPath(pos, *args[1], context);
- mkString(v, hashFile(ht, state.checkSourcePath(p)).to_string(Base16, false), context);
+ mkString(v, hashFile(ht, state.checkSourcePath(p)).to_string(Base::Base16, false), context);
}
/* Read a directory (without . or ..) */
@@ -1073,8 +1073,8 @@ static void addPath(EvalState & state, const Pos & pos, const string & name, con
Path dstPath;
if (!expectedHash || !state.store->isValidPath(*expectedStorePath)) {
dstPath = state.store->printStorePath(settings.readOnlyMode
- ? state.store->computeStorePathForPath(name, path, recursive, htSHA256, filter).first
- : state.store->addToStore(name, path, recursive, htSHA256, filter, state.repair));
+ ? state.store->computeStorePathForPath(name, path, recursive, HashType::SHA256, filter).first
+ : state.store->addToStore(name, path, recursive, HashType::SHA256, filter, state.repair));
if (expectedHash && expectedStorePath != state.store->parseStorePath(dstPath))
throw Error("store path mismatch in (possibly filtered) path added from '%s'", path);
} else
@@ -1122,7 +1122,7 @@ static void prim_path(EvalState & state, const Pos & pos, Value * * args, Value
} else if (n == "recursive")
recursive = state.forceBool(*attr.value, *attr.pos);
else if (n == "sha256")
- expectedHash = Hash(state.forceStringNoCtx(*attr.value, *attr.pos), htSHA256);
+ expectedHash = Hash(state.forceStringNoCtx(*attr.value, *attr.pos), HashType::SHA256);
else
throw EvalError(format("unsupported argument '%1%' to 'addPath', at %2%") % attr.name % *attr.pos);
}
@@ -1806,13 +1806,13 @@ static void prim_hashString(EvalState & state, const Pos & pos, Value * * args,
{
string type = state.forceStringNoCtx(*args[0], pos);
HashType ht = parseHashType(type);
- if (ht == htUnknown)
+ if (ht == HashType::Unknown)
throw Error(format("unknown hash type '%1%', at %2%") % type % pos);
PathSet context; // discarded
string s = state.forceString(*args[1], context, pos);
- mkString(v, hashString(ht, s).to_string(Base16, false), context);
+ mkString(v, hashString(ht, s).to_string(Base::Base16, false), context);
}
@@ -2068,7 +2068,7 @@ void fetch(EvalState & state, const Pos & pos, Value * * args, Value & v,
if (n == "url")
request.uri = state.forceStringNoCtx(*attr.value, *attr.pos);
else if (n == "sha256")
- request.expectedHash = Hash(state.forceStringNoCtx(*attr.value, *attr.pos), htSHA256);
+ request.expectedHash = Hash(state.forceStringNoCtx(*attr.value, *attr.pos), HashType::SHA256);
else if (n == "name")
request.name = state.forceStringNoCtx(*attr.value, *attr.pos);
else
diff --git a/src/libexpr/primops/fetchGit.cc b/src/libexpr/primops/fetchGit.cc
index 4aee1073e..7f70dfab0 100644
--- a/src/libexpr/primops/fetchGit.cc
+++ b/src/libexpr/primops/fetchGit.cc
@@ -69,7 +69,7 @@ GitInfo exportGit(ref<Store> store, const std::string & uri,
return files.count(file);
};
- gitInfo.storePath = store->printStorePath(store->addToStore("source", uri, true, htSHA256, filter));
+ gitInfo.storePath = store->printStorePath(store->addToStore("source", uri, true, HashType::SHA256, filter));
return gitInfo;
}
@@ -86,7 +86,7 @@ GitInfo exportGit(ref<Store> store, const std::string & uri,
deletePath(getCacheDir() + "/nix/git");
- Path cacheDir = getCacheDir() + "/nix/gitv2/" + hashString(htSHA256, uri).to_string(Base32, false);
+ Path cacheDir = getCacheDir() + "/nix/gitv2/" + hashString(HashType::SHA256, uri).to_string(Base::Base32, false);
if (!pathExists(cacheDir)) {
createDirs(dirOf(cacheDir));
@@ -123,7 +123,7 @@ GitInfo exportGit(ref<Store> store, const std::string & uri,
}
if (doFetch)
{
- Activity act(*logger, lvlTalkative, actUnknown, fmt("fetching Git repository '%s'", uri));
+ Activity act(*logger, Verbosity::Talkative, ActivityType::Unknown, fmt("fetching Git repository '%s'", uri));
// FIXME: git stderr messes up our progress indicator, so
// we're using --quiet for now. Should process its stderr.
@@ -145,7 +145,7 @@ GitInfo exportGit(ref<Store> store, const std::string & uri,
printTalkative("using revision %s of repo '%s'", gitInfo.rev, uri);
- std::string storeLinkName = hashString(htSHA512, name + std::string("\0"s) + gitInfo.rev).to_string(Base32, false);
+ std::string storeLinkName = hashString(HashType::SHA512, name + std::string("\0"s) + gitInfo.rev).to_string(Base::Base32, false);
Path storeLink = cacheDir + "/" + storeLinkName + ".link";
PathLocks storeLinkLock({storeLink}, fmt("waiting for lock on '%1%'...", storeLink)); // FIXME: broken
diff --git a/src/libexpr/primops/fetchMercurial.cc b/src/libexpr/primops/fetchMercurial.cc
index db274fa4f..65f52f682 100644
--- a/src/libexpr/primops/fetchMercurial.cc
+++ b/src/libexpr/primops/fetchMercurial.cc
@@ -63,7 +63,7 @@ HgInfo exportMercurial(ref<Store> store, const std::string & uri,
return files.count(file);
};
- hgInfo.storePath = store->printStorePath(store->addToStore("source", uri, true, htSHA256, filter));
+ hgInfo.storePath = store->printStorePath(store->addToStore("source", uri, true, HashType::SHA256, filter));
return hgInfo;
}
@@ -71,9 +71,9 @@ HgInfo exportMercurial(ref<Store> store, const std::string & uri,
if (rev == "") rev = "default";
- Path cacheDir = fmt("%s/nix/hg/%s", getCacheDir(), hashString(htSHA256, uri).to_string(Base32, false));
+ Path cacheDir = fmt("%s/nix/hg/%s", getCacheDir(), hashString(HashType::SHA256, uri).to_string(Base::Base32, false));
- Path stampFile = fmt("%s/.hg/%s.stamp", cacheDir, hashString(htSHA512, rev).to_string(Base32, false));
+ Path stampFile = fmt("%s/.hg/%s.stamp", cacheDir, hashString(HashType::SHA512, rev).to_string(Base::Base32, false));
/* If we haven't pulled this repo less than ‘tarball-ttl’ seconds,
do so now. */
@@ -90,7 +90,7 @@ HgInfo exportMercurial(ref<Store> store, const std::string & uri,
RunOptions("hg", { "log", "-R", cacheDir, "-r", rev, "--template", "1" })
.killStderr(true)).second == "1"))
{
- Activity act(*logger, lvlTalkative, actUnknown, fmt("fetching Mercurial repository '%s'", uri));
+ Activity act(*logger, Verbosity::Talkative, ActivityType::Unknown, fmt("fetching Mercurial repository '%s'", uri));
if (pathExists(cacheDir)) {
try {
@@ -124,7 +124,7 @@ HgInfo exportMercurial(ref<Store> store, const std::string & uri,
hgInfo.revCount = std::stoull(tokens[1]);
hgInfo.branch = tokens[2];
- std::string storeLinkName = hashString(htSHA512, name + std::string("\0"s) + hgInfo.rev).to_string(Base32, false);
+ std::string storeLinkName = hashString(HashType::SHA512, name + std::string("\0"s) + hgInfo.rev).to_string(Base::Base32, false);
Path storeLink = fmt("%s/.hg/%s.link", cacheDir, storeLinkName);
try {