mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 04:00:59 +01:00
downscaled to 1 repos per statePath
This commit is contained in:
parent
cce4156232
commit
9f00b42f38
19 changed files with 218 additions and 399 deletions
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
debug=""; #set to "" for no debugging, set to "echo " to debug the commands
|
debug=""; #set to "" for no debugging, set to "echo " to debug the commands
|
||||||
|
|
||||||
if [ "$#" != 5 ] && [ "$#" != 6 ] ; then
|
if [ "$#" != 6 ] && [ "$#" != 7 ] ; then
|
||||||
echo "Incorrect number of arguments"
|
echo "Incorrect number of arguments"
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
@ -19,8 +19,9 @@ svnbin=$1
|
||||||
subversionedpaths=( $2 ) #arrays
|
subversionedpaths=( $2 ) #arrays
|
||||||
subversionedpathsCommitBools=( $3 )
|
subversionedpathsCommitBools=( $3 )
|
||||||
nonversionedpaths=( $4 )
|
nonversionedpaths=( $4 )
|
||||||
checkouts=( $5 )
|
checkout=$5
|
||||||
deletesvn=$6 #this flag can be set to 1 to DELETE all .svn folders and NOT commit
|
statepath=$6
|
||||||
|
deletesvn=$7 #this flag can be set to 1 to DELETE all .svn folders and NOT commit
|
||||||
|
|
||||||
|
|
||||||
if [ "$debug" != "" ] ; then
|
if [ "$debug" != "" ] ; then
|
||||||
|
|
@ -28,7 +29,8 @@ if [ "$debug" != "" ] ; then
|
||||||
echo subversionedpaths: ${subversionedpaths[@]}
|
echo subversionedpaths: ${subversionedpaths[@]}
|
||||||
echo subversionedpathsCommitBools: ${subversionedpathsCommitBools[@]}
|
echo subversionedpathsCommitBools: ${subversionedpathsCommitBools[@]}
|
||||||
echo nonversionedpaths: ${nonversionedpaths[@]}
|
echo nonversionedpaths: ${nonversionedpaths[@]}
|
||||||
echo checkouts: ${checkouts[@]}
|
echo checkouts: $checkout
|
||||||
|
echo statepath: $statepath
|
||||||
echo deletesvn: $deletesvn
|
echo deletesvn: $deletesvn
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -46,9 +48,9 @@ function subversionSingleStateDir {
|
||||||
empty=$(ls)
|
empty=$(ls)
|
||||||
|
|
||||||
if [ "$empty" = "" ] ; then
|
if [ "$empty" = "" ] ; then
|
||||||
allsubitems=(); #no subfiles / dirs
|
allsubitems=(); #no subfiles / dirs
|
||||||
else
|
else
|
||||||
allsubitems=( $(echo *) $(echo .*) ) #there are subfiles / dirs,also adds hidden items
|
allsubitems=( $(echo *) $(echo .*) ) #there are subfiles / dirs,also adds hidden items
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for subitem in ${allsubitems[@]}
|
for subitem in ${allsubitems[@]}
|
||||||
|
|
@ -128,39 +130,28 @@ function subversionSingleStateDir {
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
|
if ! test -d "${statepath}/.svn/"; then #if the dir exists but is not yet an svn dir: checkout repos, if it doenst exits (is removed or something) than we dont do anything
|
||||||
|
if [ "$deletesvn" != "1" ]; then
|
||||||
|
$debug $checkout;
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
i=0
|
i=0
|
||||||
i_checkout=0
|
|
||||||
for path in ${subversionedpaths[@]}
|
for path in ${subversionedpaths[@]}
|
||||||
do
|
do
|
||||||
if test -d $path; then #if the dir doesnt exist, than we dont hav to do anything
|
if test -d $path; then #if the dir doesnt exist, than we dont hav to do anything
|
||||||
cd $path;
|
cd $path;
|
||||||
|
|
||||||
checkoutcommand=""; #HACK: I cant seem to find a way for bash to parse a 2 dimensional string array as argument, so we use a 1-d array with '|' as seperator
|
|
||||||
while true; do
|
|
||||||
if [ "${checkouts[$i_checkout]}" = "|" ]; then
|
|
||||||
let "i_checkout+=1"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
checkoutcommand="${checkoutcommand} ${checkouts[$i_checkout]}";
|
|
||||||
let "i_checkout+=1"
|
|
||||||
done
|
|
||||||
|
|
||||||
if ! test -d "${path}.svn/"; then #if the dir exists but is not yet an svn dir: checkout repos, if it doenst exits (is removed or something) than we dont do anything
|
|
||||||
if [ "$deletesvn" != "1" ]; then
|
|
||||||
$debug $checkoutcommand;
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${subversionedpathsCommitBools[$i]}" = "true" ]; then #Check if we need to commit this folder
|
if [ "${subversionedpathsCommitBools[$i]}" = "true" ]; then #Check if we need to commit this folder
|
||||||
|
|
||||||
echo "Entering $path"
|
echo "Entering $path"
|
||||||
|
|
||||||
subversionSingleStateDir $path;
|
if ! test -d "${path}/.svn/"; then #Also add yourself if nessecary
|
||||||
|
if [ "$deletesvn" != "1" ]; then
|
||||||
|
$debug svn -N add $path
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
cd $path #now that everything is added we go back to the 'root' path and commit
|
subversionSingleStateDir $path;
|
||||||
if [ "$deletesvn" != "1" ]; then
|
|
||||||
$debug svn -m "" commit;
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd - &> /dev/null;
|
cd - &> /dev/null;
|
||||||
|
|
@ -168,7 +159,8 @@ do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
cd $statepath #now that everything is added we go back to the 'root' path and commit
|
||||||
|
if [ "$deletesvn" != "1" ]; then
|
||||||
|
$debug svn -m "" commit;
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
debug=""; #set to "" for no debugging, set to "echo " to debug the commands
|
debug=""; #set to "" for no debugging, set to "echo " to debug the commands
|
||||||
|
|
||||||
if [ "$#" != 5 ] && [ "$#" != 6 ] ; then
|
if [ "$#" != 6 ] && [ "$#" != 7 ] ; then
|
||||||
echo "Incorrect number of arguments"
|
echo "Incorrect number of arguments"
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
@ -19,8 +19,9 @@ svnbin=$1
|
||||||
subversionedpaths=( $2 ) #arrays
|
subversionedpaths=( $2 ) #arrays
|
||||||
subversionedpathsCommitBools=( $3 )
|
subversionedpathsCommitBools=( $3 )
|
||||||
nonversionedpaths=( $4 )
|
nonversionedpaths=( $4 )
|
||||||
checkouts=( $5 )
|
checkout=$5
|
||||||
deletesvn=$6 #this flag can be set to 1 to DELETE all .svn folders and NOT commit
|
statepath=$6
|
||||||
|
deletesvn=$7 #this flag can be set to 1 to DELETE all .svn folders and NOT commit
|
||||||
|
|
||||||
|
|
||||||
if [ "$debug" != "" ] ; then
|
if [ "$debug" != "" ] ; then
|
||||||
|
|
@ -28,7 +29,8 @@ if [ "$debug" != "" ] ; then
|
||||||
echo subversionedpaths: ${subversionedpaths[@]}
|
echo subversionedpaths: ${subversionedpaths[@]}
|
||||||
echo subversionedpathsCommitBools: ${subversionedpathsCommitBools[@]}
|
echo subversionedpathsCommitBools: ${subversionedpathsCommitBools[@]}
|
||||||
echo nonversionedpaths: ${nonversionedpaths[@]}
|
echo nonversionedpaths: ${nonversionedpaths[@]}
|
||||||
echo checkouts: ${checkouts[@]}
|
echo checkouts: $checkout
|
||||||
|
echo statepath: $statepath
|
||||||
echo deletesvn: $deletesvn
|
echo deletesvn: $deletesvn
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -46,9 +48,9 @@ function subversionSingleStateDir {
|
||||||
empty=$(ls)
|
empty=$(ls)
|
||||||
|
|
||||||
if [ "$empty" = "" ] ; then
|
if [ "$empty" = "" ] ; then
|
||||||
allsubitems=(); #no subfiles / dirs
|
allsubitems=(); #no subfiles / dirs
|
||||||
else
|
else
|
||||||
allsubitems=( $(echo *) $(echo .*) ) #there are subfiles / dirs,also adds hidden items
|
allsubitems=( $(echo *) $(echo .*) ) #there are subfiles / dirs,also adds hidden items
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for subitem in ${allsubitems[@]}
|
for subitem in ${allsubitems[@]}
|
||||||
|
|
@ -128,39 +130,28 @@ function subversionSingleStateDir {
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
|
if ! test -d "${statepath}/.svn/"; then #if the dir exists but is not yet an svn dir: checkout repos, if it doenst exits (is removed or something) than we dont do anything
|
||||||
|
if [ "$deletesvn" != "1" ]; then
|
||||||
|
$debug $checkout;
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
i=0
|
i=0
|
||||||
i_checkout=0
|
|
||||||
for path in ${subversionedpaths[@]}
|
for path in ${subversionedpaths[@]}
|
||||||
do
|
do
|
||||||
if test -d $path; then #if the dir doesnt exist, than we dont hav to do anything
|
if test -d $path; then #if the dir doesnt exist, than we dont hav to do anything
|
||||||
cd $path;
|
cd $path;
|
||||||
|
|
||||||
checkoutcommand=""; #HACK: I cant seem to find a way for bash to parse a 2 dimensional string array as argument, so we use a 1-d array with '|' as seperator
|
|
||||||
while true; do
|
|
||||||
if [ "${checkouts[$i_checkout]}" = "|" ]; then
|
|
||||||
let "i_checkout+=1"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
checkoutcommand="${checkoutcommand} ${checkouts[$i_checkout]}";
|
|
||||||
let "i_checkout+=1"
|
|
||||||
done
|
|
||||||
|
|
||||||
if ! test -d "${path}.svn/"; then #if the dir exists but is not yet an svn dir: checkout repos, if it doenst exits (is removed or something) than we dont do anything
|
|
||||||
if [ "$deletesvn" != "1" ]; then
|
|
||||||
$debug $checkoutcommand;
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${subversionedpathsCommitBools[$i]}" = "true" ]; then #Check if we need to commit this folder
|
if [ "${subversionedpathsCommitBools[$i]}" = "true" ]; then #Check if we need to commit this folder
|
||||||
|
|
||||||
echo "Entering $path"
|
echo "Entering $path"
|
||||||
|
|
||||||
subversionSingleStateDir $path;
|
if ! test -d "${path}/.svn/"; then #Also add yourself if nessecary
|
||||||
|
if [ "$deletesvn" != "1" ]; then
|
||||||
|
$debug svn -N add $path
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
cd $path #now that everything is added we go back to the 'root' path and commit
|
subversionSingleStateDir $path;
|
||||||
if [ "$deletesvn" != "1" ]; then
|
|
||||||
$debug svn -m "" commit;
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd - &> /dev/null;
|
cd - &> /dev/null;
|
||||||
|
|
@ -168,7 +159,8 @@ do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
cd $statepath #now that everything is added we go back to the 'root' path and commit
|
||||||
|
if [ "$deletesvn" != "1" ]; then
|
||||||
|
$debug svn -m "" commit;
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -485,6 +485,7 @@ static Expr prim_derivationStrict(EvalState & state, const ATermVector & args)
|
||||||
|
|
||||||
dir.path = s;
|
dir.path = s;
|
||||||
}
|
}
|
||||||
|
else if (statekey == "file") { dir.path = s; }
|
||||||
else if (statekey == "type") { dir.type = s; }
|
else if (statekey == "type") { dir.type = s; }
|
||||||
else if (statekey == "interval") {
|
else if (statekey == "interval") {
|
||||||
if(s == "")
|
if(s == "")
|
||||||
|
|
|
||||||
|
|
@ -1200,7 +1200,7 @@ DerivationGoal::HookReply DerivationGoal::tryBuildHook()
|
||||||
*probably* already has it.) */
|
*probably* already has it.) */
|
||||||
PathSet allInputs;
|
PathSet allInputs;
|
||||||
allInputs.insert(inputPaths.begin(), inputPaths.end());
|
allInputs.insert(inputPaths.begin(), inputPaths.end());
|
||||||
computeFSClosure(drvPath, allInputs, true, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
computeFSClosure(drvPath, allInputs, true, false, -1); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
||||||
|
|
||||||
string s;
|
string s;
|
||||||
for (PathSet::iterator i = allInputs.begin();
|
for (PathSet::iterator i = allInputs.begin();
|
||||||
|
|
@ -1323,8 +1323,8 @@ bool DerivationGoal::prepareBuild()
|
||||||
Derivation inDrv = derivationFromPath(i->first);
|
Derivation inDrv = derivationFromPath(i->first);
|
||||||
for (StringSet::iterator j = i->second.begin(); j != i->second.end(); ++j)
|
for (StringSet::iterator j = i->second.begin(); j != i->second.end(); ++j)
|
||||||
if (inDrv.outputs.find(*j) != inDrv.outputs.end()){
|
if (inDrv.outputs.find(*j) != inDrv.outputs.end()){
|
||||||
computeFSClosure(inDrv.outputs[*j].path, inputPaths, true, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE (done?)
|
computeFSClosure(inDrv.outputs[*j].path, inputPaths, true, false, -1); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE (done?)
|
||||||
computeFSClosure(inDrv.outputs[*j].path, inputStatePaths, false, true); //TODO!!!!!!!!!!!!! HOW CAN THESE PATHS ALREADY BE VALID ..... ?????????????????????
|
computeFSClosure(inDrv.outputs[*j].path, inputStatePaths, false, true, -1); //TODO!!!!!!!!!!!!! HOW CAN THESE PATHS ALREADY BE VALID ..... ?????????????????????
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw BuildError(
|
throw BuildError(
|
||||||
|
|
@ -1334,8 +1334,8 @@ bool DerivationGoal::prepareBuild()
|
||||||
|
|
||||||
/* Second, the input sources. */
|
/* Second, the input sources. */
|
||||||
for (PathSet::iterator i = drv.inputSrcs.begin(); i != drv.inputSrcs.end(); ++i){
|
for (PathSet::iterator i = drv.inputSrcs.begin(); i != drv.inputSrcs.end(); ++i){
|
||||||
computeFSClosure(*i, inputPaths, true, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE (done?)
|
computeFSClosure(*i, inputPaths, true, false, -1); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE (done?)
|
||||||
computeFSClosure(*i, inputStatePaths, false, true);
|
computeFSClosure(*i, inputStatePaths, false, true, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
debug(format("added input paths %1%") % showPaths(inputPaths));
|
debug(format("added input paths %1%") % showPaths(inputPaths));
|
||||||
|
|
@ -1463,7 +1463,7 @@ void DerivationGoal::startBuilder()
|
||||||
|
|
||||||
/* Write closure info to `fileName'. */
|
/* Write closure info to `fileName'. */
|
||||||
PathSet refs;
|
PathSet refs;
|
||||||
computeFSClosure(storePath, refs, true, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
computeFSClosure(storePath, refs, true, false, -1); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO COPY STATE
|
||||||
/* !!! in secure Nix, the writing should be done on the
|
/* !!! in secure Nix, the writing should be done on the
|
||||||
build uid for security (maybe). */
|
build uid for security (maybe). */
|
||||||
writeStringToFile(tmpDir + "/" + fileName,
|
writeStringToFile(tmpDir + "/" + fileName,
|
||||||
|
|
|
||||||
|
|
@ -555,40 +555,6 @@ bool Database::queryStateReferences(const Transaction & txn, TableId table,
|
||||||
else
|
else
|
||||||
key = makeStatePathRevision(statePath, revision);
|
key = makeStatePathRevision(statePath, revision);
|
||||||
|
|
||||||
/*
|
|
||||||
///////////////?!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! create function
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// TODO
|
|
||||||
string key = ""; //final key that matches revision + statePath
|
|
||||||
int highestRev = -1;
|
|
||||||
|
|
||||||
//Lookup which key we need
|
|
||||||
for (Strings::iterator i = keys.begin(); i != keys.end(); ++i) {
|
|
||||||
Path getStatePath_org = *i;
|
|
||||||
Path getStatePath;
|
|
||||||
int getRevision;
|
|
||||||
splitStatePathRevision(*i, getStatePath, getRevision);
|
|
||||||
|
|
||||||
if(getStatePath == statePath){
|
|
||||||
|
|
||||||
if(revision == -1){ //the user wants the last revision
|
|
||||||
if(getRevision > highestRev)
|
|
||||||
highestRev = getRevision;
|
|
||||||
}
|
|
||||||
else if(revision == getRevision){
|
|
||||||
key = getStatePath_org;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
if(key == "" && highestRev == -1) //no records found (TODO throw error?)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if(revision == -1)
|
|
||||||
key = makeStatePathRevision(statePath, highestRev);
|
|
||||||
*/
|
|
||||||
|
|
||||||
return queryStrings(txn, table, key, references); //now that we have the key, we can query the references
|
return queryStrings(txn, table, key, references); //now that we have the key, we can query the references
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -610,15 +576,15 @@ bool Database::queryStateReferrers(const Transaction & txn, TableId table,
|
||||||
|
|
||||||
|
|
||||||
void Database::setStateRevisions(const Transaction & txn, TableId table,
|
void Database::setStateRevisions(const Transaction & txn, TableId table,
|
||||||
const Path & statePath, const RevisionNumbersSetClosure & revisions, int revision)
|
const Path & statePath, const RevisionNumbersSet & revisions, int revision)
|
||||||
{
|
{
|
||||||
if(revision == -1)
|
if(revision == -1)
|
||||||
revision = getNewRevisionNumber(txn, table, statePath);
|
revision = getNewRevisionNumber(txn, table, statePath);
|
||||||
|
|
||||||
//Sort based on statePath to RevisionNumbersClosure
|
//Sort based on statePath to RevisionNumbersClosure
|
||||||
RevisionNumbersClosure sorted_revisions;
|
RevisionNumbers sorted_revisions;
|
||||||
vector<Path> sortedStatePaths;
|
vector<Path> sortedStatePaths;
|
||||||
for (RevisionNumbersSetClosure::const_iterator i = revisions.begin(); i != revisions.end(); ++i)
|
for (RevisionNumbersSet::const_iterator i = revisions.begin(); i != revisions.end(); ++i)
|
||||||
sortedStatePaths.push_back((*i).first);
|
sortedStatePaths.push_back((*i).first);
|
||||||
sort(sortedStatePaths.begin(), sortedStatePaths.end());
|
sort(sortedStatePaths.begin(), sortedStatePaths.end());
|
||||||
for (vector<Path>::const_iterator i = sortedStatePaths.begin(); i != sortedStatePaths.end(); ++i)
|
for (vector<Path>::const_iterator i = sortedStatePaths.begin(); i != sortedStatePaths.end(); ++i)
|
||||||
|
|
@ -626,22 +592,16 @@ void Database::setStateRevisions(const Transaction & txn, TableId table,
|
||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
for (vector<Path>::const_iterator i = sortedStatePaths.begin(); i != sortedStatePaths.end(); ++i){
|
for (vector<Path>::const_iterator i = sortedStatePaths.begin(); i != sortedStatePaths.end(); ++i){
|
||||||
printMsg(lvlError, format("Insert: %1%") % *i);
|
printMsg(lvlError, format("Insert: %1% into %2%") % int2String(revisions.at(*i)) % *i);
|
||||||
for (RevisionNumbers::const_iterator e = (revisions.at(*i)).begin(); e != (revisions.at(*i)).end(); ++e)
|
|
||||||
printMsg(lvlError, format("Rev: %1%") % *e);
|
|
||||||
}
|
}
|
||||||
//////////////////
|
//////////////////
|
||||||
|
|
||||||
//Pack the data into Strings
|
//Convert the int's into Strings
|
||||||
const string seperator = "|";
|
|
||||||
Strings data;
|
Strings data;
|
||||||
for (RevisionNumbersClosure::const_iterator i = sorted_revisions.begin(); i != sorted_revisions.end(); ++i) {
|
for (RevisionNumbers::const_iterator i = sorted_revisions.begin(); i != sorted_revisions.end(); ++i) {
|
||||||
RevisionNumbers revisionNumbers = *i;
|
int revisionnumber = *i;
|
||||||
string packedNumbers = "";
|
data.push_back(int2String(revisionnumber));
|
||||||
for (RevisionNumbers::iterator j = revisionNumbers.begin(); j != revisionNumbers.end(); ++j)
|
|
||||||
packedNumbers += int2String(*j) + seperator;
|
|
||||||
packedNumbers = packedNumbers.substr(0, packedNumbers.length()-1); //remove the last |
|
|
||||||
data.push_back(packedNumbers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Create the key
|
//Create the key
|
||||||
|
|
@ -652,10 +612,8 @@ void Database::setStateRevisions(const Transaction & txn, TableId table,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Database::queryStateRevisions(const Transaction & txn, TableId table,
|
bool Database::queryStateRevisions(const Transaction & txn, TableId table,
|
||||||
const Path & statePath, RevisionNumbersClosure & revisions, int revision)
|
const Path & statePath, RevisionNumbers & revisions, int revision)
|
||||||
{
|
{
|
||||||
const string seperator = "|";
|
|
||||||
|
|
||||||
Strings keys;
|
Strings keys;
|
||||||
enumTable(txn, table, keys); //get all revisions
|
enumTable(txn, table, keys); //get all revisions
|
||||||
|
|
||||||
|
|
@ -668,55 +626,17 @@ bool Database::queryStateRevisions(const Transaction & txn, TableId table,
|
||||||
else
|
else
|
||||||
key = makeStatePathRevision(statePath, revision);
|
key = makeStatePathRevision(statePath, revision);
|
||||||
|
|
||||||
/*
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
string key = ""; //final key that matches revision + statePath
|
|
||||||
int highestRev = -1;
|
|
||||||
|
|
||||||
//Lookup which key we need
|
|
||||||
for (Strings::iterator i = keys.begin(); i != keys.end(); ++i) {
|
|
||||||
Path getStatePath_org = *i;
|
|
||||||
Path getStatePath;
|
|
||||||
int getRevision;
|
|
||||||
splitStatePathRevision(*i, getStatePath, getRevision);
|
|
||||||
|
|
||||||
if(getStatePath == statePath){
|
|
||||||
|
|
||||||
if(revision == -1){ //the user wants the last revision
|
|
||||||
if(getRevision > highestRev)
|
|
||||||
highestRev = getRevision;
|
|
||||||
}
|
|
||||||
else if(revision == getRevision){
|
|
||||||
key = getStatePath_org;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
if(key == "" && highestRev == -1) //no records found (TODO throw error?)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if(revision == -1)
|
|
||||||
key = makeStatePathRevision(statePath, highestRev);
|
|
||||||
*/
|
|
||||||
|
|
||||||
Strings data;
|
Strings data;
|
||||||
bool succeed = queryStrings(txn, table, key, data); //now that we have the key, we can query the references
|
bool succeed = queryStrings(txn, table, key, data); //now that we have the key, we can query the references
|
||||||
|
|
||||||
//Unpack Strings into RevisionNumbersClosure
|
//Convert the Strings into int's
|
||||||
for (Strings::iterator i = data.begin(); i != data.end(); ++i){
|
for (Strings::iterator i = data.begin(); i != data.end(); ++i){
|
||||||
RevisionNumbers revisionsGroup;
|
string getRevisionS = *i;
|
||||||
string packedNumbers = *i;
|
int getRevision;
|
||||||
Strings tokens = tokenizeString(packedNumbers, seperator);
|
bool succeed = string2Int(getRevisionS, getRevision);
|
||||||
for (Strings::iterator j = tokens.begin(); j != tokens.end(); ++j){
|
if(!succeed)
|
||||||
int getRevision;
|
throw Error(format("Cannot read revision number from db of path '%1%'") % statePath);
|
||||||
bool succeed = string2Int(*j, getRevision);
|
revisions.push_back(getRevision);
|
||||||
if(!succeed)
|
|
||||||
throw Error(format("Cannot read revision number from db of path '%1%'") % statePath);
|
|
||||||
revisionsGroup.push_back(getRevision);
|
|
||||||
}
|
|
||||||
revisions.push_back(revisionsGroup);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return succeed;
|
return succeed;
|
||||||
|
|
|
||||||
|
|
@ -117,11 +117,11 @@ public:
|
||||||
|
|
||||||
/* Set the revision number of the statePath and the revision numbers of all state paths in the references closure */
|
/* Set the revision number of the statePath and the revision numbers of all state paths in the references closure */
|
||||||
void setStateRevisions(const Transaction & txn, TableId table,
|
void setStateRevisions(const Transaction & txn, TableId table,
|
||||||
const Path & statePath, const RevisionNumbersSetClosure & revisions, int revision = -1);
|
const Path & statePath, const RevisionNumbersSet & revisions, int revision = -1);
|
||||||
|
|
||||||
/* Returns all the revision numbers of the state references closure of the given state path */
|
/* Returns all the revision numbers of the state references closure of the given state path */
|
||||||
bool queryStateRevisions(const Transaction & txn, TableId table,
|
bool queryStateRevisions(const Transaction & txn, TableId table,
|
||||||
const Path & statePath, RevisionNumbersClosure & revisions, int revision = -1);
|
const Path & statePath, RevisionNumbers & revisions, int revision = -1);
|
||||||
|
|
||||||
/* Returns all available revision numbers of the given state path */
|
/* Returns all available revision numbers of the given state path */
|
||||||
bool queryAvailableStateRevisions(const Transaction & txn, TableId table,
|
bool queryAvailableStateRevisions(const Transaction & txn, TableId table,
|
||||||
|
|
|
||||||
|
|
@ -469,7 +469,7 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
||||||
roots under the `references' relation. */
|
roots under the `references' relation. */
|
||||||
PathSet livePaths;
|
PathSet livePaths;
|
||||||
for (PathSet::const_iterator i = roots.begin(); i != roots.end(); ++i)
|
for (PathSet::const_iterator i = roots.begin(); i != roots.end(); ++i)
|
||||||
computeFSClosure(canonPath(*i), livePaths, true, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO DELETE STATE??
|
computeFSClosure(canonPath(*i), livePaths, true, false, -1); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO DELETE STATE??
|
||||||
|
|
||||||
if (gcKeepDerivations) {
|
if (gcKeepDerivations) {
|
||||||
for (PathSet::iterator i = livePaths.begin();
|
for (PathSet::iterator i = livePaths.begin();
|
||||||
|
|
@ -480,7 +480,7 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
||||||
turned off). */
|
turned off). */
|
||||||
Path deriver = queryDeriver(noTxn, *i);
|
Path deriver = queryDeriver(noTxn, *i);
|
||||||
if (deriver != "" && store->isValidPath(deriver))
|
if (deriver != "" && store->isValidPath(deriver))
|
||||||
computeFSClosure(deriver, livePaths, true, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO KEEP STATE
|
computeFSClosure(deriver, livePaths, true, false, -1); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO KEEP STATE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -493,7 +493,7 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
||||||
for (DerivationOutputs::iterator j = drv.outputs.begin();
|
for (DerivationOutputs::iterator j = drv.outputs.begin();
|
||||||
j != drv.outputs.end(); ++j)
|
j != drv.outputs.end(); ++j)
|
||||||
if (store->isValidPath(j->second.path))
|
if (store->isValidPath(j->second.path))
|
||||||
computeFSClosure(j->second.path, livePaths, true, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO KEEP STATE
|
computeFSClosure(j->second.path, livePaths, true, false, -1); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO KEEP STATE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -518,7 +518,7 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
||||||
PathSet tempRootsClosed;
|
PathSet tempRootsClosed;
|
||||||
for (PathSet::iterator i = tempRoots.begin(); i != tempRoots.end(); ++i)
|
for (PathSet::iterator i = tempRoots.begin(); i != tempRoots.end(); ++i)
|
||||||
if (store->isValidPath(*i))
|
if (store->isValidPath(*i))
|
||||||
computeFSClosure(*i, tempRootsClosed, true, false); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO .... STATE
|
computeFSClosure(*i, tempRootsClosed, true, false, -1); //TODO !!!!!!!!!!!!!!!!!!!!!!!!!!! WE (MAY) ALSO NEED TO .... STATE
|
||||||
else
|
else
|
||||||
tempRootsClosed.insert(*i);
|
tempRootsClosed.insert(*i);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ static TableId dbStateCounters = 0;
|
||||||
*/
|
*/
|
||||||
static TableId dbStateInfo = 0;
|
static TableId dbStateInfo = 0;
|
||||||
|
|
||||||
/* dbStateRevisions :: StatePath -> RevisionNumbersClosure
|
/* dbStateRevisions :: StatePath -> RevisionNumbers
|
||||||
|
|
||||||
This table lists the statepaths + recursive (indirect) references and the revision numbers of their repositorys
|
This table lists the statepaths + recursive (indirect) references and the revision numbers of their repositorys
|
||||||
|
|
||||||
|
|
@ -1491,7 +1491,7 @@ void setStatePathsInterval(const PathSet & statePaths, const vector<int> & inter
|
||||||
int n=0;
|
int n=0;
|
||||||
for (PathSet::iterator i = statePaths.begin(); i != statePaths.end(); ++i)
|
for (PathSet::iterator i = statePaths.begin(); i != statePaths.end(); ++i)
|
||||||
{
|
{
|
||||||
printMsg(lvlError, format("Set interval of PATH: %1%") % *i);
|
//printMsg(lvlError, format("Set interval of PATH: %1%") % *i);
|
||||||
|
|
||||||
int interval=0;
|
int interval=0;
|
||||||
if(!allZero)
|
if(!allZero)
|
||||||
|
|
@ -1597,9 +1597,11 @@ PathSet mergeNewDerivationIntoList(const Path & storepath, const Path & newdrv,
|
||||||
|
|
||||||
TODO Change comment, this can also take state paths
|
TODO Change comment, this can also take state paths
|
||||||
*/
|
*/
|
||||||
void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState)
|
void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision)
|
||||||
{
|
{
|
||||||
computeFSClosure(storeOrstatePath, paths, withComponents, withState);
|
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
|
computeFSClosure(storeOrstatePath, paths, withComponents, withState, revision);
|
||||||
|
|
||||||
if (includeOutputs) {
|
if (includeOutputs) {
|
||||||
for (PathSet::iterator i = paths.begin();
|
for (PathSet::iterator i = paths.begin();
|
||||||
|
|
@ -1609,14 +1611,14 @@ void storePathRequisites(const Path & storeOrstatePath, const bool includeOutput
|
||||||
for (DerivationOutputs::iterator j = drv.outputs.begin();
|
for (DerivationOutputs::iterator j = drv.outputs.begin();
|
||||||
j != drv.outputs.end(); ++j)
|
j != drv.outputs.end(); ++j)
|
||||||
if (store->isValidPath(j->second.path))
|
if (store->isValidPath(j->second.path))
|
||||||
computeFSClosure(j->second.path, paths, withComponents, withState);
|
computeFSClosure(j->second.path, paths, withComponents, withState, revision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalStore::storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState)
|
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);
|
return nix::storePathRequisites(storeOrstatePath, includeOutputs, paths, withComponents, withState, revision);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -1768,7 +1770,6 @@ void scanAndUpdateAllReferencesTxn(const Transaction & txn, const Path & statePa
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//update all revision numbers (transaction) NEW FUN THAT UPDATES THE REVISIONS
|
//update all revision numbers (transaction) NEW FUN THAT UPDATES THE REVISIONS
|
||||||
//update all revision numbers + references (transaction)
|
//update all revision numbers + references (transaction)
|
||||||
//update all references
|
//update all references
|
||||||
|
|
@ -1796,9 +1797,9 @@ void LocalStore::scanAndUpdateAllReferences(const Path & statePath)
|
||||||
|
|
||||||
void scanAndUpdateAllReferencesRecusively(const Transaction & txn, const Path & storeOrStatePath) //TODO Can also work for statePaths???
|
void scanAndUpdateAllReferencesRecusively(const Transaction & txn, const Path & storeOrStatePath) //TODO Can also work for statePaths???
|
||||||
{
|
{
|
||||||
//get all state references recursively
|
//get all state current state references recursively
|
||||||
PathSet statePaths;
|
PathSet statePaths;
|
||||||
storePathRequisites(storeOrStatePath, false, statePaths, false, true); //TODO CAN THIS ???
|
storePathRequisites(storeOrStatePath, false, statePaths, false, true, -1); //TODO CAN THIS ???
|
||||||
|
|
||||||
//call scanForAllReferences again on all newly found statePaths
|
//call scanForAllReferences again on all newly found statePaths
|
||||||
for (PathSet::iterator i = statePaths.begin(); i != statePaths.end(); ++i)
|
for (PathSet::iterator i = statePaths.begin(); i != statePaths.end(); ++i)
|
||||||
|
|
@ -1820,22 +1821,22 @@ void LocalStore::scanAndUpdateAllReferencesRecusively(const Path & storeOrStateP
|
||||||
return nix::scanAndUpdateAllReferencesRecusively(noTxn, storeOrStatePath);
|
return nix::scanAndUpdateAllReferencesRecusively(noTxn, storeOrStatePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setStateRevisions(const Transaction & txn, const Path & statePath, const RevisionNumbersSetClosure & revisions, const int revision)
|
void setStateRevisions(const Transaction & txn, const Path & statePath, const RevisionNumbersSet & revisions, const int revision)
|
||||||
{
|
{
|
||||||
nixDB.setStateRevisions(txn, dbStateRevisions, statePath, revisions, revision);
|
nixDB.setStateRevisions(txn, dbStateRevisions, statePath, revisions, revision);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalStore::setStateRevisions(const Path & statePath, const RevisionNumbersSetClosure & revisions, const int revision)
|
void LocalStore::setStateRevisions(const Path & statePath, const RevisionNumbersSet & revisions, const int revision)
|
||||||
{
|
{
|
||||||
nix::setStateRevisions(noTxn, statePath, revisions, revision);
|
nix::setStateRevisions(noTxn, statePath, revisions, revision);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool queryStateRevisions(const Transaction & txn, const Path & statePath, RevisionNumbersClosure & revisions, const int revision)
|
bool queryStateRevisions(const Transaction & txn, const Path & statePath, RevisionNumbers & revisions, const int revision)
|
||||||
{
|
{
|
||||||
return nixDB.queryStateRevisions(txn, dbStateRevisions, statePath, revisions, revision);
|
return nixDB.queryStateRevisions(txn, dbStateRevisions, statePath, revisions, revision);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LocalStore::queryStateRevisions(const Path & statePath, RevisionNumbersClosure & revisions, const int revision)
|
bool LocalStore::queryStateRevisions(const Path & statePath, RevisionNumbers & revisions, const int revision)
|
||||||
{
|
{
|
||||||
return nix::queryStateRevisions(noTxn, statePath, revisions, revision);
|
return nix::queryStateRevisions(noTxn, statePath, revisions, revision);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -96,15 +96,15 @@ public:
|
||||||
|
|
||||||
bool isStateDrv(const Derivation & drv);
|
bool isStateDrv(const Derivation & drv);
|
||||||
|
|
||||||
void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState);
|
void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision);
|
||||||
|
|
||||||
void scanAndUpdateAllReferences(const Path & statePath);
|
void scanAndUpdateAllReferences(const Path & statePath);
|
||||||
|
|
||||||
void scanAndUpdateAllReferencesRecusively(const Path & storeOrstatePath);
|
void scanAndUpdateAllReferencesRecusively(const Path & storeOrstatePath);
|
||||||
|
|
||||||
void setStateRevisions(const Path & statePath, const RevisionNumbersSetClosure & revisions, const int revision);
|
void setStateRevisions(const Path & statePath, const RevisionNumbersSet & revisions, const int revision);
|
||||||
|
|
||||||
bool queryStateRevisions(const Path & statePath, RevisionNumbersClosure & revisions, const int revision);
|
bool queryStateRevisions(const Path & statePath, RevisionNumbers & revisions, const int revision);
|
||||||
|
|
||||||
bool queryAvailableStateRevisions(const Path & statePath, RevisionNumbers & revisions);
|
bool queryAvailableStateRevisions(const Path & statePath, RevisionNumbers & revisions);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,18 +11,18 @@ namespace nix {
|
||||||
Derivation derivationFromPath(const Path & drvPath)
|
Derivation derivationFromPath(const Path & drvPath)
|
||||||
{
|
{
|
||||||
assertStorePath(drvPath);
|
assertStorePath(drvPath);
|
||||||
printMsg(lvlError, format("tttttttttttttttttt"));
|
//printMsg(lvlError, format("tttttttttttttttttt"));
|
||||||
store->ensurePath(drvPath);
|
store->ensurePath(drvPath);
|
||||||
printMsg(lvlError, format("uuuuuuuuuuuuuuuuuu"));
|
//printMsg(lvlError, format("uuuuuuuuuuuuuuuuuu"));
|
||||||
ATerm t = ATreadFromNamedFile(drvPath.c_str());
|
ATerm t = ATreadFromNamedFile(drvPath.c_str());
|
||||||
if (!t) throw Error(format("cannot read aterm from `%1%'") % drvPath);
|
if (!t) throw Error(format("cannot read aterm from `%1%'") % drvPath);
|
||||||
return parseDerivation(t);
|
return parseDerivation(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void computeFSClosure(const Path & path, PathSet & paths, const bool & withComponents, const bool & withState, bool flipDirection)
|
void computeFSClosure(const Path & path, PathSet & paths, const bool & withComponents, const bool & withState, const int revision, bool flipDirection)
|
||||||
{
|
{
|
||||||
PathSet allPaths;
|
PathSet allPaths;
|
||||||
computeFSClosureRec(path, allPaths, flipDirection);
|
computeFSClosureRec(path, allPaths, revision, flipDirection);
|
||||||
|
|
||||||
if(!withComponents && !withState)
|
if(!withComponents && !withState)
|
||||||
throw Error(format("Useless call to computeFSClosure, at leat withComponents or withState must be true"));
|
throw Error(format("Useless call to computeFSClosure, at leat withComponents or withState must be true"));
|
||||||
|
|
@ -50,7 +50,7 @@ void computeFSClosure(const Path & path, PathSet & paths, const bool & withCompo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void computeFSClosureRec(const Path & path, PathSet & paths, const bool & flipDirection)
|
void computeFSClosureRec(const Path & path, PathSet & paths, const int revision, const bool & flipDirection)
|
||||||
{
|
{
|
||||||
if (paths.find(path) != paths.end()) return; //takes care of double entries
|
if (paths.find(path) != paths.end()) return; //takes care of double entries
|
||||||
|
|
||||||
|
|
@ -60,19 +60,19 @@ void computeFSClosureRec(const Path & path, PathSet & paths, const bool & flipDi
|
||||||
PathSet stateReferences;
|
PathSet stateReferences;
|
||||||
|
|
||||||
if (flipDirection){
|
if (flipDirection){
|
||||||
store->queryReferrers(path, references, -1);
|
store->queryReferrers(path, references, revision);
|
||||||
store->queryStateReferrers(path, stateReferences, -1);
|
store->queryStateReferrers(path, stateReferences, revision);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
store->queryReferences(path, references, -1);
|
store->queryReferences(path, references, revision);
|
||||||
store->queryStateReferences(path, stateReferences, -1);
|
store->queryStateReferences(path, stateReferences, revision);
|
||||||
}
|
}
|
||||||
|
|
||||||
PathSet allReferences;
|
PathSet allReferences;
|
||||||
allReferences = pathSets_union(references, stateReferences);
|
allReferences = pathSets_union(references, stateReferences);
|
||||||
|
|
||||||
for (PathSet::iterator i = allReferences.begin(); i != allReferences.end(); ++i)
|
for (PathSet::iterator i = allReferences.begin(); i != allReferences.end(); ++i)
|
||||||
computeFSClosureRec(*i, paths, flipDirection);
|
computeFSClosureRec(*i, paths, revision, flipDirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,9 @@ Derivation derivationFromPath(const Path & drvPath);
|
||||||
We can currentky only compute the closure of the latsest revision!
|
We can currentky only compute the closure of the latsest revision!
|
||||||
|
|
||||||
returned. */
|
returned. */
|
||||||
void computeFSClosure(const Path & storePath, PathSet & paths, const bool & withComponents, const bool & withState, bool flipDirection = false);
|
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 bool & flipDirection); //private
|
void computeFSClosureRec(const Path & path, PathSet & paths, const int revision, const bool & flipDirection); //TODO private
|
||||||
|
|
||||||
/* Return the path corresponding to the output identifier `id' in the
|
/* Return the path corresponding to the output identifier `id' in the
|
||||||
given derivation. */
|
given derivation. */
|
||||||
|
|
|
||||||
|
|
@ -457,7 +457,7 @@ bool RemoteStore::isStateDrv(const Derivation & drv)
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
void RemoteStore::storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState)
|
void RemoteStore::storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -475,13 +475,13 @@ void RemoteStore::scanAndUpdateAllReferencesRecusively(const Path & storeOrstate
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
void RemoteStore::setStateRevisions(const Path & statePath, const RevisionNumbersSetClosure & revisions, const int revision)
|
void RemoteStore::setStateRevisions(const Path & statePath, const RevisionNumbersSet & revisions, const int revision)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
bool RemoteStore::queryStateRevisions(const Path & statePath, RevisionNumbersClosure & revisions, const int revision)
|
bool RemoteStore::queryStateRevisions(const Path & statePath, RevisionNumbers & revisions, const int revision)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -84,15 +84,15 @@ public:
|
||||||
|
|
||||||
bool isStateDrv(const Derivation & drv);
|
bool isStateDrv(const Derivation & drv);
|
||||||
|
|
||||||
void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState);
|
void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision);
|
||||||
|
|
||||||
void scanAndUpdateAllReferences(const Path & statePath);
|
void scanAndUpdateAllReferences(const Path & statePath);
|
||||||
|
|
||||||
void scanAndUpdateAllReferencesRecusively(const Path & storeOrstatePath);
|
void scanAndUpdateAllReferencesRecusively(const Path & storeOrstatePath);
|
||||||
|
|
||||||
void setStateRevisions(const Path & statePath, const RevisionNumbersSetClosure & revisions, const int revision);
|
void setStateRevisions(const Path & statePath, const RevisionNumbersSet & revisions, const int revision);
|
||||||
|
|
||||||
bool queryStateRevisions(const Path & statePath, RevisionNumbersClosure & revisions, const int revision);
|
bool queryStateRevisions(const Path & statePath, RevisionNumbers & revisions, const int revision);
|
||||||
|
|
||||||
bool queryAvailableStateRevisions(const Path & statePath, RevisionNumbers & revisions);
|
bool queryAvailableStateRevisions(const Path & statePath, RevisionNumbers & revisions);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -153,18 +153,11 @@ void checkStatePath(const Derivation & drv)
|
||||||
Error(format("The statepath from the Derivation does not match the recalculated statepath, are u trying to spoof the statepath?"));
|
Error(format("The statepath from the Derivation does not match the recalculated statepath, are u trying to spoof the statepath?"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void calculateStateReposPath(const string & type, const Path statePath, const string subfolder, const string & suffix, const string & stateIdentifier, Path & rootPath, Path & fullPath)
|
void calculateStateReposPath(const string & type, const Path statePath, const string & suffix, const string & stateIdentifier, Path & path)
|
||||||
{
|
{
|
||||||
//This is a little trick: we could use the same hash as the statepath, but we change it so the repository also gets a unique scannable hash
|
//This is a little trick: we could use the same hash as the statepath, but we change it so the repository also gets a unique scannable hash
|
||||||
Hash hash = hashString(htSHA256, statePath);
|
Hash hash = hashString(htSHA256, statePath);
|
||||||
|
|
||||||
//We also hash repository subfolders the prevent collisions
|
|
||||||
if(subfolder.length() == 0)
|
|
||||||
throw Error(format("Cannot create a repository for a subfolder without a name"));
|
|
||||||
|
|
||||||
string hash_subfolder = type + ":sha256:" + printHash(hash) + ":" + subfolder;
|
|
||||||
string subfolder2 = printHash32(compressHash(hashString(htSHA256, hash_subfolder), 20)) + "-" + subfolder;
|
|
||||||
|
|
||||||
string suffix_stateIdentifier = stateIdentifier;
|
string suffix_stateIdentifier = stateIdentifier;
|
||||||
if(suffix_stateIdentifier != "")
|
if(suffix_stateIdentifier != "")
|
||||||
suffix_stateIdentifier = "-" + suffix_stateIdentifier;
|
suffix_stateIdentifier = "-" + suffix_stateIdentifier;
|
||||||
|
|
@ -176,28 +169,18 @@ void calculateStateReposPath(const string & type, const Path statePath, const st
|
||||||
checkStoreName(suffix);
|
checkStoreName(suffix);
|
||||||
checkStoreName(stateIdentifier);
|
checkStoreName(stateIdentifier);
|
||||||
|
|
||||||
rootPath = nixStoreStateRepos + "/"
|
path = nixStoreStateRepos + "/"
|
||||||
+ printHash32(compressHash(hashString(htSHA256, s), 20))
|
+ printHash32(compressHash(hashString(htSHA256, s), 20))
|
||||||
+ "-" + suffix + suffix_stateIdentifier;
|
+ "-" + suffix + suffix_stateIdentifier + "/";
|
||||||
|
|
||||||
fullPath = rootPath + "/" + subfolder2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Path getStateReposPath(const string & type, const Path statePath, const string subfolder, const string & suffix, const string & stateIdentifier)
|
Path getStateReposPath(const string & type, const Path statePath, const string & suffix, const string & stateIdentifier)
|
||||||
{
|
{
|
||||||
Path fullPath;
|
Path path;
|
||||||
Path rootPath;
|
calculateStateReposPath(type, statePath, suffix, stateIdentifier, path);
|
||||||
calculateStateReposPath(type, statePath, subfolder, suffix, stateIdentifier, rootPath, fullPath);
|
return path;
|
||||||
return fullPath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Path getStateReposRootPath(const string & type, const Path statePath, const string & suffix, const string & stateIdentifier)
|
|
||||||
{
|
|
||||||
Path fullPath;
|
|
||||||
Path rootPath;
|
|
||||||
calculateStateReposPath(type, statePath, "/", suffix, stateIdentifier, rootPath, fullPath);
|
|
||||||
return rootPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
Path makeFixedOutputPath(bool recursive,
|
Path makeFixedOutputPath(bool recursive,
|
||||||
string hashAlgo, Hash hash, string name)
|
string hashAlgo, Hash hash, string name)
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ public:
|
||||||
virtual bool isStateDrv(const Derivation & drv) = 0;
|
virtual bool isStateDrv(const Derivation & drv) = 0;
|
||||||
|
|
||||||
/* TODO */
|
/* TODO */
|
||||||
virtual void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState) = 0;
|
virtual void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision) = 0;
|
||||||
|
|
||||||
/* TODO */
|
/* TODO */
|
||||||
virtual void scanAndUpdateAllReferences(const Path & statePath) = 0;
|
virtual void scanAndUpdateAllReferences(const Path & statePath) = 0;
|
||||||
|
|
@ -224,10 +224,10 @@ public:
|
||||||
virtual void scanAndUpdateAllReferencesRecusively(const Path & storeOrstatePath) = 0;
|
virtual void scanAndUpdateAllReferencesRecusively(const Path & storeOrstatePath) = 0;
|
||||||
|
|
||||||
/* TODO */
|
/* TODO */
|
||||||
virtual void setStateRevisions(const Path & statePath, const RevisionNumbersSetClosure & revisions, const int revision) = 0;
|
virtual void setStateRevisions(const Path & statePath, const RevisionNumbersSet & revisions, const int revision) = 0;
|
||||||
|
|
||||||
/* TODO */
|
/* TODO */
|
||||||
virtual bool queryStateRevisions(const Path & statePath, RevisionNumbersClosure & revisions, const int revision) = 0;
|
virtual bool queryStateRevisions(const Path & statePath, RevisionNumbers & revisions, const int revision) = 0;
|
||||||
|
|
||||||
/* TODO */
|
/* TODO */
|
||||||
virtual bool queryAvailableStateRevisions(const Path & statePath, RevisionNumbers & revisions) = 0;
|
virtual bool queryAvailableStateRevisions(const Path & statePath, RevisionNumbers & revisions) = 0;
|
||||||
|
|
@ -268,13 +268,11 @@ Path makeStatePath(const string & componentHash, const string & suffix, const st
|
||||||
void checkStatePath(const Derivation & drv);
|
void checkStatePath(const Derivation & drv);
|
||||||
|
|
||||||
/* Calculates a unique store state repos path and also the root path */
|
/* Calculates a unique store state repos path and also the root path */
|
||||||
void calculateStateReposPath(const string & type, const Path statePath, const string subfolder, const string & suffix, const string & stateIdentifier, Path & rootPath, Path & fullPath);
|
void calculateStateReposPath(const string & type, const Path statePath, const string & suffix, const string & stateIdentifier, Path & path);
|
||||||
|
|
||||||
|
|
||||||
/* Returns the full repository path */
|
/* Returns the full repository path */
|
||||||
Path getStateReposPath(const string & type, const Path statePath, const string subfolder, const string & suffix, const string & stateIdentifier);
|
Path getStateReposPath(const string & type, const Path statePath, const string & suffix, const string & stateIdentifier);
|
||||||
|
|
||||||
/* Returns the root path containing the repository's */
|
|
||||||
Path getStateReposRootPath(const string & type, const Path statePath, const string & suffix, const string & stateIdentifier);
|
|
||||||
|
|
||||||
/* This is the preparatory part of addToStore() and addToStoreFixed();
|
/* This is the preparatory part of addToStore() and addToStoreFixed();
|
||||||
it computes the store path to which srcPath is to be copied.
|
it computes the store path to which srcPath is to be copied.
|
||||||
|
|
|
||||||
|
|
@ -37,72 +37,54 @@ void createStateDirs(const DerivationStateOutputDirs & stateOutputDirs, const De
|
||||||
|
|
||||||
PathSet intervalPaths;
|
PathSet intervalPaths;
|
||||||
|
|
||||||
//Make sure the 'root' path which holds the repositorys exists, so svn doenst complain.
|
//check if we can create state and staterepos dirs
|
||||||
string repos_root_path = getStateReposRootPath("stateOutput:staterepospath", stateDir, drvName, stateIdentifier);
|
//TODO
|
||||||
|
|
||||||
Strings p_args;
|
//Create a repository for this state location
|
||||||
p_args.push_back("-p");
|
string repos = getStateReposPath("stateOutput:staterepospath", stateDir, drvName, stateIdentifier);
|
||||||
p_args.push_back(repos_root_path);
|
|
||||||
runProgram_AndPrintOutput("mkdir", true, p_args, "mkdir");
|
|
||||||
|
|
||||||
|
printMsg(lvlTalkative, format("Adding statedir '%1%' from repository '%2%'") % stateDir % repos);
|
||||||
|
|
||||||
//TODO check if we can create state and staterepos dirs
|
if(IsDirectory(repos))
|
||||||
|
printMsg(lvlTalkative, format("Repos %1% already exists, so we use that repository") % repos);
|
||||||
|
else{
|
||||||
|
Strings p_args;
|
||||||
|
p_args.push_back("create");
|
||||||
|
p_args.push_back(repos);
|
||||||
|
runProgram_AndPrintOutput(svnadminbin, true, p_args, "svnadmin"); //TODO create as nixbld.nixbld chmod 700... can you still commit then ??
|
||||||
|
}
|
||||||
|
|
||||||
|
string statedir_svn = stateDir + "/.svn/";
|
||||||
|
if( ! IsDirectory(statedir_svn) ){
|
||||||
|
Strings p_args;
|
||||||
|
p_args.push_back("checkout");
|
||||||
|
p_args.push_back("file://" + repos);
|
||||||
|
p_args.push_back(stateDir);
|
||||||
|
runProgram_AndPrintOutput(svnbin, true, p_args, "svn"); //TODO checkout as user
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printMsg(lvlTalkative, format("Statedir %1% already exists, so dont check out its repository again") % statedir_svn);
|
||||||
|
|
||||||
for (DerivationStateOutputDirs::const_reverse_iterator i = stateOutputDirs.rbegin(); i != stateOutputDirs.rend(); ++i){
|
for (DerivationStateOutputDirs::const_reverse_iterator i = stateOutputDirs.rbegin(); i != stateOutputDirs.rend(); ++i){
|
||||||
DerivationStateOutputDir d = i->second;
|
DerivationStateOutputDir d = i->second;
|
||||||
|
|
||||||
string thisdir = d.path;
|
string thisdir = d.path;
|
||||||
string fullstatedir = stateDir + "/" + thisdir;
|
Path fullstatedir = stateDir + "/" + thisdir;
|
||||||
Path statePath = fullstatedir; //TODO call coerce function
|
|
||||||
|
|
||||||
//Check if and how this dir needs to be versioned
|
Strings p_args;
|
||||||
if(d.type == "none"){
|
p_args.push_back("-p");
|
||||||
Strings p_args;
|
p_args.push_back(fullstatedir);
|
||||||
p_args.push_back("-p");
|
runProgram_AndPrintOutput("mkdir", true, p_args, "mkdir");
|
||||||
p_args.push_back(fullstatedir);
|
|
||||||
runProgram_AndPrintOutput("mkdir", true, p_args, "mkdir");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Create a repository for this state location
|
|
||||||
string repos = getStateReposPath("stateOutput:staterepospath", stateDir, thisdir, drvName, stateIdentifier);
|
|
||||||
|
|
||||||
|
|
||||||
if(IsDirectory(repos))
|
|
||||||
printMsg(lvlTalkative, format("Repos %1% already exists, so we use that repository") % repos);
|
|
||||||
else{
|
|
||||||
Strings p_args;
|
|
||||||
p_args.push_back("create");
|
|
||||||
p_args.push_back(repos);
|
|
||||||
runProgram_AndPrintOutput(svnadminbin, true, p_args, "svnadmin"); //TODO create as nixbld.nixbld chmod 700... can you still commit then ??
|
|
||||||
}
|
|
||||||
|
|
||||||
if(d.type == "interval"){
|
if(d.type == "interval"){
|
||||||
intervalPaths.insert(statePath);
|
intervalPaths.insert(fullstatedir);
|
||||||
}
|
}
|
||||||
|
|
||||||
printMsg(lvlTalkative, format("Adding state subdir: %1% to %2% from repository %3%") % thisdir % fullstatedir % repos);
|
|
||||||
|
|
||||||
string fullstatedir_svn = fullstatedir + "/.svn/";
|
|
||||||
if( ! IsDirectory(fullstatedir_svn) ){
|
|
||||||
Strings p_args;
|
|
||||||
p_args.push_back("checkout");
|
|
||||||
p_args.push_back("file://" + repos);
|
|
||||||
p_args.push_back(fullstatedir);
|
|
||||||
runProgram_AndPrintOutput(svnbin, true, p_args, "svn"); //TODO checkout as user
|
|
||||||
}
|
|
||||||
else
|
|
||||||
printMsg(lvlTalkative, format("Statedir %1% already exists, so dont check out its repository again") % fullstatedir_svn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Initialize the counters for the statePaths that have an interval to 0
|
//Initialize the counters for the statePaths that have an interval to 0
|
||||||
vector<int> empty;
|
vector<int> empty;
|
||||||
store->setStatePathsInterval(intervalPaths, empty, true);
|
store->setStatePathsInterval(intervalPaths, empty, true);
|
||||||
|
|
||||||
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
|
|
||||||
//Initialize the revisions recursively
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,14 +60,9 @@ typedef set<Path> PathSet;
|
||||||
|
|
||||||
//state types
|
//state types
|
||||||
typedef list<int> RevisionNumbers; //the Strings (list) of StateReferences and this list are connected by position
|
typedef list<int> RevisionNumbers; //the Strings (list) of StateReferences and this list are connected by position
|
||||||
typedef map<Path, RevisionNumbers> RevisionNumbersSetClosure; //We include to the paths to sort on
|
typedef map<Path, int> RevisionNumbersSet; //We include to the paths to sort on
|
||||||
typedef list<RevisionNumbers> RevisionNumbersClosure;
|
|
||||||
typedef map<int, Strings> StateReferences;
|
typedef map<int, Strings> StateReferences;
|
||||||
|
|
||||||
//typedef std::map<int, Strings> StateReferencesKey;
|
|
||||||
//typedef std::map<int, Strings> StateReferencesKey2;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
lvlError,
|
lvlError,
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ static void opShowStatePath(Strings opFlags, Strings opArgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Prints the root path that contains the repoisitorys of the state of a component - indetiefier combination
|
//Prints the root path that contains the repoisitorys of the state of a component - indetiefier combination
|
||||||
static void opShowStateReposRootPath(Strings opFlags, Strings opArgs)
|
static void opShowStateReposPath(Strings opFlags, Strings opArgs)
|
||||||
{
|
{
|
||||||
Path componentPath;
|
Path componentPath;
|
||||||
Path statePath;
|
Path statePath;
|
||||||
|
|
@ -166,12 +166,12 @@ static void opShowStateReposRootPath(Strings opFlags, Strings opArgs)
|
||||||
|
|
||||||
//Get the a repository for this state location
|
//Get the a repository for this state location
|
||||||
string drvName = drv.env.find("name")->second;
|
string drvName = drv.env.find("name")->second;
|
||||||
string repos = getStateReposPath("stateOutput:staterepospath", statePath, "/", drvName, stateIdentifier); //this is a copy from store-state.cc
|
string repos = getStateReposPath("stateOutput:staterepospath", statePath, drvName, stateIdentifier); //this is a copy from store-state.cc
|
||||||
|
|
||||||
printMsg(lvlError, format("%1%") % repos);
|
printMsg(lvlError, format("%1%") % repos);
|
||||||
}
|
}
|
||||||
|
|
||||||
RevisionNumbers readRevisionNumbers(const Derivation & drv)
|
int readRevisionNumber(const Derivation & drv)
|
||||||
{
|
{
|
||||||
string svnbin = nixSVNPath + "/svn";
|
string svnbin = nixSVNPath + "/svn";
|
||||||
RevisionNumbers revisions;
|
RevisionNumbers revisions;
|
||||||
|
|
@ -182,42 +182,22 @@ RevisionNumbers readRevisionNumbers(const Derivation & drv)
|
||||||
Path statePath = stateOutputs.find("state")->second.statepath;
|
Path statePath = stateOutputs.find("state")->second.statepath;
|
||||||
string getStateIdentifier = stateOutputs.find("state")->second.stateIdentifier;
|
string getStateIdentifier = stateOutputs.find("state")->second.stateIdentifier;
|
||||||
|
|
||||||
//TODO sort based on the repository
|
string repos = getStateReposPath("stateOutput:staterepospath", statePath, drvName, getStateIdentifier); //this is a copy from store-state.cc
|
||||||
vector<Path> sorted_repositorys;
|
|
||||||
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, getStateIdentifier); //this is a copy from store-state.cc
|
|
||||||
sorted_repositorys.push_back(repos);
|
|
||||||
}
|
|
||||||
sort(sorted_repositorys.begin(), sorted_repositorys.end());
|
|
||||||
|
|
||||||
//After the sort read the paths
|
Strings p_args;
|
||||||
for (vector<Path>::const_iterator i = sorted_repositorys.begin(); i != sorted_repositorys.end(); ++i){
|
p_args.push_back(svnbin);
|
||||||
string repos = *i;
|
p_args.push_back("file://" + repos);
|
||||||
|
string output = runProgram(nixLibexecDir + "/nix/nix-readrevisions.sh", true, p_args); //run
|
||||||
|
|
||||||
//printMsg(lvlError, format("%1%") % repos);
|
int pos = output.find("\n",0); //remove trailing \n
|
||||||
|
output.erase(pos,1);
|
||||||
|
|
||||||
if(IsDirectory(repos)){
|
int revision;
|
||||||
Strings p_args;
|
bool succeed = string2Int(output, revision);
|
||||||
p_args.push_back(svnbin);
|
if(!succeed)
|
||||||
p_args.push_back("file://" + repos);
|
throw Error(format("Cannot read revision number of path '%1%'") % repos);
|
||||||
string output = runProgram(nixLibexecDir + "/nix/nix-readrevisions.sh", true, p_args); //run
|
|
||||||
|
|
||||||
int pos = output.find("\n",0); //remove trailing \n
|
return revision;
|
||||||
output.erase(pos,1);
|
|
||||||
|
|
||||||
int revision;
|
|
||||||
bool succeed = string2Int(output, revision);
|
|
||||||
if(!succeed)
|
|
||||||
throw Error(format("Cannot read revision number of path '%1%'") % repos);
|
|
||||||
revisions.push_back(revision); //insert into array
|
|
||||||
}
|
|
||||||
else
|
|
||||||
revisions.push_back(-1);
|
|
||||||
}
|
|
||||||
return revisions;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -228,9 +208,7 @@ PathSet getAllStateDerivationsRecursively(const Path & storePath, const int revi
|
||||||
{
|
{
|
||||||
//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, revision);
|
||||||
|
|
||||||
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! include revision
|
|
||||||
|
|
||||||
//Find the matching drv with the statePath
|
//Find the matching drv with the statePath
|
||||||
PathSet derivations;
|
PathSet derivations;
|
||||||
|
|
@ -259,10 +237,12 @@ static void queryAvailableStateRevisions(Strings opFlags, Strings opArgs)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string revisions_txt="";
|
||||||
for (RevisionNumbers::iterator i = revisions.begin(); i != revisions.end(); ++i)
|
for (RevisionNumbers::iterator i = revisions.begin(); i != revisions.end(); ++i)
|
||||||
{
|
{
|
||||||
printMsg(lvlError, format("Available Revision: %1%") % int2String(*i));
|
revisions_txt += int2String(*i) + " ";
|
||||||
}
|
}
|
||||||
|
printMsg(lvlError, format("Available Revisions: %1%") % revisions_txt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void revertToRevision(Strings opFlags, Strings opArgs)
|
static void revertToRevision(Strings opFlags, Strings opArgs)
|
||||||
|
|
@ -275,51 +255,35 @@ static void revertToRevision(Strings opFlags, Strings opArgs)
|
||||||
string program_args;
|
string program_args;
|
||||||
Derivation drv = getDerivation_andCheckArgs(opFlags, opArgs, componentPath, statePath, binary, derivationPath, isStatePath, program_args);
|
Derivation drv = getDerivation_andCheckArgs(opFlags, opArgs, componentPath, statePath, binary, derivationPath, isStatePath, program_args);
|
||||||
|
|
||||||
bool recursive = true; //TODO !!!!!!!!!
|
bool recursive = true; //TODO !!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
//First, revert own statepath
|
//Insert the direct statePath or all recursive statePaths into the list
|
||||||
|
|
||||||
//Then, do the rest (if nessecary)
|
|
||||||
PathSet drvs;
|
PathSet drvs;
|
||||||
if(recursive)
|
if(recursive)
|
||||||
drvs = getAllStateDerivationsRecursively(componentPath, revision_arg); //get dependecies (if neccecary | recusively) of all state components that need to be updated
|
drvs = getAllStateDerivationsRecursively(componentPath, revision_arg); //get dependecies (if neccecary | recusively) of all state components that need to be updated
|
||||||
else
|
else
|
||||||
drvs.insert(derivationPath);
|
drvs.insert(derivationPath);
|
||||||
/*
|
|
||||||
|
//Revert each statePath in the list
|
||||||
for (PathSet::iterator d = drvs.begin(); d != drvs.end(); ++d)
|
for (PathSet::iterator d = drvs.begin(); d != drvs.end(); ++d)
|
||||||
{
|
{
|
||||||
Path drvPath = *d;
|
Path drvPath = *d;
|
||||||
Derivation drv = derivationFromPath(drvPath);
|
Derivation drv = derivationFromPath(drvPath);
|
||||||
DerivationStateOutputs stateOutputs = drv.stateOutputs;
|
DerivationStateOutputs stateOutputs = drv.stateOutputs;
|
||||||
Path statePath = stateOutputs.find("state")->second.statepath;
|
Path statePath = stateOutputs.find("state")->second.statepath;
|
||||||
DerivationStateOutputDirs stateOutputDirs = drv.stateOutputDirs;
|
|
||||||
string drvName = drv.env.find("name")->second;
|
string drvName = drv.env.find("name")->second;
|
||||||
|
|
||||||
RevisionNumbersClosure getRivisionsClosure;
|
RevisionNumbers getRivisions;
|
||||||
bool b = store->queryStateRevisions(statePath, getRivisionsClosure, revision_arg);
|
bool b = store->queryStateRevisions(statePath, getRivisions, revision_arg);
|
||||||
|
|
||||||
//sort
|
string repos = getStateReposPath("stateOutput:staterepospath", statePath, drvName, stateIdentifier); //this is a copy from store-state.cc
|
||||||
for (DerivationStateOutputDirs::const_reverse_iterator i = stateOutputDirs.rbegin(); i != stateOutputDirs.rend(); ++i){
|
|
||||||
|
|
||||||
DerivationStateOutputDir d = i->second;
|
Strings p_args;
|
||||||
string thisdir = d.path;
|
p_args.push_back(nixSVNPath + "/svn");
|
||||||
//Get the a repository for this state location
|
p_args.push_back(int2String(revision_arg));
|
||||||
string repos = getStateReposPath("stateOutput:staterepospath", statePath, thisdir, drvName, stateIdentifier); //this is a copy from store-state.cc
|
p_args.push_back("file://" + repos);
|
||||||
|
string output = runProgram(nixLibexecDir + "/nix/nix-restorerevision.sh", true, p_args); //run
|
||||||
|
|
||||||
|
|
||||||
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 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void opRunComponent(Strings opFlags, Strings opArgs)
|
static void opRunComponent(Strings opFlags, Strings opArgs)
|
||||||
|
|
@ -343,7 +307,7 @@ static void opRunComponent(Strings opFlags, Strings opArgs)
|
||||||
//add locks ... ?
|
//add locks ... ?
|
||||||
//svn lock ... ?
|
//svn lock ... ?
|
||||||
|
|
||||||
//get dependecies (if neccecary | recusively) of all state components that need to be updated
|
//get all current dependecies (if neccecary | recusively) of all state components that need to be updated
|
||||||
PathSet root_drvs = getAllStateDerivationsRecursively(root_componentPath, -1);
|
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?
|
||||||
|
|
@ -360,7 +324,7 @@ static void opRunComponent(Strings opFlags, Strings opArgs)
|
||||||
|
|
||||||
//******************* With everything in place, we call the commit script on all statePaths **********************
|
//******************* With everything in place, we call the commit script on all statePaths **********************
|
||||||
|
|
||||||
map<Path, RevisionNumbers> rivisionsClosureMapping;
|
RevisionNumbersSet rivisionMapping;
|
||||||
|
|
||||||
for (PathSet::iterator d = root_drvs.begin(); d != root_drvs.end(); ++d) //TODO first commit own state path?
|
for (PathSet::iterator d = root_drvs.begin(); d != root_drvs.end(); ++d) //TODO first commit own state path?
|
||||||
{
|
{
|
||||||
|
|
@ -379,7 +343,6 @@ static void opRunComponent(Strings opFlags, Strings opArgs)
|
||||||
vector<string> subversionedpaths;
|
vector<string> subversionedpaths;
|
||||||
vector<bool> subversionedpathsCommitBoolean;
|
vector<bool> subversionedpathsCommitBoolean;
|
||||||
vector<string> nonversionedpaths; //of type none, no versioning needed
|
vector<string> nonversionedpaths; //of type none, no versioning needed
|
||||||
vector<string> checkoutcommands;
|
|
||||||
|
|
||||||
//Get all the inverals from the database at once
|
//Get all the inverals from the database at once
|
||||||
PathSet intervalPaths;
|
PathSet intervalPaths;
|
||||||
|
|
@ -409,11 +372,6 @@ static void opRunComponent(Strings opFlags, Strings opArgs)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//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
|
|
||||||
|
|
||||||
//Add the checkout command in case its needed
|
|
||||||
checkoutcommands.push_back(svnbin + " --ignore-externals checkout file://" + repos + " " + fullstatedir);
|
|
||||||
subversionedpaths.push_back(fullstatedir);
|
subversionedpaths.push_back(fullstatedir);
|
||||||
|
|
||||||
if(d.type == "interval"){
|
if(d.type == "interval"){
|
||||||
|
|
@ -434,8 +392,9 @@ static void opRunComponent(Strings opFlags, Strings opArgs)
|
||||||
throw Error(format("interval '%1%' is not handled in nix-state") % d.type);
|
throw Error(format("interval '%1%' is not handled in nix-state") % d.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Update the intervals again
|
//Get the a repository for this state location
|
||||||
store->setStatePathsInterval(intervalPaths, intervals);
|
string repos = getStateReposPath("stateOutput:staterepospath", statePath, drvName, stateIdentifier); //this is a copy from store-state.cc
|
||||||
|
string checkoutcommand = svnbin + " --ignore-externals checkout file://" + repos + " " + statePath;
|
||||||
|
|
||||||
//Call the commit script with the appropiate paramenters
|
//Call the commit script with the appropiate paramenters
|
||||||
string subversionedstatepathsarray;
|
string subversionedstatepathsarray;
|
||||||
|
|
@ -453,12 +412,6 @@ static void opRunComponent(Strings opFlags, Strings opArgs)
|
||||||
{
|
{
|
||||||
nonversionedstatepathsarray += *(i) + " ";
|
nonversionedstatepathsarray += *(i) + " ";
|
||||||
}
|
}
|
||||||
string commandsarray;
|
|
||||||
for (vector<string>::iterator i = checkoutcommands.begin(); i != checkoutcommands.end(); ++i)
|
|
||||||
{
|
|
||||||
//#HACK: I cant seem to find a way for bash to parse a 2 dimensional string array as argument, so we use a 1-d array with '|' as seperator
|
|
||||||
commandsarray += "" + *(i) + " | ";
|
|
||||||
}
|
|
||||||
|
|
||||||
//make the call to the commit script
|
//make the call to the commit script
|
||||||
Strings p_args;
|
Strings p_args;
|
||||||
|
|
@ -466,27 +419,29 @@ static void opRunComponent(Strings opFlags, Strings opArgs)
|
||||||
p_args.push_back(subversionedstatepathsarray);
|
p_args.push_back(subversionedstatepathsarray);
|
||||||
p_args.push_back(subversionedpathsCommitBooleansarray);
|
p_args.push_back(subversionedpathsCommitBooleansarray);
|
||||||
p_args.push_back(nonversionedstatepathsarray);
|
p_args.push_back(nonversionedstatepathsarray);
|
||||||
p_args.push_back(commandsarray);
|
p_args.push_back(checkoutcommand);
|
||||||
|
p_args.push_back(statePath);
|
||||||
runProgram_AndPrintOutput(nixLibexecDir + "/nix/nix-statecommit.sh", true, p_args, "svn");
|
runProgram_AndPrintOutput(nixLibexecDir + "/nix/nix-statecommit.sh", true, p_args, "svn");
|
||||||
|
|
||||||
|
//Update the intervals again
|
||||||
|
//store->setStatePathsInterval(intervalPaths, intervals); //TODO!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
//Scan if needed
|
//Scan if needed
|
||||||
if(false)
|
if(false)
|
||||||
store->scanAndUpdateAllReferencesRecusively(statePath);
|
store->scanAndUpdateAllReferencesRecusively(statePath);
|
||||||
|
|
||||||
rivisionsClosureMapping[statePath] = readRevisionNumbers(drv); //Get current numbers
|
rivisionMapping[statePath] = readRevisionNumber(drv); //Get current numbers
|
||||||
}
|
}
|
||||||
|
|
||||||
//Store the revision numbers in the database for this statePath to a new revision
|
//Store the revision numbers in the database for this statePath to a new revision
|
||||||
store->setStateRevisions(root_statePath, rivisionsClosureMapping, -1);
|
store->setStateRevisions(root_statePath, rivisionMapping, -1);
|
||||||
|
|
||||||
RevisionNumbersClosure getRivisionsClosure;
|
RevisionNumbers getRivisions;
|
||||||
bool b = store->queryStateRevisions(root_statePath, getRivisionsClosure, -1);
|
bool b = store->queryStateRevisions(root_statePath, getRivisions, -1);
|
||||||
|
|
||||||
for (RevisionNumbersClosure::iterator d = getRivisionsClosure.begin(); d != getRivisionsClosure.end(); ++d){
|
for (RevisionNumbers::iterator i = getRivisions.begin(); i != getRivisions.end(); ++i){
|
||||||
printMsg(lvlError, format("REVVV"));
|
printMsg(lvlError, format("REV %1%") % int2String(*i));
|
||||||
for (RevisionNumbers::iterator e = (*d).begin(); e != (*d).end(); ++e)
|
|
||||||
printMsg(lvlError, format("REV %1%") % *e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -610,7 +565,7 @@ void run(Strings args)
|
||||||
else if (arg == "--showstatepath")
|
else if (arg == "--showstatepath")
|
||||||
op = opShowStatePath;
|
op = opShowStatePath;
|
||||||
else if (arg == "--showstatereposrootpath")
|
else if (arg == "--showstatereposrootpath")
|
||||||
op = opShowStateReposRootPath;
|
op = opShowStateReposPath;
|
||||||
else if (arg == "--showderivations")
|
else if (arg == "--showderivations")
|
||||||
op = opShowDerivations;
|
op = opShowDerivations;
|
||||||
else if (arg == "--showrevisions")
|
else if (arg == "--showrevisions")
|
||||||
|
|
|
||||||
|
|
@ -304,15 +304,15 @@ static void opQuery(Strings opFlags, Strings opArgs)
|
||||||
i != opArgs.end(); ++i)
|
i != opArgs.end(); ++i)
|
||||||
{
|
{
|
||||||
Path path = maybeUseOutput(fixStoreOrStatePath(*i), useOutput, forceRealise);
|
Path path = maybeUseOutput(fixStoreOrStatePath(*i), useOutput, forceRealise);
|
||||||
if (query == qRequisites) store->storePathRequisites(path, includeOutputs, paths, true, false);
|
if (query == qRequisites) store->storePathRequisites(path, includeOutputs, paths, true, false, -1);
|
||||||
else if (query == qRequisitesState) store->storePathRequisites(path, includeOutputs, paths, false, true);
|
else if (query == qRequisitesState) store->storePathRequisites(path, includeOutputs, paths, false, true, -1);
|
||||||
else if (query == qRequisitesFull) store->storePathRequisites(path, includeOutputs, paths, true, true);
|
else if (query == qRequisitesFull) store->storePathRequisites(path, includeOutputs, paths, true, true, -1);
|
||||||
else if (query == qReferences) store->queryReferences(path, paths, -1);
|
else if (query == qReferences) store->queryReferences(path, paths, -1);
|
||||||
else if (query == qStateReferences) store->queryStateReferences(path, paths, -1); //latest revision
|
else if (query == qStateReferences) store->queryStateReferences(path, paths, -1); //latest revision
|
||||||
else if (query == qReferrers) store->queryReferrers(path, paths, -1);
|
else if (query == qReferrers) store->queryReferrers(path, paths, -1);
|
||||||
else if (query == qStateReferrers) store->queryStateReferrers(path, paths, -1); //latest revision
|
else if (query == qStateReferrers) store->queryStateReferrers(path, paths, -1); //latest revision
|
||||||
else if (query == qReferrersClosure) computeFSClosure(path, paths, true, false, true);
|
else if (query == qReferrersClosure) computeFSClosure(path, paths, true, false, -1, true);
|
||||||
else if (query == qReferrersClosureWithState) computeFSClosure(path, paths, true, true, true);
|
else if (query == qReferrersClosureWithState) computeFSClosure(path, paths, true, true, -1, true);
|
||||||
}
|
}
|
||||||
Paths sorted = topoSortPaths(paths);
|
Paths sorted = topoSortPaths(paths);
|
||||||
for (Paths::reverse_iterator i = sorted.rbegin();
|
for (Paths::reverse_iterator i = sorted.rbegin();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue