1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-26 20:20:58 +01:00
This commit is contained in:
Wouter den Breejen 2007-08-14 17:34:45 +00:00
parent 4089bd5f19
commit 5a9cfdeb6e
11 changed files with 128 additions and 37 deletions

View file

@ -658,7 +658,10 @@ void Database::setStateRevisions(const Transaction & txn, TableId revisions_tabl
//save the date and comments
Strings metadata;
metadata.push_back(int2String(ts));
if(statePath == rootStatePath)
//get all paths that point to the same state (using shareing) and check if one of them equals the rootStatePath
PathSet sharedWith = getSharedWithPathSetRecTxn(txn, statePath);
if(statePath == rootStatePath || sharedWith.find(rootStatePath) != sharedWith.end())
metadata.push_back(comment);
else
metadata.push_back("Part of the snashot closure for " + rootStatePath);

View file

@ -10,7 +10,6 @@ namespace nix {
string nixStore = "/UNINIT";
string nixStoreState = "/UNINIT";
string nixStoreStateRepos = "/UNINIT";
string nixDataDir = "/UNINIT";
string nixLogDir = "/UNINIT";
string nixStateDir = "/UNINIT";

View file

@ -21,9 +21,6 @@ extern string nixLogDir;
/* nixStoreState is the directory where the state dirs of the components are stored. */
extern string nixStoreState;
/* nixStoreState is the directory where the repositorys of the state dirs of the components are stored. */
extern string nixStoreStateRepos;
/* nixStateDir is the directory where state is stored. */
extern string nixStateDir;

View file

@ -1776,6 +1776,48 @@ void setStateStateReferencesTxn(const Transaction & txn, const Path & statePath,
nixDB.setStateReferences(txn, dbStateStateReferences, dbStateRevisions, statePath, references, revision, timestamp);
}
//Lookups which statePaths directy share (point to) statePath
PathSet getSharedWithPathSetTxn(const Transaction & txn, const Path & statePath)
{
PathSet statePaths;
//enumtable
Strings keys;
nixDB.enumTable(txn, dbSharedState, keys);
for (Strings::iterator i = keys.begin(); i != keys.end(); ++i){
Path shared_with;
nixDB.queryString(txn, dbSharedState, *i, shared_with);
if (shared_with == statePath)
statePaths.insert(*i);
}
return statePaths;
}
PathSet getSharedWithPathSetRecTxn_private(const Transaction & txn, const Path & statePath, PathSet & statePaths)
{
//Get all paths pointing to statePath
PathSet newStatePaths = getSharedWithPathSetTxn(txn, statePath);
//go into recursion to see if there are more paths indirectly pointing to statePath
for (PathSet::iterator i = newStatePaths.begin(); i != newStatePaths.end(); ++i)
//Only recurse on the really new statePaths to prevent infinite recursion
if(statePaths.find(*i) == statePaths.end())
statePaths = pathSets_union(statePaths, getSharedWithPathSetRecTxn_private(txn, *i, statePaths));
return statePaths;
}
//Note: Also returns statePath in the PathSet
PathSet getSharedWithPathSetRecTxn(const Transaction & txn, const Path & statePath)
{
//To no shared state path
Path statePath_ns = toNonSharedPathTxn(txn, statePath);
PathSet empty;
return getSharedWithPathSetRecTxn_private(txn, statePath_ns, empty);
}
/* Upgrade from schema 1 (Nix <= 0.7) to schema 2 (Nix >= 0.8). */
static void upgradeStore07()

View file

@ -242,6 +242,7 @@ bool querySolidStateReferencesTxn(const Transaction & txn, const Path & statePat
void setSharedStateTxn(const Transaction & txn, const Path & fromExisting, const Path & toNew);
PathSet toNonSharedPathSetTxn(const Transaction & txn, const PathSet & statePaths);
Path toNonSharedPathTxn(const Transaction & txn, const Path & statePath);
PathSet getSharedWithPathSetRecTxn(const Transaction & txn, const Path & statePath);
}