mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-24 06:56:14 +02:00
Remove Input::locked
This commit is contained in:
parent
4f8b253ea7
commit
90e9f50a66
7 changed files with 37 additions and 17 deletions
|
@ -24,12 +24,8 @@ static void fixupInput(Input & input)
|
||||||
// Check common attributes.
|
// Check common attributes.
|
||||||
input.getType();
|
input.getType();
|
||||||
input.getRef();
|
input.getRef();
|
||||||
if (input.getRev())
|
|
||||||
input.locked = true;
|
|
||||||
input.getRevCount();
|
input.getRevCount();
|
||||||
input.getLastModified();
|
input.getLastModified();
|
||||||
if (input.getNarHash())
|
|
||||||
input.locked = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Input Input::fromURL(const ParsedURL & url)
|
Input Input::fromURL(const ParsedURL & url)
|
||||||
|
@ -94,6 +90,11 @@ bool Input::isDirect() const
|
||||||
return !scheme || scheme->isDirect(*this);
|
return !scheme || scheme->isDirect(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Input::isLocked() const
|
||||||
|
{
|
||||||
|
return scheme && scheme->isLocked(*this);
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<CanonPath> Input::isRelative() const
|
std::optional<CanonPath> Input::isRelative() const
|
||||||
{
|
{
|
||||||
assert(scheme);
|
assert(scheme);
|
||||||
|
@ -172,8 +173,6 @@ void Input::checkLocks(Input & input) const
|
||||||
|
|
||||||
// FIXME
|
// FIXME
|
||||||
#if 0
|
#if 0
|
||||||
input.locked = true;
|
|
||||||
|
|
||||||
assert(input.hasAllInfo());
|
assert(input.hasAllInfo());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ struct Input
|
||||||
|
|
||||||
std::shared_ptr<InputScheme> scheme; // note: can be null
|
std::shared_ptr<InputScheme> scheme; // note: can be null
|
||||||
Attrs attrs;
|
Attrs attrs;
|
||||||
bool locked = false;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Input fromURL(const std::string & url);
|
static Input fromURL(const std::string & url);
|
||||||
|
@ -50,7 +49,7 @@ public:
|
||||||
|
|
||||||
/* Check whether this is a "locked" input, that is,
|
/* Check whether this is a "locked" input, that is,
|
||||||
one that contains a commit hash or content hash. */
|
one that contains a commit hash or content hash. */
|
||||||
bool isLocked() const { return locked; }
|
bool isLocked() const;
|
||||||
|
|
||||||
/* Only for relative path flakes, i.e. 'path:./foo', returns the
|
/* Only for relative path flakes, i.e. 'path:./foo', returns the
|
||||||
relative path, i.e. './foo'. */
|
relative path, i.e. './foo'. */
|
||||||
|
@ -140,6 +139,9 @@ struct InputScheme
|
||||||
virtual bool isDirect(const Input & input) const
|
virtual bool isDirect(const Input & input) const
|
||||||
{ return true; }
|
{ return true; }
|
||||||
|
|
||||||
|
virtual bool isLocked(const Input & input) const
|
||||||
|
{ return false; }
|
||||||
|
|
||||||
virtual std::optional<CanonPath> isRelative(const Input & input) const
|
virtual std::optional<CanonPath> isRelative(const Input & input) const
|
||||||
{ return std::nullopt; }
|
{ return std::nullopt; }
|
||||||
|
|
||||||
|
|
|
@ -482,7 +482,6 @@ struct GitInputScheme : InputScheme
|
||||||
//input.attrs.erase("narHash");
|
//input.attrs.erase("narHash");
|
||||||
auto narHash = store->queryPathInfo(storePath)->narHash;
|
auto narHash = store->queryPathInfo(storePath)->narHash;
|
||||||
input.attrs.insert_or_assign("narHash", narHash.to_string(SRI, true));
|
input.attrs.insert_or_assign("narHash", narHash.to_string(SRI, true));
|
||||||
input.locked = true;
|
|
||||||
|
|
||||||
return storePath;
|
return storePath;
|
||||||
};
|
};
|
||||||
|
@ -732,8 +731,6 @@ struct GitInputScheme : InputScheme
|
||||||
input.attrs.insert_or_assign(
|
input.attrs.insert_or_assign(
|
||||||
"revCount",
|
"revCount",
|
||||||
getRevCount(repoInfo, repoInfo.url, *input.getRev()));
|
getRevCount(repoInfo, repoInfo.url, *input.getRev()));
|
||||||
|
|
||||||
input.locked = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: maybe we should use the timestamp of the last
|
// FIXME: maybe we should use the timestamp of the last
|
||||||
|
@ -744,6 +741,11 @@ struct GitInputScheme : InputScheme
|
||||||
|
|
||||||
return {makeFSInputAccessor(CanonPath(repoInfo.url), listFiles(repoInfo), std::move(makeNotAllowedError)), input};
|
return {makeFSInputAccessor(CanonPath(repoInfo.url), listFiles(repoInfo), std::move(makeNotAllowedError)), input};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isLocked(const Input & input) const override
|
||||||
|
{
|
||||||
|
return (bool) input.getRev();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static auto rGitInputScheme = OnStartup([] { registerInputScheme(std::make_unique<GitInputScheme>()); });
|
static auto rGitInputScheme = OnStartup([] { registerInputScheme(std::make_unique<GitInputScheme>()); });
|
||||||
|
|
|
@ -194,8 +194,6 @@ struct GitArchiveInputScheme : InputScheme
|
||||||
auto rev = input.getRev();
|
auto rev = input.getRev();
|
||||||
if (!rev) rev = getRevFromRef(store, input);
|
if (!rev) rev = getRevFromRef(store, input);
|
||||||
|
|
||||||
input.locked = true;
|
|
||||||
|
|
||||||
input.attrs.erase("ref");
|
input.attrs.erase("ref");
|
||||||
input.attrs.insert_or_assign("rev", rev->gitRev());
|
input.attrs.insert_or_assign("rev", rev->gitRev());
|
||||||
|
|
||||||
|
@ -240,6 +238,11 @@ struct GitArchiveInputScheme : InputScheme
|
||||||
|
|
||||||
return {accessor, input2};
|
return {accessor, input2};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isLocked(const Input & input) const override
|
||||||
|
{
|
||||||
|
return (bool) input.getRev();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GitHubInputScheme : GitArchiveInputScheme
|
struct GitHubInputScheme : GitArchiveInputScheme
|
||||||
|
|
|
@ -229,7 +229,6 @@ struct MercurialInputScheme : InputScheme
|
||||||
assert(input.getRev());
|
assert(input.getRev());
|
||||||
assert(!origRev || origRev == input.getRev());
|
assert(!origRev || origRev == input.getRev());
|
||||||
input.attrs.insert_or_assign("revCount", getIntAttr(infoAttrs, "revCount"));
|
input.attrs.insert_or_assign("revCount", getIntAttr(infoAttrs, "revCount"));
|
||||||
input.locked = true;
|
|
||||||
return storePath;
|
return storePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -336,6 +335,11 @@ struct MercurialInputScheme : InputScheme
|
||||||
|
|
||||||
return {makeStorePathAccessor(store, storePath), input};
|
return {makeStorePathAccessor(store, storePath), input};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isLocked(const Input & input) const override
|
||||||
|
{
|
||||||
|
return (bool) input.getRev();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static auto rMercurialInputScheme = OnStartup([] { registerInputScheme(std::make_unique<MercurialInputScheme>()); });
|
static auto rMercurialInputScheme = OnStartup([] { registerInputScheme(std::make_unique<MercurialInputScheme>()); });
|
||||||
|
|
|
@ -43,7 +43,10 @@ struct PathInputScheme : InputScheme
|
||||||
/* Allow the user to pass in "fake" tree info
|
/* Allow the user to pass in "fake" tree info
|
||||||
attributes. This is useful for making a pinned tree
|
attributes. This is useful for making a pinned tree
|
||||||
work the same as the repository from which is exported
|
work the same as the repository from which is exported
|
||||||
(e.g. path:/nix/store/...-source?lastModified=1585388205&rev=b0c285...). */
|
(e.g. path:/nix/store/...-source?lastModified=1585388205&rev=b0c285...).
|
||||||
|
FIXME: remove this hack once we have a prepopulated
|
||||||
|
flake input cache mechanism.
|
||||||
|
*/
|
||||||
if (name == "type" || name == "rev" || name == "revCount" || name == "lastModified" || name == "narHash" || name == "path")
|
if (name == "type" || name == "rev" || name == "revCount" || name == "lastModified" || name == "narHash" || name == "path")
|
||||||
// checked in Input::fromAttrs
|
// checked in Input::fromAttrs
|
||||||
;
|
;
|
||||||
|
@ -76,6 +79,11 @@ struct PathInputScheme : InputScheme
|
||||||
return CanonPath(path);
|
return CanonPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isLocked(const Input & input) const override
|
||||||
|
{
|
||||||
|
return (bool) input.getNarHash();
|
||||||
|
}
|
||||||
|
|
||||||
bool hasAllInfo(const Input & input) const override
|
bool hasAllInfo(const Input & input) const override
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -237,6 +237,10 @@ struct CurlInputScheme : InputScheme
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isLocked(const Input & input) const override
|
||||||
|
{
|
||||||
|
return (bool) input.getNarHash();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FileInputScheme : CurlInputScheme
|
struct FileInputScheme : CurlInputScheme
|
||||||
|
@ -261,7 +265,6 @@ struct FileInputScheme : CurlInputScheme
|
||||||
// FIXME: remove?
|
// FIXME: remove?
|
||||||
auto narHash = store->queryPathInfo(file.storePath)->narHash;
|
auto narHash = store->queryPathInfo(file.storePath)->narHash;
|
||||||
input.attrs.insert_or_assign("narHash", narHash.to_string(SRI, true));
|
input.attrs.insert_or_assign("narHash", narHash.to_string(SRI, true));
|
||||||
input.locked = true;
|
|
||||||
|
|
||||||
return {makeStorePathAccessor(store, file.storePath), input};
|
return {makeStorePathAccessor(store, file.storePath), input};
|
||||||
}
|
}
|
||||||
|
@ -290,7 +293,6 @@ struct TarballInputScheme : CurlInputScheme
|
||||||
// FIXME: remove?
|
// FIXME: remove?
|
||||||
auto narHash = store->queryPathInfo(storePath)->narHash;
|
auto narHash = store->queryPathInfo(storePath)->narHash;
|
||||||
input.attrs.insert_or_assign("narHash", narHash.to_string(SRI, true));
|
input.attrs.insert_or_assign("narHash", narHash.to_string(SRI, true));
|
||||||
input.locked = true;
|
|
||||||
|
|
||||||
return {makeStorePathAccessor(store, storePath), input};
|
return {makeStorePathAccessor(store, storePath), input};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue