forked from lix-project/lix
Remove redundant resolvedRef fields since they're already in SourceInfo
This commit is contained in:
parent
4846304541
commit
dda4f7167b
|
@ -397,13 +397,17 @@ LockFile entryToLockFile(const LockFile::FlakeEntry & entry)
|
||||||
|
|
||||||
LockFile::FlakeEntry dependenciesToFlakeEntry(const ResolvedFlake & resolvedFlake)
|
LockFile::FlakeEntry dependenciesToFlakeEntry(const ResolvedFlake & resolvedFlake)
|
||||||
{
|
{
|
||||||
LockFile::FlakeEntry entry(resolvedFlake.flake.resolvedRef, resolvedFlake.flake.sourceInfo.narHash);
|
LockFile::FlakeEntry entry(
|
||||||
|
resolvedFlake.flake.sourceInfo.resolvedRef,
|
||||||
|
resolvedFlake.flake.sourceInfo.narHash);
|
||||||
|
|
||||||
for (auto & info : resolvedFlake.flakeDeps)
|
for (auto & info : resolvedFlake.flakeDeps)
|
||||||
entry.flakeEntries.insert_or_assign(info.first.to_string(), dependenciesToFlakeEntry(info.second));
|
entry.flakeEntries.insert_or_assign(info.first.to_string(), dependenciesToFlakeEntry(info.second));
|
||||||
|
|
||||||
for (auto & nonFlake : resolvedFlake.nonFlakeDeps) {
|
for (auto & nonFlake : resolvedFlake.nonFlakeDeps) {
|
||||||
LockFile::NonFlakeEntry nonEntry(nonFlake.resolvedRef, nonFlake.sourceInfo.narHash);
|
LockFile::NonFlakeEntry nonEntry(
|
||||||
|
nonFlake.sourceInfo.resolvedRef,
|
||||||
|
nonFlake.sourceInfo.narHash);
|
||||||
entry.nonFlakeEntries.insert_or_assign(nonFlake.alias, nonEntry);
|
entry.nonFlakeEntries.insert_or_assign(nonFlake.alias, nonEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,11 +544,11 @@ void callFlake(EvalState & state, const ResolvedFlake & resFlake, Value & v)
|
||||||
state.store->isValidPath(path);
|
state.store->isValidPath(path);
|
||||||
mkString(*state.allocAttr(v, state.sOutPath), path, {path});
|
mkString(*state.allocAttr(v, state.sOutPath), path, {path});
|
||||||
|
|
||||||
if (resFlake.flake.resolvedRef.rev) {
|
if (resFlake.flake.sourceInfo.resolvedRef.rev) {
|
||||||
mkString(*state.allocAttr(v, state.symbols.create("rev")),
|
mkString(*state.allocAttr(v, state.symbols.create("rev")),
|
||||||
resFlake.flake.resolvedRef.rev->gitRev());
|
resFlake.flake.sourceInfo.resolvedRef.rev->gitRev());
|
||||||
mkString(*state.allocAttr(v, state.symbols.create("shortRev")),
|
mkString(*state.allocAttr(v, state.symbols.create("shortRev")),
|
||||||
resFlake.flake.resolvedRef.rev->gitShortRev());
|
resFlake.flake.sourceInfo.resolvedRef.rev->gitShortRev());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resFlake.flake.sourceInfo.revCount)
|
if (resFlake.flake.sourceInfo.revCount)
|
||||||
|
|
|
@ -92,7 +92,6 @@ struct Flake
|
||||||
{
|
{
|
||||||
FlakeId id;
|
FlakeId id;
|
||||||
FlakeRef originalRef;
|
FlakeRef originalRef;
|
||||||
FlakeRef resolvedRef;
|
|
||||||
std::string description;
|
std::string description;
|
||||||
SourceInfo sourceInfo;
|
SourceInfo sourceInfo;
|
||||||
std::vector<FlakeRef> requires;
|
std::vector<FlakeRef> requires;
|
||||||
|
@ -100,18 +99,17 @@ struct Flake
|
||||||
Value * vProvides; // FIXME: gc
|
Value * vProvides; // FIXME: gc
|
||||||
unsigned int epoch;
|
unsigned int epoch;
|
||||||
|
|
||||||
Flake(const FlakeRef & origRef, const SourceInfo & sourceInfo) : originalRef(origRef),
|
Flake(const FlakeRef & origRef, const SourceInfo & sourceInfo)
|
||||||
resolvedRef(sourceInfo.resolvedRef), sourceInfo(sourceInfo) {};
|
: originalRef(origRef), sourceInfo(sourceInfo) {};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NonFlake
|
struct NonFlake
|
||||||
{
|
{
|
||||||
FlakeAlias alias;
|
FlakeAlias alias;
|
||||||
FlakeRef originalRef;
|
FlakeRef originalRef;
|
||||||
FlakeRef resolvedRef;
|
|
||||||
SourceInfo sourceInfo;
|
SourceInfo sourceInfo;
|
||||||
NonFlake(const FlakeRef & origRef, const SourceInfo & sourceInfo) :
|
NonFlake(const FlakeRef & origRef, const SourceInfo & sourceInfo)
|
||||||
originalRef(origRef), resolvedRef(sourceInfo.resolvedRef), sourceInfo(sourceInfo) {};
|
: originalRef(origRef), sourceInfo(sourceInfo) {};
|
||||||
};
|
};
|
||||||
|
|
||||||
Flake getFlake(EvalState &, const FlakeRef &, bool impureIsAllowed);
|
Flake getFlake(EvalState &, const FlakeRef &, bool impureIsAllowed);
|
||||||
|
|
|
@ -74,12 +74,12 @@ void printFlakeInfo(const Flake & flake, bool json) {
|
||||||
if (json) {
|
if (json) {
|
||||||
nlohmann::json j;
|
nlohmann::json j;
|
||||||
j["id"] = flake.id;
|
j["id"] = flake.id;
|
||||||
j["uri"] = flake.resolvedRef.to_string();
|
j["uri"] = flake.sourceInfo.resolvedRef.to_string();
|
||||||
j["description"] = flake.description;
|
j["description"] = flake.description;
|
||||||
if (flake.resolvedRef.ref)
|
if (flake.sourceInfo.resolvedRef.ref)
|
||||||
j["branch"] = *flake.resolvedRef.ref;
|
j["branch"] = *flake.sourceInfo.resolvedRef.ref;
|
||||||
if (flake.resolvedRef.rev)
|
if (flake.sourceInfo.resolvedRef.rev)
|
||||||
j["revision"] = flake.resolvedRef.rev->to_string(Base16, false);
|
j["revision"] = flake.sourceInfo.resolvedRef.rev->to_string(Base16, false);
|
||||||
if (flake.sourceInfo.revCount)
|
if (flake.sourceInfo.revCount)
|
||||||
j["revCount"] = *flake.sourceInfo.revCount;
|
j["revCount"] = *flake.sourceInfo.revCount;
|
||||||
j["path"] = flake.sourceInfo.storePath;
|
j["path"] = flake.sourceInfo.storePath;
|
||||||
|
@ -87,12 +87,12 @@ void printFlakeInfo(const Flake & flake, bool json) {
|
||||||
std::cout << j.dump(4) << std::endl;
|
std::cout << j.dump(4) << std::endl;
|
||||||
} else {
|
} else {
|
||||||
std::cout << "ID: " << flake.id << "\n";
|
std::cout << "ID: " << flake.id << "\n";
|
||||||
std::cout << "URI: " << flake.resolvedRef.to_string() << "\n";
|
std::cout << "URI: " << flake.sourceInfo.resolvedRef.to_string() << "\n";
|
||||||
std::cout << "Description: " << flake.description << "\n";
|
std::cout << "Description: " << flake.description << "\n";
|
||||||
if (flake.resolvedRef.ref)
|
if (flake.sourceInfo.resolvedRef.ref)
|
||||||
std::cout << "Branch: " << *flake.resolvedRef.ref << "\n";
|
std::cout << "Branch: " << *flake.sourceInfo.resolvedRef.ref << "\n";
|
||||||
if (flake.resolvedRef.rev)
|
if (flake.sourceInfo.resolvedRef.rev)
|
||||||
std::cout << "Revision: " << flake.resolvedRef.rev->to_string(Base16, false) << "\n";
|
std::cout << "Revision: " << flake.sourceInfo.resolvedRef.rev->to_string(Base16, false) << "\n";
|
||||||
if (flake.sourceInfo.revCount)
|
if (flake.sourceInfo.revCount)
|
||||||
std::cout << "Revcount: " << *flake.sourceInfo.revCount << "\n";
|
std::cout << "Revcount: " << *flake.sourceInfo.revCount << "\n";
|
||||||
std::cout << "Path: " << flake.sourceInfo.storePath << "\n";
|
std::cout << "Path: " << flake.sourceInfo.storePath << "\n";
|
||||||
|
@ -104,22 +104,22 @@ void printNonFlakeInfo(const NonFlake & nonFlake, bool json) {
|
||||||
if (json) {
|
if (json) {
|
||||||
nlohmann::json j;
|
nlohmann::json j;
|
||||||
j["id"] = nonFlake.alias;
|
j["id"] = nonFlake.alias;
|
||||||
j["uri"] = nonFlake.resolvedRef.to_string();
|
j["uri"] = nonFlake.sourceInfo.resolvedRef.to_string();
|
||||||
if (nonFlake.resolvedRef.ref)
|
if (nonFlake.sourceInfo.resolvedRef.ref)
|
||||||
j["branch"] = *nonFlake.resolvedRef.ref;
|
j["branch"] = *nonFlake.sourceInfo.resolvedRef.ref;
|
||||||
if (nonFlake.resolvedRef.rev)
|
if (nonFlake.sourceInfo.resolvedRef.rev)
|
||||||
j["revision"] = nonFlake.resolvedRef.rev->to_string(Base16, false);
|
j["revision"] = nonFlake.sourceInfo.resolvedRef.rev->to_string(Base16, false);
|
||||||
if (nonFlake.sourceInfo.revCount)
|
if (nonFlake.sourceInfo.revCount)
|
||||||
j["revCount"] = *nonFlake.sourceInfo.revCount;
|
j["revCount"] = *nonFlake.sourceInfo.revCount;
|
||||||
j["path"] = nonFlake.sourceInfo.storePath;
|
j["path"] = nonFlake.sourceInfo.storePath;
|
||||||
std::cout << j.dump(4) << std::endl;
|
std::cout << j.dump(4) << std::endl;
|
||||||
} else {
|
} else {
|
||||||
std::cout << "ID: " << nonFlake.alias << "\n";
|
std::cout << "ID: " << nonFlake.alias << "\n";
|
||||||
std::cout << "URI: " << nonFlake.resolvedRef.to_string() << "\n";
|
std::cout << "URI: " << nonFlake.sourceInfo.resolvedRef.to_string() << "\n";
|
||||||
if (nonFlake.resolvedRef.ref)
|
if (nonFlake.sourceInfo.resolvedRef.ref)
|
||||||
std::cout << "Branch: " << *nonFlake.resolvedRef.ref;
|
std::cout << "Branch: " << *nonFlake.sourceInfo.resolvedRef.ref;
|
||||||
if (nonFlake.resolvedRef.rev)
|
if (nonFlake.sourceInfo.resolvedRef.rev)
|
||||||
std::cout << "Revision: " << nonFlake.resolvedRef.rev->to_string(Base16, false) << "\n";
|
std::cout << "Revision: " << nonFlake.sourceInfo.resolvedRef.rev->to_string(Base16, false) << "\n";
|
||||||
if (nonFlake.sourceInfo.revCount)
|
if (nonFlake.sourceInfo.revCount)
|
||||||
std::cout << "Revcount: " << *nonFlake.sourceInfo.revCount << "\n";
|
std::cout << "Revcount: " << *nonFlake.sourceInfo.revCount << "\n";
|
||||||
std::cout << "Path: " << nonFlake.sourceInfo.storePath << "\n";
|
std::cout << "Path: " << nonFlake.sourceInfo.storePath << "\n";
|
||||||
|
@ -295,13 +295,13 @@ struct CmdFlakePin : virtual Args, EvalCommand
|
||||||
FlakeRegistry userRegistry = *readRegistry(userRegistryPath);
|
FlakeRegistry userRegistry = *readRegistry(userRegistryPath);
|
||||||
auto it = userRegistry.entries.find(FlakeRef(alias));
|
auto it = userRegistry.entries.find(FlakeRef(alias));
|
||||||
if (it != userRegistry.entries.end()) {
|
if (it != userRegistry.entries.end()) {
|
||||||
it->second = getFlake(*evalState, it->second, true).resolvedRef;
|
it->second = getFlake(*evalState, it->second, true).sourceInfo.resolvedRef;
|
||||||
writeRegistry(userRegistry, userRegistryPath);
|
writeRegistry(userRegistry, userRegistryPath);
|
||||||
} else {
|
} else {
|
||||||
std::shared_ptr<FlakeRegistry> globalReg = evalState->getGlobalFlakeRegistry();
|
std::shared_ptr<FlakeRegistry> globalReg = evalState->getGlobalFlakeRegistry();
|
||||||
it = globalReg->entries.find(FlakeRef(alias));
|
it = globalReg->entries.find(FlakeRef(alias));
|
||||||
if (it != globalReg->entries.end()) {
|
if (it != globalReg->entries.end()) {
|
||||||
FlakeRef newRef = getFlake(*evalState, it->second, true).resolvedRef;
|
auto newRef = getFlake(*evalState, it->second, true).sourceInfo.resolvedRef;
|
||||||
userRegistry.entries.insert_or_assign(alias, newRef);
|
userRegistry.entries.insert_or_assign(alias, newRef);
|
||||||
writeRegistry(userRegistry, userRegistryPath);
|
writeRegistry(userRegistry, userRegistryPath);
|
||||||
} else
|
} else
|
||||||
|
|
|
@ -176,7 +176,7 @@ void makeFlakeClosureGCRoot(Store & store, const FlakeRef & origFlakeRef, const
|
||||||
while (!queue.empty()) {
|
while (!queue.empty()) {
|
||||||
const ResolvedFlake & flake = queue.front();
|
const ResolvedFlake & flake = queue.front();
|
||||||
queue.pop();
|
queue.pop();
|
||||||
if (!std::get_if<FlakeRef::IsPath>(&flake.flake.resolvedRef.data))
|
if (!std::get_if<FlakeRef::IsPath>(&flake.flake.sourceInfo.resolvedRef.data))
|
||||||
closure.insert(flake.flake.sourceInfo.storePath);
|
closure.insert(flake.flake.sourceInfo.storePath);
|
||||||
for (const auto & dep : flake.flakeDeps)
|
for (const auto & dep : flake.flakeDeps)
|
||||||
queue.push(dep.second);
|
queue.push(dep.second);
|
||||||
|
|
Loading…
Reference in a new issue