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:
parent
30cf65af26
commit
ec7b0afb08
3 changed files with 74 additions and 55 deletions
|
|
@ -214,7 +214,11 @@ public:
|
|||
/* TODO */
|
||||
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;
|
||||
|
||||
/* TODO */
|
||||
|
|
|
|||
|
|
@ -28,8 +28,9 @@ string stateIdentifier;
|
|||
string username;
|
||||
string comment;
|
||||
unsigned int revision_arg;
|
||||
bool scanforReferences = false;
|
||||
bool only_commit = false;
|
||||
bool r_scanforReferences = false;
|
||||
bool r_commit = true;
|
||||
bool r_run = true;
|
||||
bool revert_recursively = false;
|
||||
|
||||
|
||||
|
|
@ -263,10 +264,9 @@ static void opRunComponent(Strings opFlags, Strings opArgs)
|
|||
//svn lock ... ?
|
||||
|
||||
|
||||
|
||||
//******************* Run ****************************
|
||||
|
||||
if(!only_commit){
|
||||
if(r_run){
|
||||
if( ! FileExist(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);
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
|
||||
//TODO
|
||||
Transaction txn;
|
||||
//createStoreTransaction(txn);
|
||||
|
||||
//******************* Scan for new references if neccecary
|
||||
if(scanforReferences)
|
||||
if(r_scanforReferences)
|
||||
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
|
||||
PathSet statePaths;
|
||||
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
|
||||
statePaths = store->toNonSharedPathSet(statePaths);
|
||||
|
||||
//******************* With everything in place, we call the commit script on all statePaths (in)directly referenced **********************
|
||||
|
||||
//Commit all statePaths
|
||||
RevisionClosure rivisionMapping;
|
||||
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
|
||||
store->setStateRevisions(rivisionMapping, root_statePath, comment); //TODO how about the txn?
|
||||
}
|
||||
|
||||
//Commit transaction
|
||||
//txn.commit();
|
||||
|
|
@ -323,17 +325,11 @@ static void opRunComponent(Strings opFlags, Strings opArgs)
|
|||
RevisionClosureTS empty;
|
||||
bool b = store->queryStateRevisions(root_statePath, getRivisions, empty, 0);
|
||||
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)
|
||||
{
|
||||
Strings opFlags, opArgs;
|
||||
|
|
@ -499,44 +495,66 @@ void run(Strings args)
|
|||
|
||||
Operation oldOp = op;
|
||||
|
||||
if (arg == "--run" || arg == "-r")
|
||||
//Run options
|
||||
|
||||
if (arg == "--run" || arg == "-r") //run and commit
|
||||
op = opRunComponent;
|
||||
else if (arg == "--commit-only"){
|
||||
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")
|
||||
op = opShowStatePath;
|
||||
else if (arg == "--showderivations")
|
||||
op = opShowDerivations;
|
||||
else if (arg == "--showrevisions")
|
||||
op = queryAvailableStateRevisions;
|
||||
|
||||
|
||||
//State options
|
||||
|
||||
else if (arg.substr(0,21) == "--revert-to-revision="){
|
||||
op = revertToRevision;
|
||||
bool succeed = string2UnsignedInt(arg.substr(21,arg.length()), revision_arg);
|
||||
if(!succeed)
|
||||
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
|
||||
|
||||
--unshare
|
||||
*/
|
||||
|
||||
OPTIONAL
|
||||
|
||||
--scanreferences
|
||||
|
||||
/////////////////////
|
||||
//Maybe
|
||||
|
||||
/*
|
||||
--backup ?
|
||||
|
||||
--exclude-commit-paths
|
||||
|
|
@ -547,16 +565,13 @@ void run(Strings args)
|
|||
|
||||
*/
|
||||
|
||||
else if (arg == "--scanreferences")
|
||||
scanforReferences = true;
|
||||
//Manipulate options....
|
||||
else if (arg.substr(0,13) == "--identifier=")
|
||||
stateIdentifier = arg.substr(13,arg.length());
|
||||
else if (arg.substr(0,7) == "--user=")
|
||||
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
|
||||
opArgs.push_back(arg);
|
||||
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ static void performOp(Source & from, Sink & to, unsigned int op)
|
|||
}
|
||||
|
||||
case wopIsValidStatePath: {
|
||||
Path path = readStorePath(from);
|
||||
Path path = readString(from); //TODO readStatePath
|
||||
startWork();
|
||||
bool result = store->isValidStatePath(path);
|
||||
stopWork();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue