mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 04:00:59 +01:00
coputeFSClosure is now transactional, state will now be commited after the component has been build
This commit is contained in:
parent
f3dabd6206
commit
e33a1e4e74
6 changed files with 46 additions and 23 deletions
|
|
@ -604,8 +604,8 @@ void Database::setStateRevisions(const Transaction & txn, TableId table,
|
||||||
sorted_revisions.push_back(revisions.at(*i));
|
sorted_revisions.push_back(revisions.at(*i));
|
||||||
|
|
||||||
//Debugging
|
//Debugging
|
||||||
//for (vector<Path>::const_iterator i = sortedStatePaths.begin(); i != sortedStatePaths.end(); ++i)
|
for (vector<Path>::const_iterator i = sortedStatePaths.begin(); i != sortedStatePaths.end(); ++i)
|
||||||
// printMsg(lvlError, format("Insert: %1% into %2%") % int2String(revisions.at(*i)) % *i);
|
printMsg(lvlError, format("Insert: %1% into %2%") % int2String(revisions.at(*i)) % *i);
|
||||||
|
|
||||||
//Convert the int's into Strings
|
//Convert the int's into Strings
|
||||||
Strings data;
|
Strings data;
|
||||||
|
|
|
||||||
|
|
@ -594,7 +594,7 @@ void LocalStore::queryAllReferences(const Path & path, PathSet & allReferences,
|
||||||
queryAllReferencesTxn(noTxn, path, allReferences, revision);
|
queryAllReferencesTxn(noTxn, path, allReferences, revision);
|
||||||
}
|
}
|
||||||
|
|
||||||
void queryReferrers(const Transaction & txn,
|
void queryReferrersTxn(const Transaction & txn,
|
||||||
const Path & storePath, PathSet & referrers, const int revision)
|
const Path & storePath, PathSet & referrers, const int revision)
|
||||||
{
|
{
|
||||||
if (!isRealisableComponentOrStatePath(txn, storePath))
|
if (!isRealisableComponentOrStatePath(txn, storePath))
|
||||||
|
|
@ -606,11 +606,11 @@ void queryReferrers(const Transaction & txn,
|
||||||
void LocalStore::queryReferrers(const Path & storePath,
|
void LocalStore::queryReferrers(const Path & storePath,
|
||||||
PathSet & referrers, const int revision)
|
PathSet & referrers, const int revision)
|
||||||
{
|
{
|
||||||
nix::queryReferrers(noTxn, storePath, referrers, revision);
|
nix::queryReferrersTxn(noTxn, storePath, referrers, revision);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void queryStateReferrers(const Transaction & txn, const Path & storePath, PathSet & stateReferrers, const int revision)
|
void queryStateReferrersTxn(const Transaction & txn, const Path & storePath, PathSet & stateReferrers, const int revision)
|
||||||
{
|
{
|
||||||
if (!isRealisableComponentOrStatePath(txn, storePath))
|
if (!isRealisableComponentOrStatePath(txn, storePath))
|
||||||
throw Error(format("path `%1%' is not valid") % storePath);
|
throw Error(format("path `%1%' is not valid") % storePath);
|
||||||
|
|
@ -620,7 +620,7 @@ void queryStateReferrers(const Transaction & txn, const Path & storePath, PathSe
|
||||||
|
|
||||||
void LocalStore::queryStateReferrers(const Path & storePath, PathSet & stateReferrers, const int revision)
|
void LocalStore::queryStateReferrers(const Path & storePath, PathSet & stateReferrers, const int revision)
|
||||||
{
|
{
|
||||||
nix::queryStateReferrers(noTxn, storePath, stateReferrers, revision);
|
nix::queryStateReferrersTxn(noTxn, storePath, stateReferrers, revision);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1623,7 +1623,12 @@ PathSet mergeNewDerivationIntoList(const Path & storepath, const Path & newdrv,
|
||||||
*/
|
*/
|
||||||
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)
|
||||||
{
|
{
|
||||||
computeFSClosure(storeOrstatePath, 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)
|
||||||
|
{
|
||||||
|
computeFSClosureTxn(txn, storeOrstatePath, paths, withComponents, withState, revision);
|
||||||
|
|
||||||
if (includeOutputs) {
|
if (includeOutputs) {
|
||||||
for (PathSet::iterator i = paths.begin();
|
for (PathSet::iterator i = paths.begin();
|
||||||
|
|
@ -1632,15 +1637,15 @@ void storePathRequisites(const Path & storeOrstatePath, const bool includeOutput
|
||||||
Derivation drv = derivationFromPath(*i);
|
Derivation drv = derivationFromPath(*i);
|
||||||
for (DerivationOutputs::iterator j = drv.outputs.begin();
|
for (DerivationOutputs::iterator j = drv.outputs.begin();
|
||||||
j != drv.outputs.end(); ++j)
|
j != drv.outputs.end(); ++j)
|
||||||
if (store->isValidPath(j->second.path))
|
if (isValidPathTxn(txn, j->second.path))
|
||||||
computeFSClosure(j->second.path, paths, withComponents, withState, revision);
|
computeFSClosureTxn(txn, j->second.path, paths, withComponents, withState, revision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
return nix::storePathRequisites(storeOrstatePath, includeOutputs, paths, withComponents, withState, revision);
|
nix::storePathRequisites(storeOrstatePath, includeOutputs, paths, withComponents, withState, revision);
|
||||||
}
|
}
|
||||||
|
|
||||||
void queryAllValidPaths(const Transaction & txn, PathSet & allComponentPaths, PathSet & allStatePaths)
|
void queryAllValidPaths(const Transaction & txn, PathSet & allComponentPaths, PathSet & allStatePaths)
|
||||||
|
|
|
||||||
|
|
@ -225,12 +225,21 @@ bool isStateDrvTxn(const Transaction & txn, const Derivation & drv);
|
||||||
//TODO can this ?????
|
//TODO can this ?????
|
||||||
void queryAllValidPaths(const Transaction & txn, PathSet & allComponentPaths, PathSet & allStatePaths);
|
void queryAllValidPaths(const Transaction & txn, PathSet & allComponentPaths, PathSet & allStatePaths);
|
||||||
bool isValidStatePathTxn(const Transaction & txn, const Path & path);
|
bool isValidStatePathTxn(const Transaction & txn, const Path & path);
|
||||||
|
|
||||||
void queryReferencesTxn(const Transaction & txn, const Path & path, PathSet & references, const int revision);
|
void queryReferencesTxn(const Transaction & txn, const Path & path, PathSet & references, const int revision);
|
||||||
void queryStateReferencesTxn(const Transaction & txn, const Path & storePath, PathSet & stateReferences, const int revision);
|
void queryStateReferencesTxn(const Transaction & txn, const Path & storePath, PathSet & stateReferences, const int revision);
|
||||||
|
|
||||||
|
void queryReferrersTxn(const Transaction & txn, const Path & storePath, PathSet & referrers, 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 storePathRequisites(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 Path & statePath, const RevisionNumbersSet & revisions);
|
void setStateRevisionsTxn(const Transaction & txn, const Path & statePath, const RevisionNumbersSet & revisions);
|
||||||
|
|
||||||
|
bool isValidPathTxn(const Transaction & txn, const Path & path);
|
||||||
|
bool isValidStatePathTxn(const Transaction & txn, const Path & path);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include "misc.hh"
|
#include "misc.hh"
|
||||||
#include "store-api.hh"
|
#include "store-api.hh"
|
||||||
#include "db.hh"
|
#include "db.hh"
|
||||||
|
#include "local-store.hh"
|
||||||
|
|
||||||
#include <aterm2.h>
|
#include <aterm2.h>
|
||||||
|
|
||||||
|
|
@ -19,28 +20,33 @@ Derivation derivationFromPath(const Path & drvPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
void computeFSClosure(const Path & path, PathSet & paths, const bool & withComponents, const bool & withState, const int revision, bool flipDirection)
|
void computeFSClosure(const Path & path, PathSet & paths, const bool & withComponents, const bool & withState, const int revision, bool flipDirection)
|
||||||
|
{
|
||||||
|
computeFSClosureTxn(noTxn, path, paths, withComponents, withState, revision, flipDirection);
|
||||||
|
}
|
||||||
|
|
||||||
|
void computeFSClosureTxn(const Transaction & txn, const Path & path, PathSet & paths, const bool & withComponents, const bool & withState, const int revision, bool flipDirection)
|
||||||
{
|
{
|
||||||
PathSet allPaths;
|
PathSet allPaths;
|
||||||
computeFSClosureRec(path, allPaths, revision, flipDirection);
|
computeFSClosureRecTxn(txn, path, allPaths, revision, flipDirection);
|
||||||
|
|
||||||
if(!withComponents && !withState)
|
if(!withComponents && !withState)
|
||||||
throw Error(format("Useless call to computeFSClosure, at leat withComponents or withState must be true"));
|
throw Error(format("Useless call to computeFSClosure, at leat withComponents or withState must be true"));
|
||||||
|
|
||||||
//TODO MAYBE EDIT: HOW CAN THESE PATHS ALREADY BE VALID SOMETIMES ..... ?????????????????????
|
//TODO MAYBE EDIT: HOW CAN THESE PATHS ALREADY BE VALID SOMETIMES ..... ?????????????????????
|
||||||
for (PathSet::iterator i = allPaths.begin(); i != allPaths.end(); ++i)
|
for (PathSet::iterator i = allPaths.begin(); i != allPaths.end(); ++i)
|
||||||
if ( !store->isValidPath(*i) && !store->isValidStatePath(*i) )
|
if ( !isValidPathTxn(txn, *i) && !isValidStatePathTxn(txn, *i) )
|
||||||
throw Error(format("Not a state or store path: ") % *i);
|
throw Error(format("Not a state or store path: ") % *i);
|
||||||
|
|
||||||
//if withState is false, we filter out all state paths
|
//if withState is false, we filter out all state paths
|
||||||
if( withComponents && !withState ){
|
if( withComponents && !withState ){
|
||||||
for (PathSet::iterator i = allPaths.begin(); i != allPaths.end(); ++i)
|
for (PathSet::iterator i = allPaths.begin(); i != allPaths.end(); ++i)
|
||||||
if ( store->isValidPath(*i) )
|
if ( isValidPathTxn(txn, *i) )
|
||||||
paths.insert(*i);
|
paths.insert(*i);
|
||||||
}
|
}
|
||||||
//if withComponents is false, we filter out all component paths
|
//if withComponents is false, we filter out all component paths
|
||||||
else if( !withComponents && withState ){
|
else if( !withComponents && withState ){
|
||||||
for (PathSet::iterator i = allPaths.begin(); i != allPaths.end(); ++i)
|
for (PathSet::iterator i = allPaths.begin(); i != allPaths.end(); ++i)
|
||||||
if ( store->isValidStatePath(*i) )
|
if ( isValidStatePathTxn(txn, *i) )
|
||||||
paths.insert(*i);
|
paths.insert(*i);
|
||||||
}
|
}
|
||||||
//all
|
//all
|
||||||
|
|
@ -49,7 +55,7 @@ void computeFSClosure(const Path & path, PathSet & paths, const bool & withCompo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void computeFSClosureRec(const Path & path, PathSet & paths, const int revision, const bool & flipDirection)
|
void computeFSClosureRecTxn(const Transaction & txn, const Path & path, PathSet & paths, const int revision, const bool & flipDirection)
|
||||||
{
|
{
|
||||||
if (paths.find(path) != paths.end()) return; //takes care of double entries
|
if (paths.find(path) != paths.end()) return; //takes care of double entries
|
||||||
|
|
||||||
|
|
@ -59,19 +65,19 @@ void computeFSClosureRec(const Path & path, PathSet & paths, const int revision,
|
||||||
PathSet stateReferences;
|
PathSet stateReferences;
|
||||||
|
|
||||||
if (flipDirection){
|
if (flipDirection){
|
||||||
store->queryReferrers(path, references, revision);
|
queryReferrersTxn(txn, path, references, revision);
|
||||||
store->queryStateReferrers(path, stateReferences, revision);
|
queryStateReferrersTxn(txn, path, stateReferences, revision);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
store->queryReferences(path, references, revision);
|
queryReferencesTxn(txn, path, references, revision);
|
||||||
store->queryStateReferences(path, stateReferences, revision);
|
queryStateReferencesTxn(txn, path, stateReferences, revision);
|
||||||
}
|
}
|
||||||
|
|
||||||
PathSet allReferences;
|
PathSet allReferences;
|
||||||
allReferences = pathSets_union(references, stateReferences);
|
allReferences = pathSets_union(references, stateReferences);
|
||||||
|
|
||||||
for (PathSet::iterator i = allReferences.begin(); i != allReferences.end(); ++i)
|
for (PathSet::iterator i = allReferences.begin(); i != allReferences.end(); ++i)
|
||||||
computeFSClosureRec(*i, paths, revision, flipDirection);
|
computeFSClosureRecTxn(txn, *i, paths, revision, flipDirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#define __MISC_H
|
#define __MISC_H
|
||||||
|
|
||||||
#include "derivations.hh"
|
#include "derivations.hh"
|
||||||
|
#include "db.hh"
|
||||||
|
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
@ -26,7 +27,9 @@ Derivation derivationFromPath(const Path & drvPath);
|
||||||
returned. */
|
returned. */
|
||||||
void computeFSClosure(const Path & storePath, PathSet & paths, const bool & withComponents, const bool & withState, const int revision, bool flipDirection = false);
|
void computeFSClosure(const Path & storePath, PathSet & paths, const bool & withComponents, const bool & withState, const int revision, bool flipDirection = false);
|
||||||
|
|
||||||
void computeFSClosureRec(const Path & path, PathSet & paths, const int revision, const bool & flipDirection); //TODO private
|
void computeFSClosureTxn(const Transaction & txn, const Path & storePath, PathSet & paths, const bool & withComponents, const bool & withState, const int revision, bool flipDirection = false);
|
||||||
|
|
||||||
|
void computeFSClosureRecTxn(const Transaction & txn, const Path & path, PathSet & paths, const int revision, const bool & flipDirection); //TODO private
|
||||||
|
|
||||||
/* Return the path corresponding to the output identifier `id' in the
|
/* Return the path corresponding to the output identifier `id' in the
|
||||||
given derivation. */
|
given derivation. */
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ void updateRevisionsRecursivelyTxn(const Transaction & txn, const Path & statePa
|
||||||
RevisionNumbersSet rivisionMapping;
|
RevisionNumbersSet rivisionMapping;
|
||||||
|
|
||||||
PathSet statePaths;
|
PathSet statePaths;
|
||||||
storePathRequisites(statePath, false, statePaths, false, true, -1); //Get all current state dependencies
|
storePathRequisitesTxn(txn, statePath, false, statePaths, false, true, -1); //Get all current state dependencies
|
||||||
|
|
||||||
//Add own statePath (may already be in there, but its a set, so no doubles)
|
//Add own statePath (may already be in there, but its a set, so no doubles)
|
||||||
statePaths.insert(statePath);
|
statePaths.insert(statePath);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue