mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 20:20:58 +01:00
State revisions are now printed like this: Rev. 01 @ Mon Aug 6 15:48:37 2007 (1186408117) -- Initial build revision.
This commit is contained in:
parent
696f1fd5e2
commit
13f321e397
12 changed files with 124 additions and 49 deletions
|
|
@ -1814,7 +1814,7 @@ void DerivationGoal::computeClosure()
|
|||
rivisionMapping[statePath] = commitStatePathTxn(txn, statePath);
|
||||
|
||||
//Save the new revision
|
||||
setStateRevisionsTxn(txn, rivisionMapping);
|
||||
setStateRevisionsTxn(txn, rivisionMapping, statePath, "Initial build revision.");
|
||||
|
||||
//Shared state
|
||||
Path sharedState = drv.stateOutputs.find("state")->second.sharedState;
|
||||
|
|
|
|||
|
|
@ -617,9 +617,12 @@ bool Database::queryStateReferences(const Transaction & txn, TableId references_
|
|||
return queryStrings(txn, references_table, key, references); //now that we have the key, we can query the references
|
||||
}
|
||||
|
||||
void Database::setStateRevisions(const Transaction & txn, TableId revisions_table, TableId snapshots_table,
|
||||
const RevisionClosure & revisions)
|
||||
void Database::setStateRevisions(const Transaction & txn, TableId revisions_table, TableId revisions_comments,
|
||||
TableId snapshots_table, const RevisionClosure & revisions, const Path & rootStatePath, const string & comment)
|
||||
{
|
||||
if( !isStatePath(rootStatePath) ) //weak check on statePath
|
||||
throw Error(format("StatePath '%1%' is not a statepath") % rootStatePath);
|
||||
|
||||
int ts = getTimeStamp();
|
||||
|
||||
//Insert all ss_epochs into snapshots_table with the current ts.
|
||||
|
|
@ -637,6 +640,7 @@ void Database::setStateRevisions(const Transaction & txn, TableId revisions_tabl
|
|||
Path statePath = (*i).first;
|
||||
|
||||
int revision = getNewRevisionNumber(txn, revisions_table, statePath); //get a new revision number
|
||||
|
||||
string key = mergeToDBKey(statePath, revision);
|
||||
|
||||
//get all its requisites
|
||||
|
|
@ -650,6 +654,16 @@ void Database::setStateRevisions(const Transaction & txn, TableId revisions_tabl
|
|||
data.push_back(mergeToDBKey(*j, ts));
|
||||
|
||||
setStrings(txn, revisions_table, key, data, false); //The false makes sure also empty revisions are set
|
||||
|
||||
//save the date and comments
|
||||
Strings metadata;
|
||||
metadata.push_back(int2String(ts));
|
||||
if(statePath == rootStatePath)
|
||||
metadata.push_back(comment);
|
||||
else
|
||||
metadata.push_back("Part of the snashot closure for " + rootStatePath);
|
||||
setStrings(txn, revisions_comments, key, metadata);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -720,8 +734,8 @@ bool Database::queryStateRevisions(const Transaction & txn, TableId revisions_ta
|
|||
}
|
||||
|
||||
//TODO include comments into revisions?
|
||||
bool Database::queryAvailableStateRevisions(const Transaction & txn, TableId revisions_table,
|
||||
const Path & statePath, RevisionNumbers & revisions)
|
||||
bool Database::queryAvailableStateRevisions(const Transaction & txn, TableId revisions_table, TableId revisions_comments,
|
||||
const Path & statePath, RevisionInfos & revisions)
|
||||
{
|
||||
Strings keys;
|
||||
enumTable(txn, revisions_table, keys); //get all revisions
|
||||
|
|
@ -734,7 +748,19 @@ bool Database::queryAvailableStateRevisions(const Transaction & txn, TableId rev
|
|||
Path getStatePath;
|
||||
int getRevision;
|
||||
splitDBKey(*i, getStatePath, getRevision);
|
||||
revisions.push_back(getRevision);
|
||||
|
||||
//save the date and comments
|
||||
RevisionInfo rev;
|
||||
Strings metadata;
|
||||
queryStrings(txn, revisions_comments, *i, metadata);
|
||||
unsigned int ts;
|
||||
bool succeed = string2UnsignedInt(*(metadata.begin()), ts);
|
||||
if(!succeed)
|
||||
throw Error(format("Malformed timestamp in the revisions-comments table of path '%1%'") % *i);
|
||||
rev.timestamp = ts;
|
||||
metadata.pop_front();
|
||||
rev.comment = *(metadata.begin());
|
||||
revisions[getRevision] = rev;
|
||||
}
|
||||
|
||||
if(revisions.empty())
|
||||
|
|
|
|||
|
|
@ -114,16 +114,16 @@ public:
|
|||
const Path & statePath, Strings & references, int revision = -1, int timestamp = -1);
|
||||
|
||||
/* 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 revisions_table, TableId snapshots_table,
|
||||
const RevisionClosure & revisions);
|
||||
void setStateRevisions(const Transaction & txn, TableId revisions_table, TableId revisions_comments,
|
||||
TableId snapshots_table, const RevisionClosure & revisions, const Path & rootStatePath, const string & comment);
|
||||
|
||||
/* Returns all the revision numbers of the state references closure of the given state path */
|
||||
bool queryStateRevisions(const Transaction & txn, TableId revisions_table, TableId snapshots_table,
|
||||
const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, int root_revision = -1);
|
||||
|
||||
/* Returns all available revision numbers of the given state path */
|
||||
bool queryAvailableStateRevisions(const Transaction & txn, TableId revisions_table,
|
||||
const Path & statePath, RevisionNumbers & revisions);
|
||||
bool queryAvailableStateRevisions(const Transaction & txn, TableId revisions_table, TableId revisions_comments,
|
||||
const Path & statePath, RevisionInfos & revisions);
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -135,6 +135,11 @@ static TableId dbStateInfo = 0;
|
|||
*/
|
||||
static TableId dbStateRevisions = 0;
|
||||
|
||||
/*
|
||||
* A additional table to store comments for revisions
|
||||
*/
|
||||
static TableId dbStateRevisionsComments = 0;
|
||||
|
||||
/* dbStateSnapshots :: StatePath -> RevisionNumbers
|
||||
*
|
||||
* This table stores the snapshot numbers the sub state files/folders
|
||||
|
|
@ -238,6 +243,7 @@ LocalStore::LocalStore(bool reserveSpace)
|
|||
dbStateComponentReferences = nixDB.openTable("references_s_c");
|
||||
dbStateStateReferences = nixDB.openTable("references_s_s");
|
||||
dbStateRevisions = nixDB.openTable("staterevisions");
|
||||
dbStateRevisionsComments = nixDB.openTable("staterevisions_comments");
|
||||
dbStateSnapshots = nixDB.openTable("stateSnapshots");
|
||||
dbSharedState = nixDB.openTable("sharedState");
|
||||
dbSolidStateReferences = nixDB.openTable("references_solid_c_s"); /* The contents of this table is included in references_c_s */
|
||||
|
|
@ -1674,14 +1680,14 @@ void queryAllValidPaths(const Transaction & txn, PathSet & allComponentPaths, Pa
|
|||
}
|
||||
|
||||
|
||||
void setStateRevisionsTxn(const Transaction & txn, const RevisionClosure & revisions)
|
||||
void setStateRevisionsTxn(const Transaction & txn, const RevisionClosure & revisions, const Path & rootStatePath, const string & comment)
|
||||
{
|
||||
nixDB.setStateRevisions(txn, dbStateRevisions, dbStateSnapshots, revisions);
|
||||
nixDB.setStateRevisions(txn, dbStateRevisions, dbStateRevisionsComments, dbStateSnapshots, revisions, rootStatePath, comment);
|
||||
}
|
||||
|
||||
void LocalStore::setStateRevisions(const RevisionClosure & revisions)
|
||||
void LocalStore::setStateRevisions(const RevisionClosure & revisions, const Path & rootStatePath, const string & comment)
|
||||
{
|
||||
nix::setStateRevisionsTxn(noTxn, revisions);
|
||||
nix::setStateRevisionsTxn(noTxn, revisions, rootStatePath, comment);
|
||||
}
|
||||
|
||||
bool queryStateRevisionsTxn(const Transaction & txn, const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, const int revision)
|
||||
|
|
@ -1694,12 +1700,12 @@ bool LocalStore::queryStateRevisions(const Path & statePath, RevisionClosure & r
|
|||
return nix::queryStateRevisionsTxn(noTxn, statePath, revisions, timestamps, revision);
|
||||
}
|
||||
|
||||
bool queryAvailableStateRevisionsTxn(const Transaction & txn, const Path & statePath, RevisionNumbers & revisions)
|
||||
bool queryAvailableStateRevisionsTxn(const Transaction & txn, const Path & statePath, RevisionInfos & revisions)
|
||||
{
|
||||
return nixDB.queryAvailableStateRevisions(txn, dbStateRevisions, statePath, revisions);
|
||||
return nixDB.queryAvailableStateRevisions(txn, dbStateRevisions, dbStateRevisionsComments, statePath, revisions);
|
||||
}
|
||||
|
||||
bool LocalStore::queryAvailableStateRevisions(const Path & statePath, RevisionNumbers & revisions)
|
||||
bool LocalStore::queryAvailableStateRevisions(const Path & statePath, RevisionInfos & revisions)
|
||||
{
|
||||
return nix::queryAvailableStateRevisionsTxn(noTxn, statePath, revisions);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,11 +100,11 @@ public:
|
|||
|
||||
void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision);
|
||||
|
||||
void setStateRevisions(const RevisionClosure & revisions);
|
||||
void setStateRevisions(const RevisionClosure & revisions, const Path & rootStatePath, const string & comment);
|
||||
|
||||
bool queryStateRevisions(const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, const int revision);
|
||||
|
||||
bool queryAvailableStateRevisions(const Path & statePath, RevisionNumbers & revisions);
|
||||
bool queryAvailableStateRevisions(const Path & statePath, RevisionInfos & revisions);
|
||||
|
||||
void commitStatePath(const Path & statePath);
|
||||
};
|
||||
|
|
@ -226,14 +226,12 @@ void queryXReferencesTxn(const Transaction & txn, const Path & path, PathSet & r
|
|||
void setStateComponentReferencesTxn(const Transaction & txn, const Path & statePath, const Strings & references, int revision, int timestamp);
|
||||
void setStateStateReferencesTxn(const Transaction & txn, const Path & statePath, const Strings & references, int revision, int timestamp);
|
||||
|
||||
|
||||
|
||||
void queryReferrersTxn(const Transaction & txn, const Path & storePath, PathSet & referrers, const int revision);
|
||||
void queryStateReferrersTxn(const Transaction & txn, const Path & storePath, PathSet & stateReferrers, const int revision);
|
||||
|
||||
Path queryStatePathDrvTxn(const Transaction & txn, const Path & statePath);
|
||||
void storePathRequisitesTxn(const Transaction & txn, const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision);
|
||||
void setStateRevisionsTxn(const Transaction & txn, const RevisionClosure & revisions);
|
||||
void setStateRevisionsTxn(const Transaction & txn, const RevisionClosure & revisions, const Path & rootStatePath, const string & comment);
|
||||
|
||||
bool isValidPathTxn(const Transaction & txn, const Path & path);
|
||||
bool isValidStatePathTxn(const Transaction & txn, const Path & path);
|
||||
|
|
|
|||
|
|
@ -469,7 +469,7 @@ void RemoteStore::storePathRequisites(const Path & storeOrstatePath, const bool
|
|||
}
|
||||
|
||||
//TODO
|
||||
void RemoteStore::setStateRevisions(const RevisionClosure & revisions)
|
||||
void RemoteStore::setStateRevisions(const RevisionClosure & revisions, const Path & rootStatePath, const string & comment)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -481,7 +481,7 @@ bool RemoteStore::queryStateRevisions(const Path & statePath, RevisionClosure &
|
|||
}
|
||||
|
||||
//TODO
|
||||
bool RemoteStore::queryAvailableStateRevisions(const Path & statePath, RevisionNumbers & revisions)
|
||||
bool RemoteStore::queryAvailableStateRevisions(const Path & statePath, RevisionInfos & revisions)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,11 +88,11 @@ public:
|
|||
|
||||
void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision);
|
||||
|
||||
void setStateRevisions(const RevisionClosure & revisions);
|
||||
void setStateRevisions(const RevisionClosure & revisions, const Path & rootStatePath, const string & comment);
|
||||
|
||||
bool queryStateRevisions(const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, const int revision);
|
||||
|
||||
bool queryAvailableStateRevisions(const Path & statePath, RevisionNumbers & revisions);
|
||||
bool queryAvailableStateRevisions(const Path & statePath, RevisionInfos & revisions);
|
||||
|
||||
void commitStatePath(const Path & statePath);
|
||||
|
||||
|
|
|
|||
|
|
@ -220,13 +220,13 @@ public:
|
|||
virtual void storePathRequisites(const Path & storeOrstatePath, const bool includeOutputs, PathSet & paths, const bool & withComponents, const bool & withState, const int revision) = 0;
|
||||
|
||||
/* TODO */
|
||||
virtual void setStateRevisions(const RevisionClosure & revisions) = 0;
|
||||
virtual void setStateRevisions(const RevisionClosure & revisions, const Path & rootStatePath, const string & comment) = 0;
|
||||
|
||||
/* TODO */
|
||||
virtual bool queryStateRevisions(const Path & statePath, RevisionClosure & revisions, RevisionClosureTS & timestamps, const int revision) = 0;
|
||||
|
||||
/* TODO */
|
||||
virtual bool queryAvailableStateRevisions(const Path & statePath, RevisionNumbers & revisions) = 0;
|
||||
virtual bool queryAvailableStateRevisions(const Path & statePath, RevisionInfos & revisions) = 0;
|
||||
|
||||
/* TODO */
|
||||
virtual void commitStatePath(const Path & statePath) = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue