mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 20:20:58 +01:00
Besides directorys, single files can now also be versioned (or excluded)
This commit is contained in:
parent
bc2fbabc12
commit
9257f16c85
5 changed files with 53 additions and 10 deletions
|
|
@ -513,7 +513,7 @@ void Database::setStateReferences(const Transaction & txn, TableId table,
|
|||
setStrings(txn, table, key, references);
|
||||
}
|
||||
|
||||
bool Database::lookupHighestRevivison(const Strings & keys, const Path & statePath, string & key)
|
||||
bool Database::lookupHighestRevivison(const Strings & keys, const Path & statePath, string & key, int lowerthan)
|
||||
{
|
||||
int highestRev = -1;
|
||||
|
||||
|
|
@ -527,8 +527,15 @@ bool Database::lookupHighestRevivison(const Strings & keys, const Path & statePa
|
|||
Path getStatePath;
|
||||
int getRevision;
|
||||
splitStatePathRevision(*i, getStatePath, getRevision);
|
||||
if(getRevision > highestRev)
|
||||
highestRev = getRevision;
|
||||
if(getRevision > highestRev){
|
||||
|
||||
if(lowerthan != -1){
|
||||
if(getRevision <= lowerthan) //if we have an uppper limit, see to it that we downt go over it
|
||||
highestRev = getRevision;
|
||||
}
|
||||
else
|
||||
highestRev = getRevision;
|
||||
}
|
||||
}
|
||||
|
||||
if(highestRev == -1) //no records found (TODO throw error?)
|
||||
|
|
@ -546,7 +553,7 @@ bool Database::queryStateReferences(const Transaction & txn, TableId table,
|
|||
Strings keys;
|
||||
enumTable(txn, table, keys); //get all revisions
|
||||
|
||||
//Check if this revision exists key in the table
|
||||
//Check if this revision exists key in the table, if it doesnt well find the highest key lower than it
|
||||
string key = makeStatePathRevision(statePath, revision);
|
||||
bool found = false;
|
||||
for (Strings::const_iterator i = keys.begin(); i != keys.end(); ++i) {
|
||||
|
|
@ -554,12 +561,17 @@ bool Database::queryStateReferences(const Transaction & txn, TableId table,
|
|||
found = true;
|
||||
}
|
||||
|
||||
key = ""; //reset
|
||||
if(revision == -1 || (!found)){
|
||||
key = "";
|
||||
if(revision == -1){
|
||||
bool foundsomething = lookupHighestRevivison(keys, statePath, key);
|
||||
if(!foundsomething)
|
||||
return false;
|
||||
}
|
||||
else if(!found){
|
||||
bool foundsomething = lookupHighestRevivison(keys, statePath, key, -1);
|
||||
if(!foundsomething)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
key = makeStatePathRevision(statePath, revision);
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ private:
|
|||
void open2(const string & path, bool removeOldEnv);
|
||||
|
||||
/* TODO */
|
||||
bool lookupHighestRevivison(const Strings & keys, const Path & statePath, string & key);
|
||||
bool lookupHighestRevivison(const Strings & keys, const Path & statePath, string & key, int lowerthan = -1);
|
||||
|
||||
/* TODO */
|
||||
int getNewRevisionNumber(const Transaction & txn, TableId table, const Path & statePath);
|
||||
|
|
|
|||
|
|
@ -69,8 +69,13 @@ void createStateDirs(const DerivationStateOutputDirs & stateOutputDirs, const De
|
|||
DerivationStateOutputDir d = i->second;
|
||||
|
||||
string thisdir = d.path;
|
||||
|
||||
//Check if it is a file
|
||||
if(thisdir.substr(thisdir.length() -1 , thisdir.length()) != "/")
|
||||
continue;
|
||||
|
||||
Path fullstatedir = stateDir + "/" + thisdir;
|
||||
|
||||
|
||||
Strings p_args;
|
||||
p_args.push_back("-p");
|
||||
p_args.push_back(fullstatedir);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue