WSF
wizard::RevisionStore Class Reference

A high-level interface into the Change History database. More...

#include <RevisionStore.hpp>

Inherits QObject.

Public Slots

bool Backup ()
bool RequestBackup ()
void QueueFile (TextSource *aDocPtr)
void QueueAllProjectFiles ()
void HandleProxyAvailable (WsfPProxy *aProxy)
void HandleParseUpdated (bool aParsed)
void HandleProjectStartupFilesChanged (const std::vector< UtPath > &aStartupFiles)

Public Member Functions

 RevisionStore ()
 Default constructor.
 ~RevisionStore () override=default
void SetProject (const UtPath &aProjectDir, const UtPath &aProjectFile=UtPath())
void SetProjectWorkingDir (const UtPath &aWorkingDir)
bool Open ()
bool OpenInMemory ()
bool Close ()
bool IsEmpty ()
bool IsOpen () const
bool Exists () const
void EnableAutoBackup (int aMin)
void DisableAutoBackup ()
 Disables the automatic backup feature.
void QueueFile (const UtTextDocument *aDocPtr)
bool Restore (int aRevNo, QStringList &aFailedFiles, QWidget *aRequestingWidget=nullptr)
bool DeleteAllRevisions ()
RevisionList Revisions ()
RevisionDbDB ()

Protected Member Functions

RevisionChangeList GenerateFileChanges (const RevisionPathSet &aRemovedPaths=RevisionPathSet())
bool StoreNewRevision (const RevisionChangeList &aChanges, const std::string &aWorkingDir, const std::vector< std::string > &aStartupFiles)

Detailed Description

A high-level interface into the Change History database.

Constructor & Destructor Documentation

◆ RevisionStore()

wizard::RevisionStore::RevisionStore ( )
explicit

◆ ~RevisionStore()

Member Function Documentation

◆ Backup

bool wizard::RevisionStore::Backup ( )
slot

Blocks until parsing ends and then immediately attempts to create a backup. This will clear the "backup scheduled" flag if successful.

Returns
Whether or not the backup was successful.

References wizard::Project::Instance(), and wizard::Project::WaitForAllParsing().

Referenced by wizard::Editor::AcceptsClose(), Restore(), and ~RevisionStore().

◆ Close()

bool wizard::RevisionStore::Close ( )

Closes the connection to the revision database.

Returns
Whether or not the database was successfully closed.

References success.

Referenced by wizard::ExportFiles::ExportRevision(), and ~RevisionStore().

◆ DB()

wizard::RevisionDb & wizard::RevisionStore::DB ( )
Returns
The revision database.

Referenced by wizard::ExportFiles::ExportRevision(), and ~RevisionStore().

◆ DeleteAllRevisions()

bool wizard::RevisionStore::DeleteAllRevisions ( )

Deletes all revisions (and associated data) in the database.

Returns
Whether or not the database was open and the data was succesfully cleared.

References success.

Referenced by ~RevisionStore().

◆ DisableAutoBackup()

void wizard::RevisionStore::DisableAutoBackup ( )

Disables the automatic backup feature.

Referenced by EnableAutoBackup(), and ~RevisionStore().

◆ EnableAutoBackup()

void wizard::RevisionStore::EnableAutoBackup ( int aMin)

Sets the revision store to automatically backup every X minutes.

Parameters
aMinHow often (in minutes) an automatic backup should be created.

References DisableAutoBackup(), and RequestBackup().

Referenced by ~RevisionStore().

◆ Exists()

bool wizard::RevisionStore::Exists ( ) const
Returns
Whether or not the database file for the revision store exists on the file system.

Referenced by ~RevisionStore().

◆ GenerateFileChanges()

wizard::RevisionChangeList wizard::RevisionStore::GenerateFileChanges ( const RevisionPathSet & aRemovedPaths = RevisionPathSet())
protected

Generates a list of changes for all queued files and removed files since the last revision. Queued files will included newly added files.

Parameters
aRemovedPathsA set of relative paths to files that have been removed since the last revision.
Returns
A list of changes since the last revision.

References wizard::RevisionChange::cNO_CHANGE, wizard::RevisionChange::cREMOVED_FILE, and wizard::RevisionChange::kind.

Referenced by ~RevisionStore().

◆ HandleParseUpdated

void wizard::RevisionStore::HandleParseUpdated ( bool aParsed)
slot

Receives the signal that is sent when parsing has finished. A backup is performed if one has been scheduled.

Parameters
aParsedWhether or not parsing data is up to date.

Referenced by Open(), and ~RevisionStore().

◆ HandleProjectStartupFilesChanged

void wizard::RevisionStore::HandleProjectStartupFilesChanged ( const std::vector< UtPath > & aStartupFiles)
slot

Sets the project startup files. These will be associated with the current revision.

References RequestBackup().

Referenced by Open(), and ~RevisionStore().

◆ HandleProxyAvailable

void wizard::RevisionStore::HandleProxyAvailable ( WsfPProxy * aProxy)
slot

Receives the signal that is sent when the proxy becomes available or unavailable. A backup is performed if one has been scheduled.

Parameters
aProxyA valid proxy or NULL.

References QueueAllProjectFiles().

Referenced by Open(), and ~RevisionStore().

◆ IsEmpty()

bool wizard::RevisionStore::IsEmpty ( )
Returns
Whether or not the revision database is currently empty.

Referenced by ~RevisionStore().

◆ IsOpen()

bool wizard::RevisionStore::IsOpen ( ) const
Returns
Whether or not the revision/backup database is currently open.

Referenced by wizard::ExportFiles::ExportRevision(), and ~RevisionStore().

◆ Open()

◆ OpenInMemory()

bool wizard::RevisionStore::OpenInMemory ( )

Opens the revision database in memory. Useful for testing.

Returns
Whether or not the database was successfully opened.

Referenced by ~RevisionStore().

◆ QueueAllProjectFiles

void wizard::RevisionStore::QueueAllProjectFiles ( )
slot

Queues all included files in the project to be analyzed for changes during the next backup. This is useful upon a project first being opened (and receiving the first available proxy), so that all the files can be scanned for changes in the case that they were modified outside the Wizard since the last time the project was opened.

References wizard::TextSource::cINCLUDED, wizard::TextSource::GetFlags(), wizard::Project::GetSourceCache(), wizard::TextSourceCache::GetSources(), wizard::Project::Instance(), and QueueFile().

Referenced by HandleProxyAvailable(), and ~RevisionStore().

◆ QueueFile() [1/2]

void wizard::RevisionStore::QueueFile ( const UtTextDocument * aDocPtr)

Adds a file to the queue. This should be done if the file does not exist in the database or if its content has changed since the last revision.

Parameters
aDocPtrThe document object of the file to be queued.

Referenced by Open(), QueueAllProjectFiles(), QueueFile(), and ~RevisionStore().

◆ QueueFile [2/2]

void wizard::RevisionStore::QueueFile ( TextSource * aDocPtr)
slot

Slot used for connecting to "file modified" signals. Any file that's modified gets added to the queue.

Parameters
aDocPtrThe document object of a file that has been modified.

References QueueFile().

◆ RequestBackup

bool wizard::RevisionStore::RequestBackup ( )
slot

Requests a backup. If the proxy is available and the Wizard is not currently parsing when this method is called, a backup will be created immediately. Otherwise, a flag will be set and another backup will be attempted once parsing is finished and/or the proxy is available.

Returns
Whether or not a backup has been scheduled or, if the proxy was available and up to date (i.e. the Wizard was not parsing), whether or not the backup was successful.

References success.

Referenced by EnableAutoBackup(), HandleProjectStartupFilesChanged(), RevisionStore(), SetProjectWorkingDir(), and ~RevisionStore().

◆ Restore()

bool wizard::RevisionStore::Restore ( int aRevNo,
QStringList & aFailedFiles,
QWidget * aRequestingWidget = nullptr )

Creates a revision at the current point and then attempts to restore the user's files to the given revision number.

Warning
This function modifies the user's in-memory file content.
Parameters
aRevNoThe revision number to restore the user's files to.
aFailedFilesReference to a string list to hold the paths of files that failed to be restored, potentially due to lack of 'write' file permission.
aRequestingWidgetThe widget initiating the restore request.
Returns
Whether or not all files were successfully restored.

References Backup(), wizard::Project::Instance(), wizard::Project::SetStartupFiles(), wizard::Project::SetWorkingDirectory(), success, wizard::Project::TriggerReparse(), and wizRunMgr.

Referenced by ~RevisionStore().

◆ Revisions()

wizard::RevisionList wizard::RevisionStore::Revisions ( )
Returns
The data for all available revisions in the database.

Referenced by ~RevisionStore().

◆ SetProject()

void wizard::RevisionStore::SetProject ( const UtPath & aProjectDir,
const UtPath & aProjectFile = UtPath() )

Sets the project root directory and name. The database will be created in the project directory with a name based on the project name.

Parameters
aProjectDirThe project directory/root path.
aProjectFileThe project file path.

Referenced by ~RevisionStore().

◆ SetProjectWorkingDir()

void wizard::RevisionStore::SetProjectWorkingDir ( const UtPath & aWorkingDir)

Sets the project working directory. This will be stored as part of the revision.

References RequestBackup().

Referenced by ~RevisionStore().

◆ StoreNewRevision()

bool wizard::RevisionStore::StoreNewRevision ( const RevisionChangeList & aChanges,
const std::string & aWorkingDir,
const std::vector< std::string > & aStartupFiles )
protected

Stores a new revision in the database if there are queued files with changes or if files have been added or removed from the project.

Parameters
aChangesThe list of changes that make up the revision.
aWorkingDirThe name of the working directory.
aStartupFilesA container of the start-up file names.
Returns
Whether or not a new revision was successfully stored.

Referenced by ~RevisionStore().


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