mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 04:00:59 +01:00
Added state marshall functions in RemoteStore.cc (still unfinished in Nix-worker.cc)
This commit is contained in:
parent
bdcce95a39
commit
2e7539bd27
18 changed files with 423 additions and 224 deletions
|
|
@ -1308,7 +1308,7 @@ bool DerivationGoal::prepareBuild()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The state output is a referenceable path */
|
/* The state output is a referenceable path */
|
||||||
if(store->isStateDrv(drv))
|
if(isStateDrv(drv))
|
||||||
allStatePaths.insert(drv.stateOutputs.find("state")->second.statepath);
|
allStatePaths.insert(drv.stateOutputs.find("state")->second.statepath);
|
||||||
|
|
||||||
/* Determine the full set of input paths. */
|
/* Determine the full set of input paths. */
|
||||||
|
|
@ -1754,7 +1754,7 @@ void DerivationGoal::computeClosure()
|
||||||
* If state is enabled for the path we:
|
* If state is enabled for the path we:
|
||||||
* [scan for and state references and component references in the state path] //3,4
|
* [scan for and state references and component references in the state path] //3,4
|
||||||
*/
|
*/
|
||||||
if(isStateDrvTxn(noTxn, drv)){ //TODO
|
if(isStateDrv(drv)){ //TODO
|
||||||
|
|
||||||
Path sharedState = drv.stateOutputs.find("state")->second.sharedState;
|
Path sharedState = drv.stateOutputs.find("state")->second.sharedState;
|
||||||
if(sharedState != ""){
|
if(sharedState != ""){
|
||||||
|
|
@ -1799,7 +1799,7 @@ void DerivationGoal::computeClosure()
|
||||||
}
|
}
|
||||||
|
|
||||||
//Register the state path valid
|
//Register the state path valid
|
||||||
if(isStateDrvTxn(txn, drv))
|
if(isStateDrv(drv))
|
||||||
{
|
{
|
||||||
Path statePath = drv.stateOutputs.find("state")->second.statepath;
|
Path statePath = drv.stateOutputs.find("state")->second.statepath;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ static TableId dbStateRevisions = 0;
|
||||||
*/
|
*/
|
||||||
static TableId dbStateRevisionsComments = 0;
|
static TableId dbStateRevisionsComments = 0;
|
||||||
|
|
||||||
/* dbStateSnapshots :: StatePath -> RevisionNumbers
|
/* dbStateSnapshots :: StatePath -> IntVector
|
||||||
*
|
*
|
||||||
* This table stores the snapshot numbers the sub state files/folders
|
* This table stores the snapshot numbers the sub state files/folders
|
||||||
* at a certain timestamp. These snapshot numbers are just timestamps
|
* at a certain timestamp. These snapshot numbers are just timestamps
|
||||||
|
|
@ -541,20 +541,6 @@ void LocalStore::queryStateReferences(const Path & componentOrstatePath, PathSet
|
||||||
nix::queryXReferencesTxn(noTxn, componentOrstatePath, stateReferences, revision, false);
|
nix::queryXReferencesTxn(noTxn, componentOrstatePath, stateReferences, revision, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void queryAllReferencesTxn(const Transaction & txn, const Path & path, PathSet & allReferences, const int revision)
|
|
||||||
{
|
|
||||||
PathSet references;
|
|
||||||
PathSet stateReferences;
|
|
||||||
queryXReferencesTxn(txn, path, references, true, revision);
|
|
||||||
queryXReferencesTxn(txn, path, stateReferences, false, revision);
|
|
||||||
allReferences = pathSets_union(references, stateReferences);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LocalStore::queryAllReferences(const Path & path, PathSet & allReferences, const int revision)
|
|
||||||
{
|
|
||||||
queryAllReferencesTxn(noTxn, path, allReferences, revision);
|
|
||||||
}
|
|
||||||
|
|
||||||
static PathSet getXReferrers(const Transaction & txn, const Path & store_or_statePath, const bool component_or_state, const int revision)
|
static PathSet getXReferrers(const Transaction & txn, const Path & store_or_statePath, const bool component_or_state, const int revision)
|
||||||
{
|
{
|
||||||
TableId table = 0;
|
TableId table = 0;
|
||||||
|
|
@ -788,25 +774,12 @@ bool LocalStore::isStateComponent(const Path & storePath)
|
||||||
bool isStateDrvPathTxn(const Transaction & txn, const Path & drvPath)
|
bool isStateDrvPathTxn(const Transaction & txn, const Path & drvPath)
|
||||||
{
|
{
|
||||||
Derivation drv = derivationFromPathTxn(txn, drvPath);
|
Derivation drv = derivationFromPathTxn(txn, drvPath);
|
||||||
return isStateDrvTxn(txn, drv);
|
return isStateDrv(drv);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LocalStore::isStateDrvPath(const Path & isStateDrv)
|
bool isStateDrv(const Derivation & drv)
|
||||||
{
|
{
|
||||||
return nix::isStateDrvPathTxn(noTxn, isStateDrv);
|
return (drv.stateOutputs.size() != 0);
|
||||||
}
|
|
||||||
|
|
||||||
bool isStateDrvTxn(const Transaction & txn, const Derivation & drv)
|
|
||||||
{
|
|
||||||
if (drv.stateOutputs.size() != 0)
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LocalStore::isStateDrv(const Derivation & drv)
|
|
||||||
{
|
|
||||||
return nix::isStateDrvTxn(noTxn, drv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Path queryDeriver(const Transaction & txn, const Path & storePath)
|
static Path queryDeriver(const Transaction & txn, const Path & storePath)
|
||||||
|
|
@ -818,7 +791,7 @@ static Path queryDeriver(const Transaction & txn, const Path & storePath)
|
||||||
bool b = nixDB.queryString(txn, dbDerivers, storePath, deriver);
|
bool b = nixDB.queryString(txn, dbDerivers, storePath, deriver);
|
||||||
|
|
||||||
Derivation drv = derivationFromPathTxn(txn, deriver);
|
Derivation drv = derivationFromPathTxn(txn, deriver);
|
||||||
if (isStateDrvTxn(txn, drv))
|
if (isStateDrv(drv))
|
||||||
throw Error(format("This deriver `%1%' is a state deriver, u should use queryDerivers instead of queryDeriver") % deriver);
|
throw Error(format("This deriver `%1%' is a state deriver, u should use queryDerivers instead of queryDeriver") % deriver);
|
||||||
|
|
||||||
if (b)
|
if (b)
|
||||||
|
|
@ -1573,7 +1546,7 @@ void verifyStore(bool checkContents)
|
||||||
txn.commit();
|
txn.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setStatePathsIntervalTxn(const Transaction & txn, const PathSet & statePaths, const vector<int> & intervals, bool allZero)
|
void setStatePathsIntervalTxn(const Transaction & txn, const PathSet & statePaths, const IntVector & intervals, bool allZero)
|
||||||
{
|
{
|
||||||
if(!allZero && statePaths.size() != intervals.size()){
|
if(!allZero && statePaths.size() != intervals.size()){
|
||||||
throw Error("the number of statepaths and intervals must be equal");
|
throw Error("the number of statepaths and intervals must be equal");
|
||||||
|
|
@ -1587,25 +1560,25 @@ void setStatePathsIntervalTxn(const Transaction & txn, const PathSet & statePath
|
||||||
int interval=0;
|
int interval=0;
|
||||||
if(!allZero)
|
if(!allZero)
|
||||||
interval = intervals.at(n);
|
interval = intervals.at(n);
|
||||||
|
|
||||||
nixDB.setString(txn, dbStateCounters, *i, int2String(interval));
|
nixDB.setString(txn, dbStateCounters, *i, int2String(interval));
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalStore::setStatePathsInterval(const PathSet & statePaths, const vector<int> & intervals, bool allZero)
|
void LocalStore::setStatePathsInterval(const PathSet & statePaths, const IntVector & intervals, bool allZero)
|
||||||
{
|
{
|
||||||
Transaction txn(nixDB);
|
Transaction txn(nixDB);
|
||||||
nix::setStatePathsIntervalTxn(txn, statePaths, intervals, allZero);
|
nix::setStatePathsIntervalTxn(txn, statePaths, intervals, allZero);
|
||||||
txn.commit();
|
txn.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<int> getStatePathsIntervalTxn(const Transaction & txn, const PathSet & statePaths)
|
IntVector getStatePathsIntervalTxn(const Transaction & txn, const PathSet & statePaths)
|
||||||
{
|
{
|
||||||
string data;
|
string data;
|
||||||
Paths referers;
|
Paths referers;
|
||||||
|
|
||||||
vector<int> intervals;
|
IntVector intervals;
|
||||||
for (PathSet::iterator i = statePaths.begin(); i != statePaths.end(); ++i)
|
for (PathSet::iterator i = statePaths.begin(); i != statePaths.end(); ++i)
|
||||||
{
|
{
|
||||||
nixDB.queryString(txn, dbStateCounters, *i, data);
|
nixDB.queryString(txn, dbStateCounters, *i, data);
|
||||||
|
|
@ -1620,7 +1593,7 @@ vector<int> getStatePathsIntervalTxn(const Transaction & txn, const PathSet & st
|
||||||
return intervals;
|
return intervals;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<int> LocalStore::getStatePathsInterval(const PathSet & statePaths)
|
IntVector LocalStore::getStatePathsInterval(const PathSet & statePaths)
|
||||||
{
|
{
|
||||||
return nix::getStatePathsIntervalTxn(noTxn, statePaths);
|
return nix::getStatePathsIntervalTxn(noTxn, statePaths);
|
||||||
}
|
}
|
||||||
|
|
@ -1645,12 +1618,12 @@ vector<int> LocalStore::getStatePathsInterval(const PathSet & statePaths)
|
||||||
|
|
||||||
TODO Change comment, this can also take state paths
|
TODO Change comment, this can also take state paths
|
||||||
*/
|
*/
|
||||||
void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision)
|
void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool withComponents, const bool withState, const int revision)
|
||||||
{
|
{
|
||||||
nix::storePathRequisitesTxn(noTxn, storeOrstatePath, includeOutputs, paths, withComponents, withState, revision);
|
nix::storePathRequisitesTxn(noTxn, storeOrstatePath, includeOutputs, paths, withComponents, withState, revision);
|
||||||
}
|
}
|
||||||
|
|
||||||
void storePathRequisitesTxn(const Transaction & txn, const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision)
|
void storePathRequisitesTxn(const Transaction & txn, const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool withComponents, const bool withState, const int revision)
|
||||||
{
|
{
|
||||||
computeFSClosureTxn(txn, storeOrstatePath, paths, withComponents, withState, revision);
|
computeFSClosureTxn(txn, storeOrstatePath, paths, withComponents, withState, revision);
|
||||||
|
|
||||||
|
|
@ -1667,7 +1640,7 @@ void storePathRequisitesTxn(const Transaction & txn, const Path & storeOrstatePa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalStore::storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision)
|
void LocalStore::storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool withComponents, const bool withState, const int revision)
|
||||||
{
|
{
|
||||||
nix::storePathRequisites(storeOrstatePath, includeOutputs, paths, withComponents, withState, revision);
|
nix::storePathRequisites(storeOrstatePath, includeOutputs, paths, withComponents, withState, revision);
|
||||||
}
|
}
|
||||||
|
|
@ -1848,7 +1821,7 @@ PathSet getSharedWithPathSetRecTxn(const Transaction & txn, const Path & statePa
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LocalStore::revertToRevision(Path & componentPath, Path & derivationPath, Path & statePath, int revision_arg, bool recursive)
|
void LocalStore::revertToRevision(const Path & componentPath, const Path & derivationPath, const Path & statePath, const int revision_arg, const bool recursive)
|
||||||
{
|
{
|
||||||
Transaction txn(nixDB);
|
Transaction txn(nixDB);
|
||||||
revertToRevisionTxn(txn, componentPath, derivationPath, statePath, revision_arg, recursive);
|
revertToRevisionTxn(txn, componentPath, derivationPath, statePath, revision_arg, recursive);
|
||||||
|
|
|
||||||
|
|
@ -55,8 +55,6 @@ public:
|
||||||
|
|
||||||
void queryStateReferences(const Path & storePath, PathSet & stateReferences, const int revision);
|
void queryStateReferences(const Path & storePath, PathSet & stateReferences, const int revision);
|
||||||
|
|
||||||
void queryAllReferences(const Path & path, PathSet & allReferences, const int revision);
|
|
||||||
|
|
||||||
void queryReferrers(const Path & path, PathSet & referrers, const int revision);
|
void queryReferrers(const Path & path, PathSet & referrers, const int revision);
|
||||||
|
|
||||||
void queryStateReferrers(const Path & path, PathSet & stateReferrers, const int revision);
|
void queryStateReferrers(const Path & path, PathSet & stateReferrers, const int revision);
|
||||||
|
|
@ -90,17 +88,13 @@ public:
|
||||||
|
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
|
|
||||||
void setStatePathsInterval(const PathSet & statePath, const vector<int> & intervals, bool allZero = false);
|
void setStatePathsInterval(const PathSet & statePath, const IntVector & intervals, bool allZero = false);
|
||||||
|
|
||||||
vector<int> getStatePathsInterval(const PathSet & statePaths);
|
IntVector getStatePathsInterval(const PathSet & statePaths);
|
||||||
|
|
||||||
bool isStateComponent(const Path & storePath);
|
bool isStateComponent(const Path & storePath);
|
||||||
|
|
||||||
bool isStateDrvPath(const Path & drvpath);
|
void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool withComponents, const bool withState, const int revision);
|
||||||
|
|
||||||
bool isStateDrv(const Derivation & drv);
|
|
||||||
|
|
||||||
void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision);
|
|
||||||
|
|
||||||
void setStateRevisions(const RevisionClosure & revisions, const Path & rootStatePath, const string & comment);
|
void setStateRevisions(const RevisionClosure & revisions, const Path & rootStatePath, const string & comment);
|
||||||
|
|
||||||
|
|
@ -110,7 +104,7 @@ public:
|
||||||
|
|
||||||
Snapshots commitStatePath(const Path & statePath);
|
Snapshots commitStatePath(const Path & statePath);
|
||||||
|
|
||||||
Path queryDeriver(const Path & path); //should these be in here ????
|
Path queryDeriver(const Path & path);
|
||||||
|
|
||||||
PathSet queryDerivers(const Path & storePath, const string & identifier, const string & user); //should these be in here ????
|
PathSet queryDerivers(const Path & storePath, const string & identifier, const string & user); //should these be in here ????
|
||||||
|
|
||||||
|
|
@ -118,7 +112,7 @@ public:
|
||||||
|
|
||||||
PathSet toNonSharedPathSet(const PathSet & statePaths);
|
PathSet toNonSharedPathSet(const PathSet & statePaths);
|
||||||
|
|
||||||
void revertToRevision(Path & componentPath, Path & derivationPath, Path & statePath, int revision_arg, bool recursive);
|
void revertToRevision(const Path & componentPath, const Path & derivationPath, const Path & statePath, const int revision_arg, const bool recursive);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -219,7 +213,7 @@ bool isStateComponentTxn(const Transaction & txn, const Path & path);
|
||||||
|
|
||||||
bool isStateDrvPathTxn(const Transaction & txn, const Path & drvPath);
|
bool isStateDrvPathTxn(const Transaction & txn, const Path & drvPath);
|
||||||
|
|
||||||
bool isStateDrvTxn(const Transaction & txn, const Derivation & drv);
|
bool isStateDrv(const Derivation & drv);
|
||||||
|
|
||||||
//TODO can this ?????
|
//TODO can this ?????
|
||||||
void queryAllValidPathsTxn(const Transaction & txn, PathSet & allComponentPaths, PathSet & allStatePaths);
|
void queryAllValidPathsTxn(const Transaction & txn, PathSet & allComponentPaths, PathSet & allStatePaths);
|
||||||
|
|
@ -235,7 +229,7 @@ void queryReferrersTxn(const Transaction & txn, const Path & storePath, PathSet
|
||||||
void queryStateReferrersTxn(const Transaction & txn, const Path & storePath, PathSet & stateReferrers, const int revision);
|
void queryStateReferrersTxn(const Transaction & txn, const Path & storePath, PathSet & stateReferrers, const int revision);
|
||||||
|
|
||||||
Path queryStatePathDrvTxn(const Transaction & txn, const Path & statePath);
|
Path queryStatePathDrvTxn(const Transaction & txn, const Path & statePath);
|
||||||
void storePathRequisitesTxn(const Transaction & txn, const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision);
|
void storePathRequisitesTxn(const Transaction & txn, const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool withComponents, const bool withState, const int revision);
|
||||||
void setStateRevisionsTxn(const Transaction & txn, const RevisionClosure & revisions, const Path & rootStatePath, const string & comment);
|
void setStateRevisionsTxn(const Transaction & txn, const RevisionClosure & revisions, const Path & rootStatePath, const string & comment);
|
||||||
|
|
||||||
bool isValidPathTxn(const Transaction & txn, const Path & path);
|
bool isValidPathTxn(const Transaction & txn, const Path & path);
|
||||||
|
|
@ -250,10 +244,10 @@ Path toNonSharedPathTxn(const Transaction & txn, const Path & statePath);
|
||||||
PathSet getSharedWithPathSetRecTxn(const Transaction & txn, const Path & statePath);
|
PathSet getSharedWithPathSetRecTxn(const Transaction & txn, const Path & statePath);
|
||||||
|
|
||||||
void ensurePathTxn(const Transaction & txn, const Path & path);
|
void ensurePathTxn(const Transaction & txn, const Path & path);
|
||||||
vector<int> getStatePathsIntervalTxn(const Transaction & txn, const PathSet & statePaths);
|
IntVector getStatePathsIntervalTxn(const Transaction & txn, const PathSet & statePaths);
|
||||||
|
|
||||||
bool queryStateRevisionsTxn(const Transaction & txn, const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, const int revision);
|
bool queryStateRevisionsTxn(const Transaction & txn, const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, const int revision);
|
||||||
void setStatePathsIntervalTxn(const Transaction & txn, const PathSet & statePath, const vector<int> & intervals, bool allZero = false);
|
void setStatePathsIntervalTxn(const Transaction & txn, const PathSet & statePath, const IntVector & intervals, bool allZero = false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -212,8 +212,7 @@ Path RemoteStore::queryStatePathDrv(const Path & statePath)
|
||||||
writeInt(wopQueryStatePathDrv, to);
|
writeInt(wopQueryStatePathDrv, to);
|
||||||
writeString(statePath, to);
|
writeString(statePath, to);
|
||||||
processStderr();
|
processStderr();
|
||||||
Path p = readString(from); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! check wheter from is the state path ????
|
return readString(from);
|
||||||
return p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteStore::queryReferences(const Path & path,
|
void RemoteStore::queryReferences(const Path & path,
|
||||||
|
|
@ -221,10 +220,10 @@ void RemoteStore::queryReferences(const Path & path,
|
||||||
{
|
{
|
||||||
writeInt(wopQueryReferences, to);
|
writeInt(wopQueryReferences, to);
|
||||||
writeString(path, to);
|
writeString(path, to);
|
||||||
|
writeInt(revision, to);
|
||||||
processStderr();
|
processStderr();
|
||||||
PathSet references2 = readStorePaths(from);
|
PathSet references2 = readStorePaths(from);
|
||||||
references.insert(references2.begin(), references2.end());
|
references.insert(references2.begin(), references2.end());
|
||||||
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! include revision?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteStore::queryStateReferences(const Path & path,
|
void RemoteStore::queryStateReferences(const Path & path,
|
||||||
|
|
@ -232,29 +231,23 @@ void RemoteStore::queryStateReferences(const Path & path,
|
||||||
{
|
{
|
||||||
writeInt(wopQueryStateReferences, to);
|
writeInt(wopQueryStateReferences, to);
|
||||||
writeString(path, to);
|
writeString(path, to);
|
||||||
|
writeInt(revision, to);
|
||||||
processStderr();
|
processStderr();
|
||||||
PathSet stateReferences2 = readStorePaths(from);
|
PathSet stateReferences2 = readStorePaths(from);
|
||||||
stateReferences.insert(stateReferences2.begin(), stateReferences2.end());
|
stateReferences.insert(stateReferences2.begin(), stateReferences2.end());
|
||||||
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! include revision?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RemoteStore::queryAllReferences(const Path & path,
|
|
||||||
PathSet & allReferences, const int revision)
|
|
||||||
{
|
|
||||||
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void RemoteStore::queryReferrers(const Path & path,
|
void RemoteStore::queryReferrers(const Path & path,
|
||||||
PathSet & referrers, const int revision)
|
PathSet & referrers, const int revision)
|
||||||
{
|
{
|
||||||
writeInt(wopQueryReferrers, to);
|
writeInt(wopQueryReferrers, to);
|
||||||
writeString(path, to);
|
writeString(path, to);
|
||||||
|
writeInt(revision, to);
|
||||||
processStderr();
|
processStderr();
|
||||||
PathSet referrers2 = readStorePaths(from);
|
PathSet referrers2 = readStorePaths(from);
|
||||||
referrers.insert(referrers2.begin(), referrers2.end());
|
referrers.insert(referrers2.begin(), referrers2.end());
|
||||||
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! include revision?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteStore::queryStateReferrers(const Path & path,
|
void RemoteStore::queryStateReferrers(const Path & path,
|
||||||
|
|
@ -262,10 +255,10 @@ void RemoteStore::queryStateReferrers(const Path & path,
|
||||||
{
|
{
|
||||||
writeInt(wopQueryStateReferrers, to);
|
writeInt(wopQueryStateReferrers, to);
|
||||||
writeString(path, to);
|
writeString(path, to);
|
||||||
|
writeInt(revision, to);
|
||||||
processStderr();
|
processStderr();
|
||||||
PathSet stateReferrers2 = readStorePaths(from);
|
PathSet stateReferrers2 = readStorePaths(from);
|
||||||
stateReferrers.insert(stateReferrers2.begin(), stateReferrers2.end());
|
stateReferrers.insert(stateReferrers2.begin(), stateReferrers2.end());
|
||||||
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! include revision?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -319,7 +312,7 @@ Path RemoteStore::importPath(bool requireSignature, Source & source)
|
||||||
anyway. */
|
anyway. */
|
||||||
|
|
||||||
processStderr(0, &source);
|
processStderr(0, &source);
|
||||||
Path path = readStorePath(from);
|
//Path path = readStorePath(from); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! remove
|
||||||
return readStorePath(from);
|
return readStorePath(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -403,6 +396,136 @@ void RemoteStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
||||||
bytesFreed = (((unsigned long long) hi) << 32) | lo;
|
bytesFreed = (((unsigned long long) hi) << 32) | lo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PathSet RemoteStore::queryDerivers(const Path & storePath, const string & identifier, const string & user)
|
||||||
|
{
|
||||||
|
writeInt(wopQueryDerivers, to);
|
||||||
|
writeString(storePath, to);
|
||||||
|
writeString(identifier, to);
|
||||||
|
writeString(user, to);
|
||||||
|
processStderr();
|
||||||
|
return readStorePaths(from); //TODO is this ok ??
|
||||||
|
}
|
||||||
|
|
||||||
|
void RemoteStore::setStatePathsInterval(const PathSet & statePaths, const IntVector & intervals, bool allZero)
|
||||||
|
{
|
||||||
|
writeInt(wopSetStatePathsInterval, to);
|
||||||
|
writeStringSet(statePaths, to);
|
||||||
|
writeIntVector(intervals, to);
|
||||||
|
writeInt(allZero ? 1 : 0, to);
|
||||||
|
processStderr();
|
||||||
|
readInt(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
IntVector RemoteStore::getStatePathsInterval(const PathSet & statePaths)
|
||||||
|
{
|
||||||
|
writeInt(wopGetStatePathsInterval, to);
|
||||||
|
writeStringSet(statePaths, to);
|
||||||
|
processStderr();
|
||||||
|
return readIntVector(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RemoteStore::isStateComponent(const Path & path)
|
||||||
|
{
|
||||||
|
writeInt(wopIsStateComponent, to);
|
||||||
|
writeString(path, to);
|
||||||
|
processStderr();
|
||||||
|
unsigned int reply = readInt(from);
|
||||||
|
return reply != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RemoteStore::storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool withComponents, const bool withState, const int revision)
|
||||||
|
{
|
||||||
|
writeInt(wopStorePathRequisites, to);
|
||||||
|
writeString(storeOrstatePath, to);
|
||||||
|
writeInt(includeOutputs ? 1 : 0, to);
|
||||||
|
writeStringSet(paths, to);
|
||||||
|
writeInt(withComponents ? 1 : 0, to);
|
||||||
|
writeInt(withState ? 1 : 0, to);
|
||||||
|
writeInt(revision, to);
|
||||||
|
processStderr();
|
||||||
|
readInt(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RemoteStore::setStateRevisions(const RevisionClosure & revisions, const Path & rootStatePath, const string & comment)
|
||||||
|
{
|
||||||
|
writeInt(wopSetStateRevisions, to);
|
||||||
|
writeRevisionClosure(revisions, to);
|
||||||
|
writeString(rootStatePath, to);
|
||||||
|
writeString(comment, to);
|
||||||
|
processStderr();
|
||||||
|
readInt(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RemoteStore::queryStateRevisions(const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, const int revision)
|
||||||
|
{
|
||||||
|
writeInt(wopQueryStateRevisions, to);
|
||||||
|
writeString(statePath, to);
|
||||||
|
writeInt(revision, to);
|
||||||
|
RevisionClosure revisions2 = readRevisionClosure(from);
|
||||||
|
RevisionClosureTS timestamps2 = readRevisionClosureTS(from);
|
||||||
|
revisions = revisions2; //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
timestamps = timestamps2; //TODO !!!!!!!!!!!!!!!!!!!! COPY BY VALUE I THINK
|
||||||
|
processStderr();
|
||||||
|
unsigned int reply = readInt(from);
|
||||||
|
return reply != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RemoteStore::queryAvailableStateRevisions(const Path & statePath, RevisionInfos & revisions)
|
||||||
|
{
|
||||||
|
writeInt(wopQueryAvailableStateRevisions, to);
|
||||||
|
writeString(statePath, to);
|
||||||
|
RevisionInfos revisions2 = readRevisionInfos(from);
|
||||||
|
revisions = revisions2; //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
processStderr();
|
||||||
|
unsigned int reply = readInt(from);
|
||||||
|
return reply != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Snapshots RemoteStore::commitStatePath(const Path & statePath)
|
||||||
|
{
|
||||||
|
writeInt(wopCommitStatePath, to);
|
||||||
|
writeString(statePath, to);
|
||||||
|
processStderr();
|
||||||
|
return readSnapshots(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RemoteStore::scanAndUpdateAllReferences(const Path & statePath, const bool recursive)
|
||||||
|
{
|
||||||
|
writeInt(wopScanAndUpdateAllReferences, to);
|
||||||
|
writeString(statePath, to);
|
||||||
|
writeInt(recursive ? 1 : 0, to);
|
||||||
|
processStderr();
|
||||||
|
readInt(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
Path RemoteStore::queryDeriver(const Path & path)
|
||||||
|
{
|
||||||
|
writeInt(wopQueryDeriver, to);
|
||||||
|
writeString(path, to);
|
||||||
|
processStderr();
|
||||||
|
return readStorePath(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
PathSet RemoteStore::toNonSharedPathSet(const PathSet & statePaths)
|
||||||
|
{
|
||||||
|
writeInt(wopToNonSharedPathSet, to);
|
||||||
|
writeStringSet(statePaths, to);
|
||||||
|
processStderr();
|
||||||
|
return readStringSet(from); //TODO !!!!!!!!!!!!!!! create a readStatePaths just like readStorePaths
|
||||||
|
}
|
||||||
|
|
||||||
|
void RemoteStore::revertToRevision(const Path & componentPath, const Path & derivationPath, const Path & statePath, const int revision_arg, const bool recursive)
|
||||||
|
{
|
||||||
|
writeInt(wopRevertToRevision, to);
|
||||||
|
writeString(componentPath, to);
|
||||||
|
writeString(derivationPath, to);
|
||||||
|
writeString(statePath, to);
|
||||||
|
writeInt(revision_arg, to);
|
||||||
|
writeInt(recursive ? 1 : 0, to);
|
||||||
|
processStderr();
|
||||||
|
readInt(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void RemoteStore::processStderr(Sink * sink, Source * source)
|
void RemoteStore::processStderr(Sink * sink, Source * source)
|
||||||
{
|
{
|
||||||
|
|
@ -433,100 +556,6 @@ void RemoteStore::processStderr(Sink * sink, Source * source)
|
||||||
throw Error("protocol error processing standard error");
|
throw Error("protocol error processing standard error");
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO
|
|
||||||
void RemoteStore::setStatePathsInterval(const PathSet & statePaths, const vector<int> & intervals, bool allZero)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO
|
|
||||||
vector<int> RemoteStore::getStatePathsInterval(const PathSet & statePaths)
|
|
||||||
{
|
|
||||||
vector<int> intervals;
|
|
||||||
return intervals;
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO
|
|
||||||
bool RemoteStore::isStateComponent(const Path & path)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO
|
|
||||||
bool RemoteStore::isStateDrvPath(const Path & drvpath)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO
|
|
||||||
bool RemoteStore::isStateDrv(const Derivation & drv)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO
|
|
||||||
void RemoteStore::storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO
|
|
||||||
void RemoteStore::setStateRevisions(const RevisionClosure & revisions, const Path & rootStatePath, const string & comment)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO
|
|
||||||
bool RemoteStore::queryStateRevisions(const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, const int revision)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO
|
|
||||||
bool RemoteStore::queryAvailableStateRevisions(const Path & statePath, RevisionInfos & revisions)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO
|
|
||||||
Snapshots RemoteStore::commitStatePath(const Path & statePath)
|
|
||||||
{
|
|
||||||
Snapshots ss;
|
|
||||||
return ss;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RemoteStore::scanAndUpdateAllReferences(const Path & statePath, const bool recursive)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Path RemoteStore::queryDeriver(const Path & path)
|
|
||||||
{
|
|
||||||
writeInt(wopQueryDeriver, to);
|
|
||||||
writeString(path, to);
|
|
||||||
processStderr();
|
|
||||||
return readStorePath(from);
|
|
||||||
}
|
|
||||||
|
|
||||||
PathSet RemoteStore::queryDerivers(const Path & storePath, const string & identifier, const string & user)
|
|
||||||
{
|
|
||||||
writeInt(wopQueryDerivers, to);
|
|
||||||
writeString(storePath, to);
|
|
||||||
writeString(identifier, to);
|
|
||||||
writeString(user, to);
|
|
||||||
processStderr();
|
|
||||||
return readStorePaths(from); //TODO is this ok ??
|
|
||||||
}
|
|
||||||
|
|
||||||
PathSet RemoteStore::toNonSharedPathSet(const PathSet & statePaths)
|
|
||||||
{
|
|
||||||
PathSet p;
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RemoteStore::revertToRevision(Path & componentPath, Path & derivationPath, Path & statePath, int revision_arg, bool recursive)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,6 @@ public:
|
||||||
|
|
||||||
void queryStateReferences(const Path & storePath, PathSet & stateReferences, const int revision);
|
void queryStateReferences(const Path & storePath, PathSet & stateReferences, const int revision);
|
||||||
|
|
||||||
void queryAllReferences(const Path & path, PathSet & allReferences, const int revision);
|
|
||||||
|
|
||||||
void queryReferrers(const Path & path, PathSet & referrers, const int revision);
|
void queryReferrers(const Path & path, PathSet & referrers, const int revision);
|
||||||
|
|
||||||
void queryStateReferrers(const Path & path, PathSet & stateReferrers, const int revision);
|
void queryStateReferrers(const Path & path, PathSet & stateReferrers, const int revision);
|
||||||
|
|
@ -76,17 +74,13 @@ public:
|
||||||
void collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
void collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
||||||
bool ignoreLiveness, PathSet & result, unsigned long long & bytesFreed);
|
bool ignoreLiveness, PathSet & result, unsigned long long & bytesFreed);
|
||||||
|
|
||||||
void setStatePathsInterval(const PathSet & statePath, const vector<int> & intervals, bool allZero = false);
|
void setStatePathsInterval(const PathSet & statePath, const IntVector & intervals, bool allZero = false);
|
||||||
|
|
||||||
vector<int> getStatePathsInterval(const PathSet & statePaths);
|
IntVector getStatePathsInterval(const PathSet & statePaths);
|
||||||
|
|
||||||
bool isStateComponent(const Path & path);
|
bool isStateComponent(const Path & path);
|
||||||
|
|
||||||
bool isStateDrvPath(const Path & drvpath);
|
void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool withComponents, const bool withState, const int revision);
|
||||||
|
|
||||||
bool isStateDrv(const Derivation & drv);
|
|
||||||
|
|
||||||
void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision);
|
|
||||||
|
|
||||||
void setStateRevisions(const RevisionClosure & revisions, const Path & rootStatePath, const string & comment);
|
void setStateRevisions(const RevisionClosure & revisions, const Path & rootStatePath, const string & comment);
|
||||||
|
|
||||||
|
|
@ -104,7 +98,7 @@ public:
|
||||||
|
|
||||||
PathSet toNonSharedPathSet(const PathSet & statePaths);
|
PathSet toNonSharedPathSet(const PathSet & statePaths);
|
||||||
|
|
||||||
void revertToRevision(Path & componentPath, Path & derivationPath, Path & statePath, int revision_arg, bool recursive);
|
void revertToRevision(const Path & componentPath, const Path & derivationPath, const Path & statePath, const int revision_arg, const bool recursive);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AutoCloseFD fdSocket;
|
AutoCloseFD fdSocket;
|
||||||
|
|
|
||||||
|
|
@ -87,8 +87,6 @@ public:
|
||||||
The result is not cleared. */
|
The result is not cleared. */
|
||||||
virtual void queryStateReferences(const Path & storePath, PathSet & stateReferences, const int revision) = 0;
|
virtual void queryStateReferences(const Path & storePath, PathSet & stateReferences, const int revision) = 0;
|
||||||
|
|
||||||
virtual void queryAllReferences(const Path & path, PathSet & allReferences, const int revision) = 0;
|
|
||||||
|
|
||||||
/* Queries the set of incoming FS references for a store path.
|
/* Queries the set of incoming FS references for a store path.
|
||||||
The result is not cleared. */
|
The result is not cleared. */
|
||||||
virtual void queryReferrers(const Path & path,
|
virtual void queryReferrers(const Path & path,
|
||||||
|
|
@ -202,22 +200,16 @@ public:
|
||||||
bool ignoreLiveness, PathSet & result, unsigned long long & bytesFreed) = 0;
|
bool ignoreLiveness, PathSet & result, unsigned long long & bytesFreed) = 0;
|
||||||
|
|
||||||
/* TODO */
|
/* TODO */
|
||||||
virtual void setStatePathsInterval(const PathSet & statePath, const vector<int> & intervals, bool allZero = false) = 0;
|
virtual void setStatePathsInterval(const PathSet & statePath, const IntVector & intervals, bool allZero = false) = 0;
|
||||||
|
|
||||||
/* TODO */
|
/* TODO */
|
||||||
virtual vector<int> getStatePathsInterval(const PathSet & statePaths) = 0;
|
virtual IntVector getStatePathsInterval(const PathSet & statePaths) = 0;
|
||||||
|
|
||||||
/* Checks whether a path is a component path that has a statePath. */
|
/* Checks whether a path is a component path that has a statePath. */
|
||||||
virtual bool isStateComponent(const Path & path) = 0;
|
virtual bool isStateComponent(const Path & path) = 0;
|
||||||
|
|
||||||
/* TODO */
|
/* TODO */
|
||||||
virtual bool isStateDrvPath(const Path & drvpath) = 0;
|
virtual void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool withComponents, const bool withState, const int revision) = 0;
|
||||||
|
|
||||||
/* TODO */
|
|
||||||
virtual bool isStateDrv(const Derivation & drv) = 0;
|
|
||||||
|
|
||||||
/* TODO */
|
|
||||||
virtual void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision) = 0;
|
|
||||||
|
|
||||||
/* TODO */
|
/* TODO */
|
||||||
virtual void setStateRevisions(const RevisionClosure & revisions, const Path & rootStatePath, const string & comment) = 0;
|
virtual void setStateRevisions(const RevisionClosure & revisions, const Path & rootStatePath, const string & comment) = 0;
|
||||||
|
|
@ -234,14 +226,18 @@ public:
|
||||||
/* Query the deriver of a store path. Return the empty string if
|
/* Query the deriver of a store path. Return the empty string if
|
||||||
no deriver has been set. */
|
no deriver has been set. */
|
||||||
virtual Path queryDeriver(const Path & path) = 0;
|
virtual Path queryDeriver(const Path & path) = 0;
|
||||||
|
|
||||||
|
/* TODO */
|
||||||
virtual PathSet queryDerivers(const Path & storePath, const string & identifier, const string & user) = 0;
|
virtual PathSet queryDerivers(const Path & storePath, const string & identifier, const string & user) = 0;
|
||||||
|
|
||||||
|
/* TODO */
|
||||||
virtual void scanAndUpdateAllReferences(const Path & statePath, const bool recursive) = 0;
|
virtual void scanAndUpdateAllReferences(const Path & statePath, const bool recursive) = 0;
|
||||||
|
|
||||||
|
/* TODO */
|
||||||
virtual PathSet toNonSharedPathSet(const PathSet & statePaths) = 0;
|
virtual PathSet toNonSharedPathSet(const PathSet & statePaths) = 0;
|
||||||
|
|
||||||
virtual void revertToRevision(Path & componentPath, Path & derivationPath, Path & statePath, int revision_arg, bool recursive) = 0;
|
/* TODO */
|
||||||
|
virtual void revertToRevision(const Path & componentPath, const Path & derivationPath, const Path & statePath, const int revision_arg, const bool recursive) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ void createStateDirsTxn(const Transaction & txn, const DerivationStateOutputDirs
|
||||||
}
|
}
|
||||||
|
|
||||||
//Initialize the counters for the statePaths that have an interval to 0
|
//Initialize the counters for the statePaths that have an interval to 0
|
||||||
vector<int> empty;
|
IntVector empty;
|
||||||
setStatePathsIntervalTxn(txn, intervalPaths, empty, true);
|
setStatePathsIntervalTxn(txn, intervalPaths, empty, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -90,7 +90,7 @@ PathSet getAllStateDerivationsRecursivelyTxn(const Transaction & txn, const Path
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void revertToRevisionTxn(const Transaction & txn, Path & componentPath, Path & derivationPath, Path & statePath, int revision_arg, bool recursive)
|
void revertToRevisionTxn(const Transaction & txn, const Path & componentPath, const Path & derivationPath, const Path & statePath, const int revision_arg, const bool recursive)
|
||||||
{
|
{
|
||||||
|
|
||||||
PathSet statePaths;
|
PathSet statePaths;
|
||||||
|
|
@ -222,7 +222,7 @@ Snapshots commitStatePathTxn(const Transaction & txn, const Path & statePath)
|
||||||
intervalPaths.insert(fullstatedir);
|
intervalPaths.insert(fullstatedir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vector<int> intervals = getStatePathsIntervalTxn(txn, intervalPaths);
|
IntVector intervals = getStatePathsIntervalTxn(txn, intervalPaths);
|
||||||
|
|
||||||
Snapshots revisions_list;
|
Snapshots revisions_list;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ void scanAndUpdateAllReferencesTxn(const Transaction & txn, const Path & statePa
|
||||||
|
|
||||||
void scanAndUpdateAllReferencesRecusivelyTxn(const Transaction & txn, const Path & statePath);
|
void scanAndUpdateAllReferencesRecusivelyTxn(const Transaction & txn, const Path & statePath);
|
||||||
|
|
||||||
void revertToRevisionTxn(const Transaction & txn, Path & componentPath, Path & derivationPath, Path & statePath, int revision_arg, bool recursive);
|
void revertToRevisionTxn(const Transaction & txn, const Path & componentPath, const Path & derivationPath, const Path & statePath, const int revision_arg, const bool recursive);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,19 @@ typedef enum {
|
||||||
wopExportPath,
|
wopExportPath,
|
||||||
wopImportPath,
|
wopImportPath,
|
||||||
wopQueryDeriver,
|
wopQueryDeriver,
|
||||||
|
|
||||||
wopQueryDerivers,
|
wopQueryDerivers,
|
||||||
|
wopSetStatePathsInterval,
|
||||||
|
wopGetStatePathsInterval,
|
||||||
|
wopIsStateComponent,
|
||||||
|
wopStorePathRequisites,
|
||||||
|
wopSetStateRevisions,
|
||||||
|
wopQueryStateRevisions,
|
||||||
|
wopQueryAvailableStateRevisions,
|
||||||
|
wopCommitStatePath,
|
||||||
|
wopScanAndUpdateAllReferences,
|
||||||
|
wopToNonSharedPathSet,
|
||||||
|
wopRevertToRevision,
|
||||||
} WorkerOp;
|
} WorkerOp;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,50 @@ void writeStringSet(const StringSet & ss, Sink & sink)
|
||||||
writeString(*i, sink);
|
writeString(*i, sink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void writeIntVector(const IntVector & iv, Sink & sink)
|
||||||
|
{
|
||||||
|
writeInt(iv.size(), sink);
|
||||||
|
for(int i=0;i < iv.size(); i++)
|
||||||
|
writeString(int2String(iv.at(i)), sink);
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeRevisionClosure(const RevisionClosure & rc, Sink & sink)
|
||||||
|
{
|
||||||
|
writeInt(rc.size(), sink);
|
||||||
|
for (RevisionClosure::const_iterator i = rc.begin(); i != rc.end(); ++i){
|
||||||
|
writeString((*i).first, sink);
|
||||||
|
writeSnapshots((*i).second, sink);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeSnapshots(const Snapshots & ss, Sink & sink)
|
||||||
|
{
|
||||||
|
writeInt(ss.size(), sink);
|
||||||
|
for (Snapshots::const_iterator i = ss.begin(); i != ss.end(); ++i){
|
||||||
|
writeString((*i).first, sink);
|
||||||
|
writeInt((*i).second, sink); //TODO MUST BE UNSGINED INT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeRevisionClosureTS(const RevisionClosureTS & rc, Sink & sink)
|
||||||
|
{
|
||||||
|
writeInt(rc.size(), sink);
|
||||||
|
for (RevisionClosureTS::const_iterator i = rc.begin(); i != rc.end(); ++i){
|
||||||
|
writeString((*i).first, sink);
|
||||||
|
writeInt((*i).second, sink);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeRevisionInfos(const RevisionInfos & ri, Sink & sink)
|
||||||
|
{
|
||||||
|
writeInt(ri.size(), sink);
|
||||||
|
for (RevisionInfos::const_iterator i = ri.begin(); i != ri.end(); ++i){
|
||||||
|
writeInt((*i).first, sink);
|
||||||
|
RevisionInfo rvi = (*i).second;
|
||||||
|
writeString(rvi.comment, sink);
|
||||||
|
writeInt(rvi.timestamp, sink); //TODO MUST BE UNSGINED INT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void readPadding(unsigned int len, Source & source)
|
void readPadding(unsigned int len, Source & source)
|
||||||
{
|
{
|
||||||
|
|
@ -102,5 +146,86 @@ StringSet readStringSet(Source & source)
|
||||||
return ss;
|
return ss;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
//IntVector
|
||||||
|
//RevisionClosure
|
||||||
|
//RevisionClosureTS
|
||||||
|
//RevisionInfos
|
||||||
|
|
||||||
|
struct RevisionInfo
|
||||||
|
{
|
||||||
|
string comment;
|
||||||
|
unsigned int timestamp;
|
||||||
|
};
|
||||||
|
typedef map<int, RevisionInfo> RevisionInfos;
|
||||||
|
typedef map<Path, unsigned int> Snapshots; //Automatically sorted on Path :)
|
||||||
|
typedef map<Path, Snapshots> RevisionClosure;
|
||||||
|
typedef map<Path, int> RevisionClosureTS;
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
IntVector readIntVector(Source & source)
|
||||||
|
{
|
||||||
|
unsigned int count = readInt(source);
|
||||||
|
IntVector iv;
|
||||||
|
while (count--){
|
||||||
|
string s = readString(source);
|
||||||
|
int i;
|
||||||
|
if (!string2Int(s, i))
|
||||||
|
throw Error(format("`%1%' is corrupt in readIntVector") % s);
|
||||||
|
iv.push_back(i);
|
||||||
|
}
|
||||||
|
return iv;
|
||||||
|
}
|
||||||
|
|
||||||
|
RevisionClosure readRevisionClosure(Source & source)
|
||||||
|
{
|
||||||
|
unsigned int count = readInt(source);
|
||||||
|
RevisionClosure rc;
|
||||||
|
while (count--){
|
||||||
|
string path = readString(source);
|
||||||
|
Snapshots ss = readSnapshots(source);
|
||||||
|
rc[path] = ss;
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Snapshots readSnapshots(Source & source)
|
||||||
|
{
|
||||||
|
unsigned int count = readInt(source);
|
||||||
|
Snapshots ss;
|
||||||
|
while (count--){
|
||||||
|
string path = readString(source);
|
||||||
|
unsigned int ri = readInt(source); //TODO MUST BE UNSGINED INT
|
||||||
|
ss[path] = ri;
|
||||||
|
}
|
||||||
|
return ss;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RevisionClosureTS readRevisionClosureTS(Source & source)
|
||||||
|
{
|
||||||
|
unsigned int count = readInt(source);
|
||||||
|
RevisionClosureTS rc;
|
||||||
|
while (count--){
|
||||||
|
string path = readString(source);
|
||||||
|
int ri = readInt(source);
|
||||||
|
rc[path] = ri;
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
RevisionInfos readRevisionInfos(Source & source)
|
||||||
|
{
|
||||||
|
unsigned int count = readInt(source);
|
||||||
|
RevisionInfos ri;
|
||||||
|
while (count--){
|
||||||
|
readInt(source);
|
||||||
|
RevisionInfo rvi;
|
||||||
|
rvi.comment = readString(source);
|
||||||
|
rvi.timestamp = readInt(source);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -98,11 +98,22 @@ void writeInt(unsigned int n, Sink & sink);
|
||||||
void writeString(const string & s, Sink & sink);
|
void writeString(const string & s, Sink & sink);
|
||||||
void writeStringSet(const StringSet & ss, Sink & sink);
|
void writeStringSet(const StringSet & ss, Sink & sink);
|
||||||
|
|
||||||
|
void writeIntVector(const IntVector & iv, Sink & sink);
|
||||||
|
void writeRevisionClosure(const RevisionClosure & rc, Sink & sink);
|
||||||
|
void writeSnapshots(const Snapshots & ss, Sink & sink);
|
||||||
|
void writeRevisionClosureTS(const RevisionClosureTS & rc, Sink & sink);
|
||||||
|
void writeRevisionInfos(const RevisionInfos & ri, Sink & sink);
|
||||||
|
|
||||||
void readPadding(unsigned int len, Source & source);
|
void readPadding(unsigned int len, Source & source);
|
||||||
unsigned int readInt(Source & source);
|
unsigned int readInt(Source & source);
|
||||||
string readString(Source & source);
|
string readString(Source & source);
|
||||||
StringSet readStringSet(Source & source);
|
StringSet readStringSet(Source & source);
|
||||||
|
|
||||||
|
IntVector readIntVector(Source & source);
|
||||||
|
RevisionClosure readRevisionClosure(Source & source);
|
||||||
|
Snapshots readSnapshots(Source & source);
|
||||||
|
RevisionClosureTS readRevisionClosureTS(Source & source);
|
||||||
|
RevisionInfos readRevisionInfos(Source & source);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ typedef list<Path> Paths;
|
||||||
typedef set<Path> PathSet;
|
typedef set<Path> PathSet;
|
||||||
|
|
||||||
//state types
|
//state types
|
||||||
typedef list<int> RevisionNumbers; //the Strings (list) of StateReferences and this list are connected by position
|
typedef vector<int> IntVector; //the Strings (list) of StateReferences and this list are connected by position
|
||||||
struct RevisionInfo
|
struct RevisionInfo
|
||||||
{
|
{
|
||||||
string comment;
|
string comment;
|
||||||
|
|
|
||||||
|
|
@ -919,22 +919,22 @@ Strings unpackStrings(const string & s)
|
||||||
return strings;
|
return strings;
|
||||||
}
|
}
|
||||||
|
|
||||||
string packRevisionNumbers(const RevisionNumbers & revs)
|
string packRevisionNumbers(const IntVector & revs)
|
||||||
{
|
{
|
||||||
string seperator = "|";
|
string seperator = "|";
|
||||||
string d = "";
|
string d = "";
|
||||||
for (RevisionNumbers::const_iterator i = revs.begin();
|
for (IntVector::const_iterator i = revs.begin();
|
||||||
i != revs.end(); ++i){
|
i != revs.end(); ++i){
|
||||||
d += int2String(*i) + seperator;
|
d += int2String(*i) + seperator;
|
||||||
}
|
}
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
RevisionNumbers unpackRevisionNumbers(const string & packed)
|
IntVector unpackRevisionNumbers(const string & packed)
|
||||||
{
|
{
|
||||||
string seperator = "|";
|
string seperator = "|";
|
||||||
Strings ss = tokenizeString(packed, seperator);
|
Strings ss = tokenizeString(packed, seperator);
|
||||||
RevisionNumbers revs;
|
IntVector revs;
|
||||||
|
|
||||||
for (Strings::const_iterator i = ss.begin();
|
for (Strings::const_iterator i = ss.begin();
|
||||||
i != ss.end(); ++i){
|
i != ss.end(); ++i){
|
||||||
|
|
|
||||||
|
|
@ -497,7 +497,7 @@ static void installDerivations(Globals & globals,
|
||||||
//Set the state indentifier if it is a state-component
|
//Set the state indentifier if it is a state-component
|
||||||
printMsg(lvlError, format("New component to install DRV: '%1%'") % i->queryDrvPath(globals.state));
|
printMsg(lvlError, format("New component to install DRV: '%1%'") % i->queryDrvPath(globals.state));
|
||||||
Derivation drv = derivationFromPathTxn(noTxn, i->queryDrvPath(globals.state));
|
Derivation drv = derivationFromPathTxn(noTxn, i->queryDrvPath(globals.state));
|
||||||
if(store->isStateDrv(drv))
|
if(isStateDrv(drv))
|
||||||
{
|
{
|
||||||
DerivationStateOutputs stateOutputs = drv.stateOutputs;
|
DerivationStateOutputs stateOutputs = drv.stateOutputs;
|
||||||
string stateIdentifier = stateOutputs.find("state")->second.stateIdentifier;
|
string stateIdentifier = stateOutputs.find("state")->second.stateIdentifier;
|
||||||
|
|
|
||||||
|
|
@ -213,7 +213,7 @@ static void queryAvailableStateRevisions(Strings opFlags, Strings opArgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Sort ourselfes to create a nice output
|
//Sort ourselfes to create a nice output
|
||||||
vector<int> revisions_sort;
|
IntVector revisions_sort;
|
||||||
int highestrev;
|
int highestrev;
|
||||||
for (RevisionInfos::iterator i = revisions.begin(); i != revisions.end(); ++i){
|
for (RevisionInfos::iterator i = revisions.begin(); i != revisions.end(); ++i){
|
||||||
int rev = (*i).first;
|
int rev = (*i).first;
|
||||||
|
|
@ -224,7 +224,7 @@ static void queryAvailableStateRevisions(Strings opFlags, Strings opArgs)
|
||||||
sort(revisions_sort.begin(), revisions_sort.end());
|
sort(revisions_sort.begin(), revisions_sort.end());
|
||||||
|
|
||||||
int max_size = int2String(highestrev).length();
|
int max_size = int2String(highestrev).length();
|
||||||
for (vector<int>::iterator i = revisions_sort.begin(); i != revisions_sort.end(); ++i)
|
for (IntVector::iterator i = revisions_sort.begin(); i != revisions_sort.end(); ++i)
|
||||||
{
|
{
|
||||||
int rev = *i;
|
int rev = *i;
|
||||||
string rev_s = padd(int2String(rev), '0' , max_size, true); //pad revisions with a 0
|
string rev_s = padd(int2String(rev), '0' , max_size, true); //pad revisions with a 0
|
||||||
|
|
|
||||||
|
|
@ -111,9 +111,13 @@ void printDotGraph(const PathSet & roots)
|
||||||
|
|
||||||
cout << makeNode(path, symbolicName(path), "#ff0000");
|
cout << makeNode(path, symbolicName(path), "#ff0000");
|
||||||
|
|
||||||
PathSet allReferences;
|
|
||||||
store->queryAllReferences(path, allReferences, -1);
|
|
||||||
|
|
||||||
|
//Lookup all references
|
||||||
|
PathSet references;
|
||||||
|
PathSet stateReferences;
|
||||||
|
store->queryReferences(path, references, -1);
|
||||||
|
store->queryStateReferences(path, stateReferences, -1);
|
||||||
|
PathSet allReferences = pathSets_union(references, stateReferences);
|
||||||
|
|
||||||
for (PathSet::iterator i = allReferences.begin();
|
for (PathSet::iterator i = allReferences.begin();
|
||||||
i != allReferences.end(); ++i)
|
i != allReferences.end(); ++i)
|
||||||
|
|
|
||||||
|
|
@ -211,8 +211,12 @@ static void printTree(const Path & path,
|
||||||
|
|
||||||
cout << format("%1%%2%\n") % firstPad % path;
|
cout << format("%1%%2%\n") % firstPad % path;
|
||||||
|
|
||||||
PathSet allReferences;
|
//Lookup all references
|
||||||
store->queryAllReferences(path, allReferences, -1);
|
PathSet references;
|
||||||
|
PathSet stateReferences;
|
||||||
|
store->queryReferences(path, references, -1);
|
||||||
|
store->queryStateReferences(path, stateReferences, -1);
|
||||||
|
PathSet allReferences = pathSets_union(references, stateReferences);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
for (PathSet::iterator i = drv.inputSrcs.begin();
|
for (PathSet::iterator i = drv.inputSrcs.begin();
|
||||||
|
|
|
||||||
|
|
@ -284,7 +284,7 @@ static void performOp(Source & from, Sink & to, unsigned int op)
|
||||||
}
|
}
|
||||||
|
|
||||||
case wopQueryStatePathDrv: {
|
case wopQueryStatePathDrv: {
|
||||||
Path path = readStorePath(from); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! needs to be the state path
|
Path path = readString(from); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! make a readStatePath...
|
||||||
startWork();
|
startWork();
|
||||||
Path p = store->queryStatePathDrv(path);
|
Path p = store->queryStatePathDrv(path);
|
||||||
stopWork();
|
stopWork();
|
||||||
|
|
@ -295,12 +295,13 @@ static void performOp(Source & from, Sink & to, unsigned int op)
|
||||||
case wopQueryReferences:
|
case wopQueryReferences:
|
||||||
case wopQueryReferrers: {
|
case wopQueryReferrers: {
|
||||||
Path path = readStorePath(from);
|
Path path = readStorePath(from);
|
||||||
|
int revision = readInt(from);
|
||||||
startWork();
|
startWork();
|
||||||
PathSet paths;
|
PathSet paths;
|
||||||
if (op == wopQueryReferences)
|
if (op == wopQueryReferences)
|
||||||
store->queryReferences(path, paths, -1);
|
store->queryReferences(path, paths, revision);
|
||||||
else
|
else
|
||||||
store->queryReferrers(path, paths, -1);
|
store->queryReferrers(path, paths, revision);
|
||||||
stopWork();
|
stopWork();
|
||||||
writeStringSet(paths, to);
|
writeStringSet(paths, to);
|
||||||
break;
|
break;
|
||||||
|
|
@ -309,12 +310,13 @@ static void performOp(Source & from, Sink & to, unsigned int op)
|
||||||
case wopQueryStateReferences:
|
case wopQueryStateReferences:
|
||||||
case wopQueryStateReferrers: {
|
case wopQueryStateReferrers: {
|
||||||
Path path = readStorePath(from);
|
Path path = readStorePath(from);
|
||||||
|
int revision = readInt(from);
|
||||||
startWork();
|
startWork();
|
||||||
PathSet paths;
|
PathSet paths;
|
||||||
if (op == wopQueryStateReferences)
|
if (op == wopQueryStateReferences)
|
||||||
store->queryStateReferences(path, paths, -1);
|
store->queryStateReferences(path, paths, revision);
|
||||||
else
|
else
|
||||||
store->queryStateReferrers(path, paths, -1); //TODO Does this work???, how about the state path?????????
|
store->queryStateReferrers(path, paths, revision); //TODO Does this work???, how about the state path?????????
|
||||||
stopWork();
|
stopWork();
|
||||||
writeStringSet(paths, to);
|
writeStringSet(paths, to);
|
||||||
break;
|
break;
|
||||||
|
|
@ -329,17 +331,6 @@ static void performOp(Source & from, Sink & to, unsigned int op)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case wopQueryDerivers: {
|
|
||||||
Path path = readStorePath(from);
|
|
||||||
string identifier = readString(from);
|
|
||||||
string user = readString(from);
|
|
||||||
startWork();
|
|
||||||
PathSet derivers = store->queryDerivers(path, identifier, user);
|
|
||||||
stopWork();
|
|
||||||
writeStringSet(derivers, to);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case wopAddToStore: {
|
case wopAddToStore: {
|
||||||
string baseName = readString(from);
|
string baseName = readString(from);
|
||||||
bool fixed = readInt(from) == 1;
|
bool fixed = readInt(from) == 1;
|
||||||
|
|
@ -474,6 +465,72 @@ static void performOp(Source & from, Sink & to, unsigned int op)
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case wopQueryDerivers: {
|
||||||
|
Path path = readStorePath(from);
|
||||||
|
string identifier = readString(from);
|
||||||
|
string user = readString(from);
|
||||||
|
startWork();
|
||||||
|
PathSet derivers = store->queryDerivers(path, identifier, user);
|
||||||
|
stopWork();
|
||||||
|
writeStringSet(derivers, to);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case wopSetStatePathsInterval: {
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case wopGetStatePathsInterval: {
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case wopIsStateComponent: {
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case wopStorePathRequisites: {
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case wopSetStateRevisions: {
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case wopQueryStateRevisions: {
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case wopQueryAvailableStateRevisions: {
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case wopCommitStatePath: {
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case wopScanAndUpdateAllReferences: {
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case wopToNonSharedPathSet: {
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case wopRevertToRevision: {
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw Error(format("invalid operation %1%") % op);
|
throw Error(format("invalid operation %1%") % op);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue