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

before downscaling to 1 repos per statePath

This commit is contained in:
Wouter den Breejen 2007-07-08 19:58:16 +00:00
parent ca5fc7c582
commit cce4156232

View file

@ -74,7 +74,7 @@ Derivation getDerivation_andCheckArgs_(Strings opFlags, Strings opArgs, Path & c
//Strings progam_args_strings = tokenizeString(allArgs, " "); //Strings progam_args_strings = tokenizeString(allArgs, " ");
} }
printMsg(lvlError, format("'%1%' - '%2%' - '%3%' - '%4%' - '%5%'") % componentPath % stateIdentifier % binary % username % allArgs); //printMsg(lvlError, format("'%1%' - '%2%' - '%3%' - '%4%' - '%5%'") % componentPath % stateIdentifier % binary % username % allArgs);
if(isStatePath) if(isStatePath)
derivers = queryDerivers(noTxn, componentPath, stateIdentifier, username); derivers = queryDerivers(noTxn, componentPath, stateIdentifier, username);
@ -197,7 +197,7 @@ RevisionNumbers readRevisionNumbers(const Derivation & drv)
for (vector<Path>::const_iterator i = sorted_repositorys.begin(); i != sorted_repositorys.end(); ++i){ for (vector<Path>::const_iterator i = sorted_repositorys.begin(); i != sorted_repositorys.end(); ++i){
string repos = *i; string repos = *i;
printMsg(lvlError, format("%1%") % repos); //printMsg(lvlError, format("%1%") % repos);
if(IsDirectory(repos)){ if(IsDirectory(repos)){
Strings p_args; Strings p_args;
@ -224,12 +224,14 @@ RevisionNumbers readRevisionNumbers(const Derivation & drv)
* Input: store (or statePath?) * Input: store (or statePath?)
* Returns all the drv's of the statePaths (in)directly referenced. * Returns all the drv's of the statePaths (in)directly referenced.
*/ */
PathSet getAllStateDerivationsRecursively(const Path & storePath) PathSet getAllStateDerivationsRecursively(const Path & storePath, const int revision)
{ {
//Get recursively all state paths //Get recursively all state paths
PathSet statePaths; PathSet statePaths;
store->storePathRequisites(storePath, false, statePaths, false, true); store->storePathRequisites(storePath, false, statePaths, false, true);
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! include revision
//Find the matching drv with the statePath //Find the matching drv with the statePath
PathSet derivations; PathSet derivations;
for (PathSet::iterator i = statePaths.begin(); i != statePaths.end(); ++i) for (PathSet::iterator i = statePaths.begin(); i != statePaths.end(); ++i)
@ -275,10 +277,47 @@ static void revertToRevision(Strings opFlags, Strings opArgs)
bool recursive = true; //TODO !!!!!!!!! bool recursive = true; //TODO !!!!!!!!!
//get dependecies (if neccecary | recusively) of all state components that need to be updated //First, revert own statepath
PathSet root_drvs = getAllStateDerivationsRecursively(componentPath);
//Then, do the rest (if nessecary)
//revision_arg PathSet drvs;
if(recursive)
drvs = getAllStateDerivationsRecursively(componentPath, revision_arg); //get dependecies (if neccecary | recusively) of all state components that need to be updated
else
drvs.insert(derivationPath);
/*
for (PathSet::iterator d = drvs.begin(); d != drvs.end(); ++d)
{
Path drvPath = *d;
Derivation drv = derivationFromPath(drvPath);
DerivationStateOutputs stateOutputs = drv.stateOutputs;
Path statePath = stateOutputs.find("state")->second.statepath;
DerivationStateOutputDirs stateOutputDirs = drv.stateOutputDirs;
string drvName = drv.env.find("name")->second;
RevisionNumbersClosure getRivisionsClosure;
bool b = store->queryStateRevisions(statePath, getRivisionsClosure, revision_arg);
//sort
for (DerivationStateOutputDirs::const_reverse_iterator i = stateOutputDirs.rbegin(); i != stateOutputDirs.rend(); ++i){
DerivationStateOutputDir d = i->second;
string thisdir = d.path;
//Get the a repository for this state location
string repos = getStateReposPath("stateOutput:staterepospath", statePath, thisdir, drvName, stateIdentifier); //this is a copy from store-state.cc
Strings p_args;
p_args.push_back(nixSVNPath + "/svn");
p_args.push_back(int2String(revision_arg));
p_args.push_back("file://" + repos);
string output = runProgram(nixLibexecDir + "/nix/nix-restorerevision.sh", true, p_args); //run
}
}
*/
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
} }
@ -305,7 +344,7 @@ static void opRunComponent(Strings opFlags, Strings opArgs)
//svn lock ... ? //svn lock ... ?
//get dependecies (if neccecary | recusively) of all state components that need to be updated //get dependecies (if neccecary | recusively) of all state components that need to be updated
PathSet root_drvs = getAllStateDerivationsRecursively(root_componentPath); PathSet root_drvs = getAllStateDerivationsRecursively(root_componentPath, -1);
//TODO maybe also scan the parameters for state or component hashes? //TODO maybe also scan the parameters for state or component hashes?
//program_args //program_args
@ -323,7 +362,7 @@ static void opRunComponent(Strings opFlags, Strings opArgs)
map<Path, RevisionNumbers> rivisionsClosureMapping; map<Path, RevisionNumbers> rivisionsClosureMapping;
for (PathSet::iterator d = root_drvs.begin(); d != root_drvs.end(); ++d) for (PathSet::iterator d = root_drvs.begin(); d != root_drvs.end(); ++d) //TODO first commit own state path?
{ {
//Extract the neccecary info from each Drv //Extract the neccecary info from each Drv
Path drvPath = *d; Path drvPath = *d;