1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-26 12:10:59 +01:00

coputeFSClosure is now transactional, state will now be commited after the component has been build

This commit is contained in:
Wouter den Breejen 2007-07-12 15:59:16 +00:00
parent f3dabd6206
commit e33a1e4e74
6 changed files with 46 additions and 23 deletions

View file

@ -604,8 +604,8 @@ void Database::setStateRevisions(const Transaction & txn, TableId table,
sorted_revisions.push_back(revisions.at(*i));
//Debugging
//for (vector<Path>::const_iterator i = sortedStatePaths.begin(); i != sortedStatePaths.end(); ++i)
// printMsg(lvlError, format("Insert: %1% into %2%") % int2String(revisions.at(*i)) % *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);
//Convert the int's into Strings
Strings data;

View file

@ -594,7 +594,7 @@ void LocalStore::queryAllReferences(const Path & path, PathSet & allReferences,
queryAllReferencesTxn(noTxn, path, allReferences, revision);
}
void queryReferrers(const Transaction & txn,
void queryReferrersTxn(const Transaction & txn,
const Path & storePath, PathSet & referrers, const int revision)
{
if (!isRealisableComponentOrStatePath(txn, storePath))
@ -606,11 +606,11 @@ void queryReferrers(const Transaction & txn,
void LocalStore::queryReferrers(const Path & storePath,
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))
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)
{
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)
{
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) {
for (PathSet::iterator i = paths.begin();
@ -1632,15 +1637,15 @@ void storePathRequisites(const Path & storeOrstatePath, const bool includeOutput
Derivation drv = derivationFromPath(*i);
for (DerivationOutputs::iterator j = drv.outputs.begin();
j != drv.outputs.end(); ++j)
if (store->isValidPath(j->second.path))
computeFSClosure(j->second.path, paths, withComponents, withState, revision);
if (isValidPathTxn(txn, j->second.path))
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)
{
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)

View file

@ -225,12 +225,21 @@ bool isStateDrvTxn(const Transaction & txn, const Derivation & drv);
//TODO can this ?????
void queryAllValidPaths(const Transaction & txn, PathSet & allComponentPaths, PathSet & allStatePaths);
bool isValidStatePathTxn(const Transaction & txn, const Path & path);
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 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);
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);
bool isValidPathTxn(const Transaction & txn, const Path & path);
bool isValidStatePathTxn(const Transaction & txn, const Path & path);
}

View file

@ -1,6 +1,7 @@
#include "misc.hh"
#include "store-api.hh"
#include "db.hh"
#include "local-store.hh"
#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)
{
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;
computeFSClosureRec(path, allPaths, revision, flipDirection);
computeFSClosureRecTxn(txn, path, allPaths, revision, flipDirection);
if(!withComponents && !withState)
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 ..... ?????????????????????
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);
//if withState is false, we filter out all state paths
if( withComponents && !withState ){
for (PathSet::iterator i = allPaths.begin(); i != allPaths.end(); ++i)
if ( store->isValidPath(*i) )
if ( isValidPathTxn(txn, *i) )
paths.insert(*i);
}
//if withComponents is false, we filter out all component paths
else if( !withComponents && withState ){
for (PathSet::iterator i = allPaths.begin(); i != allPaths.end(); ++i)
if ( store->isValidStatePath(*i) )
if ( isValidStatePathTxn(txn, *i) )
paths.insert(*i);
}
//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
@ -59,19 +65,19 @@ void computeFSClosureRec(const Path & path, PathSet & paths, const int revision,
PathSet stateReferences;
if (flipDirection){
store->queryReferrers(path, references, revision);
store->queryStateReferrers(path, stateReferences, revision);
queryReferrersTxn(txn, path, references, revision);
queryStateReferrersTxn(txn, path, stateReferences, revision);
}
else{
store->queryReferences(path, references, revision);
store->queryStateReferences(path, stateReferences, revision);
queryReferencesTxn(txn, path, references, revision);
queryStateReferencesTxn(txn, path, stateReferences, revision);
}
PathSet allReferences;
allReferences = pathSets_union(references, stateReferences);
for (PathSet::iterator i = allReferences.begin(); i != allReferences.end(); ++i)
computeFSClosureRec(*i, paths, revision, flipDirection);
computeFSClosureRecTxn(txn, *i, paths, revision, flipDirection);
}

View file

@ -2,6 +2,7 @@
#define __MISC_H
#include "derivations.hh"
#include "db.hh"
namespace nix {
@ -26,7 +27,9 @@ Derivation derivationFromPath(const Path & drvPath);
returned. */
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
given derivation. */

View file

@ -202,7 +202,7 @@ void updateRevisionsRecursivelyTxn(const Transaction & txn, const Path & statePa
RevisionNumbersSet rivisionMapping;
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)
statePaths.insert(statePath);