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

Fixed showrevisions. added commit/run/scan only options

This commit is contained in:
Wouter den Breejen 2007-08-30 18:51:19 +00:00
parent 30cf65af26
commit ec7b0afb08
3 changed files with 74 additions and 55 deletions

View file

@ -214,7 +214,11 @@ public:
/* TODO */ /* TODO */
virtual void setStateRevisions(const RevisionClosure & revisions, const Path & rootStatePath, const string & comment) = 0; virtual void setStateRevisions(const RevisionClosure & revisions, const Path & rootStatePath, const string & comment) = 0;
/* TODO */ /*
* TODO Not sure wheter this comment is 100% correct
* Querys all available state revision closures.
* (e.g. a references scan can change this)
*/
virtual bool queryStateRevisions(const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, const unsigned int revision) = 0; virtual bool queryStateRevisions(const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, const unsigned int revision) = 0;
/* TODO */ /* TODO */

View file

@ -28,8 +28,9 @@ string stateIdentifier;
string username; string username;
string comment; string comment;
unsigned int revision_arg; unsigned int revision_arg;
bool scanforReferences = false; bool r_scanforReferences = false;
bool only_commit = false; bool r_commit = true;
bool r_run = true;
bool revert_recursively = false; bool revert_recursively = false;
@ -263,10 +264,9 @@ static void opRunComponent(Strings opFlags, Strings opArgs)
//svn lock ... ? //svn lock ... ?
//******************* Run **************************** //******************* Run ****************************
if(!only_commit){ if(r_run){
if( ! FileExist(root_componentPath + root_binary) ) if( ! FileExist(root_componentPath + root_binary) )
throw Error(format("You must specify the full binary path: '%1%'") % (root_componentPath + root_binary)); throw Error(format("You must specify the full binary path: '%1%'") % (root_componentPath + root_binary));
@ -285,16 +285,19 @@ static void opRunComponent(Strings opFlags, Strings opArgs)
executeShellCommand(root_componentPath + root_binary + root_args); executeShellCommand(root_componentPath + root_binary + root_args);
} }
//////////////////////////////
//TODO //TODO
Transaction txn; Transaction txn;
//createStoreTransaction(txn); //createStoreTransaction(txn);
//******************* Scan for new references if neccecary //******************* Scan for new references if neccecary
if(scanforReferences) if(r_scanforReferences)
store->scanAndUpdateAllReferences(root_statePath, true); //TODO make recursive a paramter? store->scanAndUpdateAllReferences(root_statePath, true); //TODO make recursive a paramter?
//******************* With everything in place, we call the commit script on all statePaths (in)directly referenced **********************
if(r_commit){
//get all current (maybe updated by the scan) dependecies (if neccecary | recusively) of all state components that need to be updated //get all current (maybe updated by the scan) dependecies (if neccecary | recusively) of all state components that need to be updated
PathSet statePaths; PathSet statePaths;
store->storePathRequisites(root_componentPath, false, statePaths, false, true, 0); store->storePathRequisites(root_componentPath, false, statePaths, false, true, 0);
@ -305,8 +308,6 @@ static void opRunComponent(Strings opFlags, Strings opArgs)
//Replace all shared paths in the set for their real paths //Replace all shared paths in the set for their real paths
statePaths = store->toNonSharedPathSet(statePaths); statePaths = store->toNonSharedPathSet(statePaths);
//******************* With everything in place, we call the commit script on all statePaths (in)directly referenced **********************
//Commit all statePaths //Commit all statePaths
RevisionClosure rivisionMapping; RevisionClosure rivisionMapping;
for (PathSet::iterator i = statePaths.begin(); i != statePaths.end(); ++i) //TODO first commit own state path? for (PathSet::iterator i = statePaths.begin(); i != statePaths.end(); ++i) //TODO first commit own state path?
@ -314,6 +315,7 @@ static void opRunComponent(Strings opFlags, Strings opArgs)
//Save new revisions //Save new revisions
store->setStateRevisions(rivisionMapping, root_statePath, comment); //TODO how about the txn? store->setStateRevisions(rivisionMapping, root_statePath, comment); //TODO how about the txn?
}
//Commit transaction //Commit transaction
//txn.commit(); //txn.commit();
@ -323,17 +325,11 @@ static void opRunComponent(Strings opFlags, Strings opArgs)
RevisionClosureTS empty; RevisionClosureTS empty;
bool b = store->queryStateRevisions(root_statePath, getRivisions, empty, 0); bool b = store->queryStateRevisions(root_statePath, getRivisions, empty, 0);
for (RevisionClosure::iterator i = getRivisions.begin(); i != getRivisions.end(); ++i){ for (RevisionClosure::iterator i = getRivisions.begin(); i != getRivisions.end(); ++i){
printMsg(lvlError, format("State '%1%' has revision") % (*i).first); //printMsg(lvlError, format("State '%1%' has revision") % (*i).first);
} }
} }
void testUI(unsigned int i)
{
printMsg(lvlError, format("Int: %1%") % i);
}
void run(Strings args) void run(Strings args)
{ {
Strings opFlags, opArgs; Strings opFlags, opArgs;
@ -499,44 +495,66 @@ void run(Strings args)
Operation oldOp = op; Operation oldOp = op;
if (arg == "--run" || arg == "-r") //Run options
if (arg == "--run" || arg == "-r") //run and commit
op = opRunComponent; op = opRunComponent;
else if (arg == "--commit-only"){ else if (arg == "--commit-only"){
op = opRunComponent; op = opRunComponent;
only_commit = true; r_commit = true;
r_run = false;
r_scanforReferences = false;
} }
else if (arg == "--run-only"){
op = opRunComponent;
r_commit = false;
r_run = true;
r_scanforReferences = false;
}
else if (arg == "--scan-only"){
op = opRunComponent;
r_commit = false;
r_run = false;
r_scanforReferences = true;
}
else if (arg == "--scanreferences"){
r_scanforReferences = true;
}
else if (arg.substr(0,10) == "--comment=")
comment = arg.substr(10,arg.length());
//Info options
else if (arg == "--showstatepath") else if (arg == "--showstatepath")
op = opShowStatePath; op = opShowStatePath;
else if (arg == "--showderivations") else if (arg == "--showderivations")
op = opShowDerivations; op = opShowDerivations;
else if (arg == "--showrevisions") else if (arg == "--showrevisions")
op = queryAvailableStateRevisions; op = queryAvailableStateRevisions;
//State options
else if (arg.substr(0,21) == "--revert-to-revision="){ else if (arg.substr(0,21) == "--revert-to-revision="){
op = revertToRevision; op = revertToRevision;
bool succeed = string2UnsignedInt(arg.substr(21,arg.length()), revision_arg); bool succeed = string2UnsignedInt(arg.substr(21,arg.length()), revision_arg);
if(!succeed) if(!succeed)
throw UsageError("The given revision is not a valid number"); throw UsageError("The given revision is not a valid number");
} }
else if (arg.substr(0,10) == "--revert-to-revision-recursively")
revert_recursively = true;
/* /*
--run-without-commit
--show-revision-path=....
--showrevisions
--revert-to-revision=
--share-from --share-from
--unshare --unshare
*/
OPTIONAL
--scanreferences //Maybe
/////////////////////
/*
--backup ? --backup ?
--exclude-commit-paths --exclude-commit-paths
@ -547,16 +565,13 @@ void run(Strings args)
*/ */
else if (arg == "--scanreferences") //Manipulate options....
scanforReferences = true;
else if (arg.substr(0,13) == "--identifier=") else if (arg.substr(0,13) == "--identifier=")
stateIdentifier = arg.substr(13,arg.length()); stateIdentifier = arg.substr(13,arg.length());
else if (arg.substr(0,7) == "--user=") else if (arg.substr(0,7) == "--user=")
username = arg.substr(7,arg.length()); username = arg.substr(7,arg.length());
else if (arg.substr(0,10) == "--comment=")
comment = arg.substr(10,arg.length());
else if (arg.substr(0,10) == "--revert-to-revision-recursively")
revert_recursively = true;
else else
opArgs.push_back(arg); opArgs.push_back(arg);

View file

@ -248,7 +248,7 @@ static void performOp(Source & from, Sink & to, unsigned int op)
} }
case wopIsValidStatePath: { case wopIsValidStatePath: {
Path path = readStorePath(from); Path path = readString(from); //TODO readStatePath
startWork(); startWork();
bool result = store->isValidStatePath(path); bool result = store->isValidStatePath(path);
stopWork(); stopWork();