From 9257f16c85ea5000c4e30f6770f9c223e6bdce86 Mon Sep 17 00:00:00 2001 From: Wouter den Breejen Date: Mon, 9 Jul 2007 11:59:29 +0000 Subject: [PATCH] Besides directorys, single files can now also be versioned (or excluded) --- scripts/nix-statecommit.sh | 15 ++++++++++++++- scripts/nix-statecommit.sh.in | 15 ++++++++++++++- src/libstore/db.cc | 24 ++++++++++++++++++------ src/libstore/db.hh | 2 +- src/libstore/store-state.cc | 7 ++++++- 5 files changed, 53 insertions(+), 10 deletions(-) diff --git a/scripts/nix-statecommit.sh b/scripts/nix-statecommit.sh index cdbaadfc0..dcb36aec0 100755 --- a/scripts/nix-statecommit.sh +++ b/scripts/nix-statecommit.sh @@ -145,7 +145,7 @@ do if [ "${subversionedpathsCommitBools[$i]}" = "true" ]; then #Check if we need to commit this folder echo "Entering $path" - if ! test -d "${path}/.svn/"; then #Also add yourself if nessecary + if ! test -d "${path}/.svn/"; then #Dir: Also add yourself if nessecary if [ "$deletesvn" != "1" ]; then $debug svn -N add $path fi @@ -157,6 +157,19 @@ do cd - &> /dev/null; let "i+=1" fi + + if test -f $path; then #if its a file, see if it needs to be added + + if [ "${subversionedpathsCommitBools[$i]}" = "true" ]; then #Check if we need to commit this file + + alreadyversioned=$(svn -N stat $path ) + if [ "$alreadyversioned" != "" ]; then + echo "Subversioning $path" + $debug svn add $path + fi + fi + fi + done cd $statepath #now that everything is added we go back to the 'root' path and commit diff --git a/scripts/nix-statecommit.sh.in b/scripts/nix-statecommit.sh.in index cdbaadfc0..dcb36aec0 100755 --- a/scripts/nix-statecommit.sh.in +++ b/scripts/nix-statecommit.sh.in @@ -145,7 +145,7 @@ do if [ "${subversionedpathsCommitBools[$i]}" = "true" ]; then #Check if we need to commit this folder echo "Entering $path" - if ! test -d "${path}/.svn/"; then #Also add yourself if nessecary + if ! test -d "${path}/.svn/"; then #Dir: Also add yourself if nessecary if [ "$deletesvn" != "1" ]; then $debug svn -N add $path fi @@ -157,6 +157,19 @@ do cd - &> /dev/null; let "i+=1" fi + + if test -f $path; then #if its a file, see if it needs to be added + + if [ "${subversionedpathsCommitBools[$i]}" = "true" ]; then #Check if we need to commit this file + + alreadyversioned=$(svn -N stat $path ) + if [ "$alreadyversioned" != "" ]; then + echo "Subversioning $path" + $debug svn add $path + fi + fi + fi + done cd $statepath #now that everything is added we go back to the 'root' path and commit diff --git a/src/libstore/db.cc b/src/libstore/db.cc index fe2fba06e..40bfcb897 100644 --- a/src/libstore/db.cc +++ b/src/libstore/db.cc @@ -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); diff --git a/src/libstore/db.hh b/src/libstore/db.hh index a33d407cd..cb0089816 100644 --- a/src/libstore/db.hh +++ b/src/libstore/db.hh @@ -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); diff --git a/src/libstore/store-state.cc b/src/libstore/store-state.cc index 474416377..79b06acfc 100644 --- a/src/libstore/store-state.cc +++ b/src/libstore/store-state.cc @@ -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);