unsupported(): Show the name of the unsupported operation

This commit is contained in:
Eelco Dolstra 2019-01-18 13:34:23 +01:00
parent df03430586
commit 7cc1a2593e
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
4 changed files with 31 additions and 76 deletions

View file

@ -72,24 +72,11 @@ public:
bool isValidPathUncached(const Path & path) override;
PathSet queryAllValidPaths() override
{ unsupported(); }
void queryPathInfoUncached(const Path & path,
Callback<std::shared_ptr<ValidPathInfo>> callback) override;
void queryReferrers(const Path & path,
PathSet & referrers) override
{ unsupported(); }
PathSet queryDerivationOutputs(const Path & path) override
{ unsupported(); }
StringSet queryDerivationOutputNames(const Path & path) override
{ unsupported(); }
Path queryPathFromHashPart(const string & hashPart) override
{ unsupported(); }
{ unsupported("queryPathFromHashPart"); }
bool wantMassQuery() override { return wantMassQuery_; }
@ -108,22 +95,10 @@ public:
BuildResult buildDerivation(const Path & drvPath, const BasicDerivation & drv,
BuildMode buildMode) override
{ unsupported(); }
{ unsupported("buildDerivation"); }
void ensurePath(const Path & path) override
{ unsupported(); }
void addTempRoot(const Path & path) override
{ unsupported(); }
void addIndirectRoot(const Path & path) override
{ unsupported(); }
Roots findRoots() override
{ unsupported(); }
void collectGarbage(const GCOptions & options, GCResults & results) override
{ unsupported(); }
{ unsupported("ensurePath"); }
ref<FSAccessor> getFSAccessor() override;

View file

@ -187,28 +187,17 @@ struct LegacySSHStore : public Store
copyNAR(conn->from, sink);
}
PathSet queryAllValidPaths() override { unsupported(); }
void queryReferrers(const Path & path, PathSet & referrers) override
{ unsupported(); }
PathSet queryDerivationOutputs(const Path & path) override
{ unsupported(); }
StringSet queryDerivationOutputNames(const Path & path) override
{ unsupported(); }
Path queryPathFromHashPart(const string & hashPart) override
{ unsupported(); }
{ unsupported("queryPathFromHashPart"); }
Path addToStore(const string & name, const Path & srcPath,
bool recursive, HashType hashAlgo,
PathFilter & filter, RepairFlag repair) override
{ unsupported(); }
{ unsupported("addToStore"); }
Path addTextToStore(const string & name, const string & s,
const PathSet & references, RepairFlag repair) override
{ unsupported(); }
{ unsupported("addTextToStore"); }
BuildResult buildDerivation(const Path & drvPath, const BasicDerivation & drv,
BuildMode buildMode) override
@ -242,25 +231,7 @@ struct LegacySSHStore : public Store
}
void ensurePath(const Path & path) override
{ unsupported(); }
void addTempRoot(const Path & path) override
{ unsupported(); }
void addIndirectRoot(const Path & path) override
{ unsupported(); }
Roots findRoots() override
{ unsupported(); }
void collectGarbage(const GCOptions & options, GCResults & results) override
{ unsupported(); }
ref<FSAccessor> getFSAccessor() override
{ unsupported(); }
void addSignatures(const Path & storePath, const StringSet & sigs) override
{ unsupported(); }
{ unsupported("ensurePath"); }
void computeFSClosure(const PathSet & paths,
PathSet & out, bool flipDirection = false,

View file

@ -562,10 +562,10 @@ void Store::buildPaths(const PathSet & paths, BuildMode buildMode)
{
for (auto & path : paths)
if (isDerivation(path))
unsupported();
unsupported("buildPaths");
if (queryValidPaths(paths).size() != paths.size())
unsupported();
unsupported("buildPaths");
}

View file

@ -349,7 +349,8 @@ public:
(i.e. you'll get /nix/store/<hash> rather than
/nix/store/<hash>-<name>). Use queryPathInfo() to obtain the
full store path. */
virtual PathSet queryAllValidPaths() = 0;
virtual PathSet queryAllValidPaths()
{ unsupported("queryAllValidPaths"); }
/* Query information about a valid path. It is permitted to omit
the name part of the store path. */
@ -368,8 +369,8 @@ public:
/* Queries the set of incoming FS references for a store path.
The result is not cleared. */
virtual void queryReferrers(const Path & path,
PathSet & referrers) = 0;
virtual void queryReferrers(const Path & path, PathSet & referrers)
{ unsupported("queryReferrers"); }
/* Return all currently valid derivations that have `path' as an
output. (Note that the result of `queryDeriver()' is the
@ -378,10 +379,12 @@ public:
virtual PathSet queryValidDerivers(const Path & path) { return {}; };
/* Query the outputs of the derivation denoted by `path'. */
virtual PathSet queryDerivationOutputs(const Path & path) = 0;
virtual PathSet queryDerivationOutputs(const Path & path)
{ unsupported("queryDerivationOutputs"); }
/* Query the output names of the derivation denoted by `path'. */
virtual StringSet queryDerivationOutputNames(const Path & path) = 0;
virtual StringSet queryDerivationOutputNames(const Path & path)
{ unsupported("queryDerivationOutputNames"); }
/* Query the full store path given the hash part of a valid store
path, or "" if the path doesn't exist. */
@ -447,14 +450,16 @@ public:
/* Add a store path as a temporary root of the garbage collector.
The root disappears as soon as we exit. */
virtual void addTempRoot(const Path & path) = 0;
virtual void addTempRoot(const Path & path)
{ unsupported("addTempRoot"); }
/* Add an indirect root, which is merely a symlink to `path' from
/nix/var/nix/gcroots/auto/<hash of `path'>. `path' is supposed
to be a symlink to a store path. The garbage collector will
automatically remove the indirect root when it finds that
`path' has disappeared. */
virtual void addIndirectRoot(const Path & path) = 0;
virtual void addIndirectRoot(const Path & path)
{ unsupported("addIndirectRoot"); }
/* Acquire the global GC lock, then immediately release it. This
function must be called after registering a new permanent root,
@ -479,10 +484,12 @@ public:
/* Find the roots of the garbage collector. Each root is a pair
(link, storepath) where `link' is the path of the symlink
outside of the Nix store that point to `storePath'. */
virtual Roots findRoots() = 0;
virtual Roots findRoots()
{ unsupported("findRoots"); }
/* Perform a garbage collection. */
virtual void collectGarbage(const GCOptions & options, GCResults & results) = 0;
virtual void collectGarbage(const GCOptions & options, GCResults & results)
{ unsupported("collectGarbage"); }
/* Return a string representing information about the path that
can be loaded into the database using `nix-store --load-db' or
@ -513,11 +520,13 @@ public:
virtual bool verifyStore(bool checkContents, RepairFlag repair = NoRepair) { return false; };
/* Return an object to access files in the Nix store. */
virtual ref<FSAccessor> getFSAccessor() = 0;
virtual ref<FSAccessor> getFSAccessor()
{ unsupported("getFSAccessor"); }
/* Add signatures to the specified store path. The signatures are
not verified. */
virtual void addSignatures(const Path & storePath, const StringSet & sigs) = 0;
virtual void addSignatures(const Path & storePath, const StringSet & sigs)
{ unsupported("addSignatures"); }
/* Utility functions. */
@ -620,9 +629,9 @@ protected:
Stats stats;
/* Unsupported methods. */
[[noreturn]] void unsupported()
[[noreturn]] void unsupported(const std::string & op)
{
throw Unsupported("requested operation is not supported by store '%s'", getUri());
throw Unsupported("operation '%s' is not supported by store '%s'", op, getUri());
}
};