* A command to register successor fstate expressions.
Unifying substitutes and successors isn't very feasible for now, since substitutes are only used when no path with a certain is known. Therefore, a normal form of some expression stored as a substitute would not be used unless the expression itself was missing.
This commit is contained in:
parent
8511571f65
commit
e5fbf58041
|
@ -179,6 +179,12 @@ Hash writeTerm(ATerm t, const string & suffix, string * p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void registerSuccessor(const Hash & fsHash, const Hash & scHash)
|
||||||
|
{
|
||||||
|
setDB(nixDB, dbSuccessors, fsHash, scHash);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
FState storeSuccessor(FState fs, FState sc, StringSet & paths)
|
FState storeSuccessor(FState fs, FState sc, StringSet & paths)
|
||||||
{
|
{
|
||||||
if (fs == sc) return sc;
|
if (fs == sc) return sc;
|
||||||
|
@ -186,7 +192,7 @@ FState storeSuccessor(FState fs, FState sc, StringSet & paths)
|
||||||
string path;
|
string path;
|
||||||
Hash fsHash = hashTerm(fs);
|
Hash fsHash = hashTerm(fs);
|
||||||
Hash scHash = writeTerm(sc, "-s-" + (string) fsHash, &path);
|
Hash scHash = writeTerm(sc, "-s-" + (string) fsHash, &path);
|
||||||
setDB(nixDB, dbSuccessors, fsHash, scHash);
|
registerSuccessor(fsHash, scHash);
|
||||||
paths.insert(path);
|
paths.insert(path);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
@ -93,5 +93,8 @@ ATerm termFromHash(const Hash & hash, string * p = 0);
|
||||||
/* Write an aterm to the Nix store directory, and return its hash. */
|
/* Write an aterm to the Nix store directory, and return its hash. */
|
||||||
Hash writeTerm(ATerm t, const string & suffix, string * p = 0);
|
Hash writeTerm(ATerm t, const string & suffix, string * p = 0);
|
||||||
|
|
||||||
|
/* Register a successor. */
|
||||||
|
void registerSuccessor(const Hash & fsHash, const Hash & scHash);
|
||||||
|
|
||||||
|
|
||||||
#endif /* !__EVAL_H */
|
#endif /* !__EVAL_H */
|
||||||
|
|
18
src/nix.cc
18
src/nix.cc
|
@ -26,6 +26,7 @@ static ArgType argType = atpUnknown;
|
||||||
--add / -A: copy a path to the Nix store
|
--add / -A: copy a path to the Nix store
|
||||||
--query / -q: query information
|
--query / -q: query information
|
||||||
|
|
||||||
|
--successor: register a successor expression
|
||||||
--substitute: register a substitute expression
|
--substitute: register a substitute expression
|
||||||
|
|
||||||
--dump: dump a path as a Nix archive
|
--dump: dump a path as a Nix archive
|
||||||
|
@ -183,6 +184,21 @@ static void opQuery(Strings opFlags, Strings opArgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void opSuccessor(Strings opFlags, Strings opArgs)
|
||||||
|
{
|
||||||
|
if (!opFlags.empty()) throw UsageError("unknown flag");
|
||||||
|
if (opArgs.size() % 2) throw UsageError("expecting even number of arguments");
|
||||||
|
|
||||||
|
for (Strings::iterator i = opArgs.begin();
|
||||||
|
i != opArgs.end(); )
|
||||||
|
{
|
||||||
|
Hash fsHash = parseHash(*i++);
|
||||||
|
Hash scHash = parseHash(*i++);
|
||||||
|
registerSuccessor(fsHash, scHash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void opSubstitute(Strings opFlags, Strings opArgs)
|
static void opSubstitute(Strings opFlags, Strings opArgs)
|
||||||
{
|
{
|
||||||
if (!opFlags.empty()) throw UsageError("unknown flag");
|
if (!opFlags.empty()) throw UsageError("unknown flag");
|
||||||
|
@ -288,6 +304,8 @@ void run(Strings args)
|
||||||
op = opAdd;
|
op = opAdd;
|
||||||
else if (arg == "--query" || arg == "-q")
|
else if (arg == "--query" || arg == "-q")
|
||||||
op = opQuery;
|
op = opQuery;
|
||||||
|
else if (arg == "--successor")
|
||||||
|
op = opSuccessor;
|
||||||
else if (arg == "--substitute")
|
else if (arg == "--substitute")
|
||||||
op = opSubstitute;
|
op = opSubstitute;
|
||||||
else if (arg == "--dump")
|
else if (arg == "--dump")
|
||||||
|
|
Loading…
Reference in a new issue