WSF
wizard::RevisionDb Class Reference

#include <RevisionDb.hpp>

Public Member Functions

 RevisionDb ()
virtual ~RevisionDb ()
bool Open (const std::string &aDbPath)
bool OpenInMemory ()
bool Close ()
bool ClearTables ()
int StoreNewRevision (const RevisionChangeList &aChanges, const std::string &aWorkingDir, const std::vector< std::string > &aStartupFiles)
int LatestRevisionNo ()
int NewRevisionNo (const std::string &aWorkingDir)
bool DeleteRevision (int aRevNo)
bool GetFileAtRevision (const std::string &aRelFilePath, int aRevision, UtTextDocument &aDoc, int *aRevisionsTraversed=nullptr)
bool InsertChange (int aRevNo, const RevisionChange &aChange)
bool InsertChanges (int aRevNo, const RevisionChangeList &aChangeList)
bool InsertStartupFile (int aRevNo, const std::string &aStartupFile)
 Inserts a startup file associated with the given revision.
bool InsertStartupFiles (int aRevNo, const std::vector< std::string > &aStartupFiles)
 Inserts a list of startup files associated with the given revision.
RevisionList Revisions ()
RevisionChangeList Changes (int aRevNo)
RevisionPathSet ExistingFilePaths (int aRevNo)
RevisionPathSet AllFilePaths (int aRevNo)
FileMap ExistingFiles (int aRevNo)
bool StartupFiles (int aRevNo, std::vector< std::string > &aStartupFiles)
bool WorkingDirectory (int aRevNo, std::string &aWorkingDir)
bool LatestStartupFiles (std::vector< std::string > &aStartupFiles)
bool LatestWorkingDirectory (std::string &aWorkingDir)
int LatestSupportedVersion () const
int Version ()
bool IsVersionOld ()
bool IsEmpty ()
bool IsOpen () const

Detailed Description

A semantic interface into the Change History database for managing revisions, used primarily by ViRevisionStore.

Note
You should use the higher level ViRevisionStore instead of this to view and manage the Change History database.

Constructor & Destructor Documentation

◆ RevisionDb()

wizard::RevisionDb::RevisionDb ( )

◆ ~RevisionDb()

wizard::RevisionDb::~RevisionDb ( )
virtual

References Close().

Member Function Documentation

◆ AllFilePaths()

wizard::RevisionPathSet wizard::RevisionDb::AllFilePaths ( int aRevNo)
Returns
All file paths (relative) that have existed in the database up to the given revision number, even if the files are considered to be deleted or non-existent at the revision.
Parameters
aRevNoA revision number.

◆ Changes()

wizard::RevisionChangeList wizard::RevisionDb::Changes ( int aRevNo)
Returns
All changes associated with a given revision number.
Parameters
aRevNoA revision number.

References wizard::RevisionChange::changeBytes, wizard::RevisionChange::cNO_CHANGE, wizard::RevisionChange::filePath, and wizard::RevisionChange::kind.

◆ ClearTables()

bool wizard::RevisionDb::ClearTables ( )

Runs a transaction that deletes all data from the tables.

Returns
Whether or not the transaction was successful.

References success.

◆ Close()

bool wizard::RevisionDb::Close ( )

Finalizes the SQLite statements and closes the connection to the database.

Returns
Whether or not the database was successfully closed.

References success.

Referenced by ~RevisionDb().

◆ DeleteRevision()

bool wizard::RevisionDb::DeleteRevision ( int aRevNo)

Deletes a revision from the database. (The deletion will cascade to any associated changes.)

Parameters
aRevNoThe revision number to delete.
Returns
Whether or not the delete was successful.

◆ ExistingFilePaths()

wizard::RevisionPathSet wizard::RevisionDb::ExistingFilePaths ( int aRevNo)
Returns
All distinct file paths (relative paths) that exist in the database for the given revision.
Parameters
aRevNoA revision number.

Referenced by ExistingFiles().

◆ ExistingFiles()

wizard::FileMap wizard::RevisionDb::ExistingFiles ( int aRevNo)
Returns
A map of file paths to their contents for all files that exist in the database at the given revision.
Parameters
aRevNoA revision number.

References ExistingFilePaths(), and GetFileAtRevision().

Referenced by wizard::ExportFiles::ExportRevision().

◆ GetFileAtRevision()

bool wizard::RevisionDb::GetFileAtRevision ( const std::string & aRelFilePath,
int aRevision,
UtTextDocument & aDoc,
int * aRevisionsTraversed = nullptr )

Retrieves the version of a given file as it existed at a given revision. This is used for restoring files to old versions.

Parameters
aRelFilePathThe relative path of the file to look up in the database.
aRevisionThe revision of the file to fetch.
aDocA reference to a document object to which the content of the given file name at the given revision will be written.
aRevisionsTraversedThe number of revisions that needed to be traversed in order to build the file contents.
Returns
Whether or not the file existed at the given revision.

References wizard::ApplyToDocument(), wizard::RevisionChange::cCHANGE_DELTA, wizard::RevisionChange::cCHANGE_FULL, wizard::RevisionChange::cNEW_FILE, and wizard::RevisionChange::cREMOVED_FILE.

Referenced by ExistingFiles().

◆ InsertChange()

bool wizard::RevisionDb::InsertChange ( int aRevNo,
const RevisionChange & aChange )

Inserts a change for a given revision into the database.

Parameters
aRevNoThe revision number that the change belongs to.
aChangeThe change to insert.
Returns
Whether or not the insert was successful.

References wizard::RevisionChange::changeBytes, wizard::RevisionChange::filePath, InsertChange(), and wizard::RevisionChange::kind.

Referenced by InsertChange(), and InsertChanges().

◆ InsertChanges()

bool wizard::RevisionDb::InsertChanges ( int aRevNo,
const RevisionChangeList & aChangeList )

Inserts a list of changes for a given revision into the database.

Parameters
aRevNoThe revision number that the changes belong to.
aChangeListThe list of changes to insert.
Returns
Whether or not all of the inserts were successful.

References InsertChange(), and success.

Referenced by StoreNewRevision().

◆ InsertStartupFile()

bool wizard::RevisionDb::InsertStartupFile ( int aRevNo,
const std::string & aStartupFile )

Inserts a startup file associated with the given revision.

Referenced by InsertStartupFiles().

◆ InsertStartupFiles()

bool wizard::RevisionDb::InsertStartupFiles ( int aRevNo,
const std::vector< std::string > & aStartupFiles )

Inserts a list of startup files associated with the given revision.

References InsertStartupFile(), and success.

Referenced by StoreNewRevision().

◆ IsEmpty()

bool wizard::RevisionDb::IsEmpty ( )
Returns
Whether or not the database is empty.
Note
"The ROWID chosen for the new row is at least one larger than the largest ROWID that has ever before existed in that same table. If the table has never before contained any data, then a ROWID of 1 is used." – http://www.sqlite.org/autoinc.html

References LatestRevisionNo().

◆ IsOpen()

bool wizard::RevisionDb::IsOpen ( ) const
Returns
Whether or not the database is open.

◆ IsVersionOld()

bool wizard::RevisionDb::IsVersionOld ( )
Returns
Whether or not the version of the opened database is older than the latest available version.

References LatestSupportedVersion(), and Version().

◆ LatestRevisionNo()

int wizard::RevisionDb::LatestRevisionNo ( )
Returns
The latest revision number in the database.

Referenced by IsEmpty(), LatestStartupFiles(), LatestWorkingDirectory(), and NewRevisionNo().

◆ LatestStartupFiles()

bool wizard::RevisionDb::LatestStartupFiles ( std::vector< std::string > & aStartupFiles)
Returns
A list of startup files for the latest revision.

References LatestRevisionNo(), and StartupFiles().

Referenced by StoreNewRevision().

◆ LatestSupportedVersion()

int wizard::RevisionDb::LatestSupportedVersion ( ) const
Returns
The latest version of the database currently supported.

Referenced by IsVersionOld().

◆ LatestWorkingDirectory()

bool wizard::RevisionDb::LatestWorkingDirectory ( std::string & aWorkingDir)
Returns
The working directory for the latest revision.

References LatestRevisionNo(), and WorkingDirectory().

Referenced by StoreNewRevision().

◆ NewRevisionNo()

int wizard::RevisionDb::NewRevisionNo ( const std::string & aWorkingDir)

Creates a new revision number.

Returns
The newly created revision number

References LatestRevisionNo().

Referenced by StoreNewRevision().

◆ Open()

bool wizard::RevisionDb::Open ( const std::string & aDbPath)

Creates and/or opens a database at the given file path.

Parameters
aDbPathThe file path of the database to open.
Returns
Whether or not the database was successfully opened.

References success, and Version().

Referenced by OpenInMemory().

◆ OpenInMemory()

bool wizard::RevisionDb::OpenInMemory ( )

SQLite will create an in-memory database when opening a database with the special name ":memory:". The database will vanish when its connection closes. Particularly useful for tests.

Note
http://www.sqlite.org/c3ref/open.html
Returns
Whether or not a database was successfully opened in memory.

References Open().

◆ Revisions()

wizard::RevisionList wizard::RevisionDb::Revisions ( )
Returns
Data for all revisions in the database.

References wizard::Revision::startupFiles.

◆ StartupFiles()

bool wizard::RevisionDb::StartupFiles ( int aRevNo,
std::vector< std::string > & aStartupFiles )
Returns
A list of startup files for the given revision number.

Referenced by LatestStartupFiles().

◆ StoreNewRevision()

int wizard::RevisionDb::StoreNewRevision ( const RevisionChangeList & aChanges,
const std::string & aWorkingDir,
const std::vector< std::string > & aStartupFiles )

Stores a new revision of changes in the database.

Parameters
aChangesThe list of file changes to insert for the new revision.
aWorkingDirThe project working directory to insert for the new revision.
aStartupFilesThe list of project startup files to insert for the new revision.
Returns
The new revision number (if successful) or -1 (if unsuccessful).

References InsertChanges(), InsertStartupFiles(), LatestStartupFiles(), LatestWorkingDirectory(), and NewRevisionNo().

◆ Version()

int wizard::RevisionDb::Version ( )

This should not be used in the same way the other statements are used with ViSqlStmt objects. The version specifically will have to be checked before initializing all the other statements, so that the database can be upgraded from earlier versions if necessary.

Returns
The current version of the opened database.

References wizard::RevisionSqlStmt::Bind(), wizard::RevisionSqlStmt::ColInt(), wizard::RevisionSqlStmt::Finalize(), wizard::RevisionSqlStmt::Prepare(), wizard::RevisionSqlStmt::Reset(), and wizard::RevisionSqlStmt::Step().

Referenced by IsVersionOld(), and Open().

◆ WorkingDirectory()

bool wizard::RevisionDb::WorkingDirectory ( int aRevNo,
std::string & aWorkingDir )

Sets the reference aWorkingDir to the working directory of the given revision number.

Returns
Whether or not a working directory existed in the database for the given revision.

Referenced by LatestWorkingDirectory().


The documentation for this class was generated from the following files:
Copyrights Multiple, All Rights Reserved