NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
|
#include <filerevisions.hpp>
Public Member Functions | |
FileRevisions (const wxString &revisionPath) | |
Constructor. Will try to create the missing folders on-the-fly. More... | |
size_t | getRevisionCount () |
Returns the number of available revisions. More... | |
wxArrayString | getRevisionList () |
This method returns a log-like list of revisions. More... | |
wxString | getCurrentRevision () |
This method returns the revision identifier of the current revision. More... | |
size_t | addRevision (const wxString &revisionContent) |
This method adds a new revision. More... | |
size_t | addExternalRevision (const wxString &filePath) |
This method adds an external modification as new revision. More... | |
void | undoRevision () |
This method removes the last added revision. More... | |
void | renameFile (const wxString &oldName, const wxString &newName, const wxString &newRevPath) |
This method handles renames of the corresponding file. More... | |
void | moveFile (const wxString &oldPath, const wxString &newPath, const wxString &newRevPath) |
This method handles moves of the corresponding file. More... | |
wxString | getRevision (size_t nRevision) |
Returns the contents of the selected revision. More... | |
wxString | getRevision (wxString revString) |
Returns the contents of the selected revision. More... | |
wxString | compareRevisions (const wxString &rev1, const wxString &rev2) |
This member function compares two revisions with each other and returns the differnces as unified diff. More... | |
void | restoreRevision (size_t nRevision, const wxString &targetFile) |
This method will restore the contents of the selected revision. More... | |
void | restoreRevision (const wxString &revString, const wxString &targetFile) |
This method will restore the contents of the selected revision. More... | |
size_t | tagRevision (size_t nRevision, const wxString &tagComment) |
Allows the user to tag a selected revision with the passed comment. More... | |
size_t | tagRevision (const wxString &revString, const wxString &tagComment) |
Allows the user to tag a selected revision with the passed comment. More... | |
Private Member Functions | |
std::vector< wxString > | vectorize (wxString fileContent) |
Converts a single-string file into a vector of strings. More... | |
wxString | convertLineEndings (const wxString &content) |
This method converts line end characters. More... | |
wxString | readRevision (const wxString &revString) |
This method returns the contents of the selected revision. More... | |
wxString | getLastContentModification (const wxString &revString) |
This method returns the last modification revision identifier. More... | |
wxString | getLastRevisionRoot (const wxString &revString) |
This method returns the revision identifier of the last revision root. More... | |
wxString | diff (const wxString &revision1, const wxString &revisionID1, const wxString &revision2, const wxString &revisionID2) |
This method calculates the differences between two files. More... | |
wxString | createDiff (const wxString &revisionContent) |
This method creates the file differences between the file contents and the current revision root. More... | |
wxString | createMerge (const wxString &diffFile) |
This method merges the diff file into the current revision root. More... | |
wxString | readExternalFile (const wxString &filePath) |
This method reads an external file into a string. More... | |
size_t | createNewRevision (const wxString &revContent, const wxString &comment) |
This method creates a new revision. More... | |
size_t | createNewTag (const wxString &revString, const wxString &comment) |
This method creates a new tag for the passed revision. More... | |
void | fileMove (const wxString &newRevPath, const wxString &comment) |
This method handles all file move operations. More... | |
size_t | getMaxDiffFileSize (size_t nFileSize) |
This member function returns the maximal Diff file size. More... | |
Private Attributes | |
wxFileName | m_revisionPath |
Definition at line 26 of file filerevisions.hpp.
FileRevisions::FileRevisions | ( | const wxString & | revisionPath | ) |
Constructor. Will try to create the missing folders on-the-fly.
revisionPath | const wxString& |
Definition at line 39 of file filerevisions.cpp.
References m_revisionPath.
size_t FileRevisions::addExternalRevision | ( | const wxString & | filePath | ) |
This method adds an external modification as new revision.
filePath | const wxString& |
The revision is only appended, if its a real file contents change. Therefore the content of the external modification is compared to the current revision available in the list and only appended, if they are different. This will avoid creating revisions resulting from file meta data updates.
Definition at line 795 of file filerevisions.cpp.
References convertLineEndings(), createNewRevision(), diff(), getCurrentRevision(), getRevision(), and readExternalFile().
size_t FileRevisions::addRevision | ( | const wxString & | revisionContent | ) |
This method adds a new revision.
revisionContent | const wxString& |
If there's no revisions file yet, this method will create a new one containing the revisions content's as so-called "initial revision".
Definition at line 748 of file filerevisions.cpp.
References COMPRESSIONLEVEL, convertLineEndings(), createDiff(), createNewRevision(), getCurrentRevision(), getMaxDiffFileSize(), getRevision(), and m_revisionPath.
wxString FileRevisions::compareRevisions | ( | const wxString & | rev1, |
const wxString & | rev2 | ||
) |
This member function compares two revisions with each other and returns the differnces as unified diff.
rev1 | const wxString& |
rev2 | const wxString& |
Definition at line 658 of file filerevisions.cpp.
References diff(), and getRevision().
Referenced by RevisionDialog::compareRevisions().
|
private |
This method converts line end characters.
content | const wxString& |
Windows line ending characters (CR LF) are converted into unix line endings (LF), which are used by the internal ZIP file system
Definition at line 89 of file filerevisions.cpp.
Referenced by addExternalRevision(), addRevision(), createMerge(), diff(), and restoreRevision().
|
private |
This method creates the file differences between the file contents and the current revision root.
revisionContent | const wxString& |
The file differences are created in the private FileRevisions::diff() method- The current revision root is detected automatically.
Definition at line 277 of file filerevisions.cpp.
References diff(), getCurrentRevision(), getLastRevisionRoot(), getRevision(), getRevisionCount(), and toString().
Referenced by addRevision().
|
private |
This method merges the diff file into the current revision root.
diffFile | const wxString& |
The passed diff file is used to determine the revision root, which it is based upon. Both files are vectorized first, then the changes noted in the revision file are applied to the contents of the revision root, which is merged back into a single-string file afterwards.
Definition at line 298 of file filerevisions.cpp.
References convertLineEndings(), getRevision(), and vectorize().
Referenced by readRevision().
|
private |
This method creates a new revision.
revContent | const wxString& |
comment | const wxString& |
The revision is appended to the already available list of revisions at the end. The contents of the revision are stored completely in the target ZIP file.
Definition at line 389 of file filerevisions.cpp.
References COMPRESSIONLEVEL, getRevisionCount(), m_revisionPath, and toString().
Referenced by addExternalRevision(), addRevision(), fileMove(), and restoreRevision().
|
private |
This method creates a new tag for the passed revision.
revString | const wxString& |
comment | const wxString& |
The new tag is appended directly below the corresponding revision. After the new tag, the remaing parts of the file are appended
Definition at line 440 of file filerevisions.cpp.
References COMPRESSIONLEVEL, getRevisionCount(), m_revisionPath, and toString().
Referenced by tagRevision().
|
private |
This method calculates the differences between two files.
revision1 | const wxString& |
revisionID1 | const wxString& |
revision2 | const wxString& |
revisionID2 | const wxString& |
The file differences are created by the DTL libary found in the "common" folder. The differences are returned in unified format, i.e. containing sequences of changes starting with a "@@ -a,b +c,d @@" section
Definition at line 241 of file filerevisions.cpp.
References dtl::Diff< elem, sequence, comparator >::compose(), dtl::Diff< elem, sequence, comparator >::composeUnifiedHunks(), convertLineEndings(), dtl::Diff< elem, sequence, comparator >::printUnifiedFormat(), and vectorize().
Referenced by addExternalRevision(), compareRevisions(), and createDiff().
|
private |
This method handles all file move operations.
newRevPath | const wxString& |
comment | const wxString& |
File move operations are move and rename operations. Those are reflected in the name and the location of the revisions file.
Definition at line 497 of file filerevisions.cpp.
References createNewRevision(), getCurrentRevision(), and m_revisionPath.
Referenced by moveFile(), and renameFile().
wxString FileRevisions::getCurrentRevision | ( | ) |
This method returns the revision identifier of the current revision.
It excludes all tags, which are attached to the current revision, because they do not contain any file changes.
Definition at line 588 of file filerevisions.cpp.
References getRevisionList().
Referenced by addExternalRevision(), addRevision(), createDiff(), fileMove(), and RevisionDialog::populateRevisionList().
|
private |
This method returns the last modification revision identifier.
revString | const wxString& |
The last content modification (no tag and no file move operation) is returned. The algorithm starts his search from the passed revision identifier string backwards in history.
Definition at line 161 of file filerevisions.cpp.
References getRevisionList().
Referenced by getRevision().
|
private |
This method returns the revision identifier of the last revision root.
revString | const wxString& |
The revision model is based upon comparing the new revisions with a revision root and saving only the difference between those two. The root revision may change upon time, because if the difference between the root and the current item is larger than the current item, the current item is the new revision root. Revision root items are marked by the absence of any ZIP comment except of the initial revision, which is the first root
Definition at line 202 of file filerevisions.cpp.
References getRevisionList().
Referenced by createDiff().
|
private |
This member function returns the maximal Diff file size.
nFileSize | size_t The size of the stored file |
Definition at line 519 of file filerevisions.cpp.
References getRevisionCount().
Referenced by addRevision().
wxString FileRevisions::getRevision | ( | size_t | nRevision | ) |
Returns the contents of the selected revision.
nRevision | size_t |
If the selected revision is not a content modification revision, the algorithm will search for the last previous revision containing file changes.
Definition at line 612 of file filerevisions.cpp.
References getRevision(), m_revisionPath, and toString().
Referenced by addExternalRevision(), addRevision(), compareRevisions(), createDiff(), createMerge(), getRevision(), restoreRevision(), and RevisionDialog::showRevision().
wxString FileRevisions::getRevision | ( | wxString | revString | ) |
Returns the contents of the selected revision.
revString | wxString |
If the selected revision is not a content modification revision, the algorithm will search for the last previous revision containing file changes.
Definition at line 631 of file filerevisions.cpp.
References getLastContentModification(), m_revisionPath, and readRevision().
size_t FileRevisions::getRevisionCount | ( | ) |
Returns the number of available revisions.
Definition at line 534 of file filerevisions.cpp.
References m_revisionPath.
Referenced by createDiff(), createNewRevision(), createNewTag(), getMaxDiffFileSize(), and undoRevision().
wxArrayString FileRevisions::getRevisionList | ( | ) |
This method returns a log-like list of revisions.
The returned string array can be used to display a log of all revisions done to the corresponding file. The list contains actual revisions, tags and file move operations. The list contains date-time and comments of the revisions. These are tab-separated from the revision identifiers.
Definition at line 557 of file filerevisions.cpp.
References m_revisionPath.
Referenced by getCurrentRevision(), getLastContentModification(), getLastRevisionRoot(), and RevisionDialog::populateRevisionList().
void FileRevisions::moveFile | ( | const wxString & | oldPath, |
const wxString & | newPath, | ||
const wxString & | newRevPath | ||
) |
This method handles moves of the corresponding file.
oldPath | const wxString& |
newPath | const wxString& |
newRevPath | const wxString& |
This change is reflected on the revisions file, which is also moved as well.
Definition at line 885 of file filerevisions.cpp.
References fileMove().
|
private |
This method reads an external file into a string.
filePath | const wxString& |
The method is used to include external modifications into the set of revisions, if these are actual modifications. The file is read with windows line endings (CR LF)
Definition at line 357 of file filerevisions.cpp.
Referenced by addExternalRevision().
|
private |
This method returns the contents of the selected revision.
revString | const wxString& |
The UTF8 multi-byte characters in the ZIP file are converted automatically in wide chars during reading the file. Also, the line ending characters are converted to windows line endings (CR LF)
Definition at line 111 of file filerevisions.cpp.
References createMerge(), and m_revisionPath.
Referenced by getRevision().
void FileRevisions::renameFile | ( | const wxString & | oldName, |
const wxString & | newName, | ||
const wxString & | newRevPath | ||
) |
This method handles renames of the corresponding file.
oldName | const wxString& |
newName | const wxString& |
newRevPath | const wxString& |
This change is reflected on the revisions file, which is also renamed as well.
Definition at line 868 of file filerevisions.cpp.
References fileMove().
void FileRevisions::restoreRevision | ( | const wxString & | revString, |
const wxString & | targetFile | ||
) |
This method will restore the contents of the selected revision.
revString | const wxString& |
targetFile | const wxString& |
The contents of the revision are written to the file, which has been selected as second argument.
Definition at line 696 of file filerevisions.cpp.
References convertLineEndings(), createNewRevision(), and getRevision().
void FileRevisions::restoreRevision | ( | size_t | nRevision, |
const wxString & | targetFile | ||
) |
This method will restore the contents of the selected revision.
nRevision | size_t |
targetFile | const wxString& |
The contents of the revision are written to the file, which has been selected as second argument.
Definition at line 674 of file filerevisions.cpp.
References convertLineEndings(), createNewRevision(), getRevision(), and toString().
Referenced by RevisionDialog::OnMenuEvent().
size_t FileRevisions::tagRevision | ( | const wxString & | revString, |
const wxString & | tagComment | ||
) |
Allows the user to tag a selected revision with the passed comment.
revString | const wxString& |
tagComment | const wxString& |
Definition at line 732 of file filerevisions.cpp.
References createNewTag().
size_t FileRevisions::tagRevision | ( | size_t | nRevision, |
const wxString & | tagComment | ||
) |
Allows the user to tag a selected revision with the passed comment.
nRevision | size_t |
tagComment | const wxString& |
Definition at line 716 of file filerevisions.cpp.
References createNewTag(), and toString().
Referenced by RevisionDialog::OnMenuEvent().
void FileRevisions::undoRevision | ( | ) |
This method removes the last added revision.
Definition at line 822 of file filerevisions.cpp.
References COMPRESSIONLEVEL, getRevisionCount(), m_revisionPath, and toString().
|
private |
Converts a single-string file into a vector of strings.
fileContent | wxString |
The file is split at the line break character so that each component of the vector is a single line of the passed file
Definition at line 55 of file filerevisions.cpp.
Referenced by createMerge(), and diff().
|
private |
Definition at line 29 of file filerevisions.hpp.
Referenced by addRevision(), createNewRevision(), createNewTag(), fileMove(), FileRevisions(), getRevision(), getRevisionCount(), getRevisionList(), readRevision(), and undoRevision().