From b46db4dea7e125fa2e0aa864a6ee4867056147ed Mon Sep 17 00:00:00 2001 From: Wouter den Breejen Date: Wed, 18 Jul 2007 11:19:41 +0000 Subject: [PATCH] --- src/libstore/build.cc | 4 ++-- src/libstore/references.cc | 35 +++++++++++++++++++++++++---------- src/libstore/references.hh | 9 ++++++++- src/nix-state/nix-state.cc | 4 ++-- 4 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/libstore/build.cc b/src/libstore/build.cc index a1089ee40..44a231bf7 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -1711,7 +1711,7 @@ void DerivationGoal::computeClosure() allReferences[path] = references; /* For this output path, find the state references to other paths contained in it. */ - PathSet output_state_references = scanForReferences(path, allStatePaths); + PathSet output_state_references = scanForStateReferences(path, allStatePaths); allStateReferences[path] = output_state_references; /* For debugging, print out the referenced and unreferenced @@ -1758,7 +1758,7 @@ void DerivationGoal::computeClosure() printMsg(lvlTalkative, format("scanning for component and state references inside `%1%'") % statePath); state_references = scanForReferences(statePath, allPaths); - state_stateReferences = scanForReferences(statePath, allStatePaths); + state_stateReferences = scanForStateReferences(statePath, allStatePaths); } /* Register each output path as valid, and register the sets of diff --git a/src/libstore/references.cc b/src/libstore/references.cc index 5d77362af..04f3b2bd9 100644 --- a/src/libstore/references.cc +++ b/src/libstore/references.cc @@ -118,13 +118,36 @@ void checkPath(const string & path, else throw Error(format("unknown file type: %1%") % path); } - PathSet scanForReferences(const string & path, const PathSet & paths) { return scanForReferencesTxn(noTxn, path, paths); } PathSet scanForReferencesTxn(const Transaction & txn, const Path & path, const PathSet & paths) +{ + return scanForReferencesTxn_(txn, path, paths); +} + +PathSet scanForStateReferences(const string & path, const PathSet & paths) +{ + return scanForStateReferencesTxn(noTxn, path, paths); +} + +PathSet scanForStateReferencesTxn(const Transaction & txn, const Path & path, const PathSet & paths) +{ + //Get the references from the scan + PathSet org_references = scanForReferencesTxn_(txn, path, paths); + + //Get the solid state dependencies, and also insert them + PathSet solidStateDeps; + querySolidStateReferencesTxn(txn, path, solidStateDeps); + org_references.insert(solidStateDeps.begin(), solidStateDeps.end()); + + return org_references; +} + + +PathSet scanForReferencesTxn_(const Transaction & txn, const Path & path, const PathSet & paths) { std::map backMap; StringSet ids; @@ -156,16 +179,8 @@ PathSet scanForReferencesTxn(const Transaction & txn, const Path & path, const P found.insert(j->second); } - //Get the solid state dependencies, and also insert them - PathSet solidStateDeps; - querySolidStateReferencesTxn(txn, path, solidStateDeps); - found.insert(solidStateDeps.begin(), solidStateDeps.end()); - - //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! we only scan the paths, if we scan for state references, this STORE path will show up !!!!!!!!!!!!!! - //TODO Create a scanForReferencesState() funtion wrapper !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - return found; } - + } diff --git a/src/libstore/references.hh b/src/libstore/references.hh index 580ef9f64..01529f457 100644 --- a/src/libstore/references.hh +++ b/src/libstore/references.hh @@ -6,10 +6,17 @@ namespace nix { +/* Scans for Component References (currently doesnt add solid dependencys) */ PathSet scanForReferences(const Path & path, const PathSet & refs); - PathSet scanForReferencesTxn(const Transaction & txn, const Path & path, const PathSet & refs); +/* Scans for State References and adds solid state dependencys*/ +PathSet scanForStateReferences(const Path & path, const PathSet & refs); +PathSet scanForStateReferencesTxn(const Transaction & txn, const Path & path, const PathSet & refs); + +/* The original scanForReferences */ +PathSet scanForReferencesTxn_(const Transaction & txn, const Path & path, const PathSet & refs); + } #endif /* !__REFERENCES_H */ diff --git a/src/nix-state/nix-state.cc b/src/nix-state/nix-state.cc index c0ddbd4cf..2c9d25596 100644 --- a/src/nix-state/nix-state.cc +++ b/src/nix-state/nix-state.cc @@ -310,8 +310,8 @@ void scanAndUpdateAllReferencesTxn(const Transaction & txn, const Path & statePa //TODO maybe only scan in the changeset (patch) for new references? (this will be difficult and depending on the underlying versioning system) //Scan in for (new) component and state references - PathSet state_references = scanForReferences(statePath, allComponentPaths2); //TODO - PathSet state_stateReferences = scanForReferences(statePath, allStatePaths); + PathSet state_references = scanForReferences(statePath, allComponentPaths2); + PathSet state_stateReferences = scanForStateReferences(statePath, allStatePaths); //Retrieve old references PathSet old_references;