|
KiCad PCB EDA Suite
|
Simple local history manager built on libgit2. More...
#include <local_history.h>
Static Public Member Functions | |
| static bool | Init (const wxString &aProjectPath) |
| Initialize the local history repository for the given project path. | |
| static bool | CommitSnapshot (const std::vector< wxString > &aFiles, const wxString &aTitle) |
| Commit the given files to the local history repository. | |
| static bool | CommitFullProjectSnapshot (const wxString &aProjectPath, const wxString &aTitle) |
| Commit a snapshot of the entire project directory (excluding the .history directory and ignored transient files) to the local history repository. | |
| static void | RegisterSaver (const std::function< void(const wxString &, std::vector< wxString > &)> &aSaver) |
| Register a saver callback invoked during autosave history commits. | |
| static bool | RunRegisteredSaversAndCommit (const wxString &aProjectPath, const wxString &aTitle) |
| Run all registered savers and, if any staged changes differ from HEAD, create a commit. | |
| static void | NoteFileChange (const wxString &aFile) |
| Record that a file has been modified and should be included in the next snapshot. | |
| static bool | CommitPending () |
| Commit any pending modified files to the history repository. | |
| static bool | HistoryExists (const wxString &aProjectPath) |
| Return true if history exists for the project. | |
| static bool | TagSave (const wxString &aProjectPath, const wxString &aFileType) |
| Tag a manual save in the local history repository. | |
| static bool | CommitDuplicateOfLastSave (const wxString &aProjectPath, const wxString &aFileType, const wxString &aMessage) |
| Create a new commit duplicating the tree pointed to by Last_Save_<fileType> and move the Last_Save_<fileType> tag to the new commit (used when user discards changes). | |
| static bool | EnforceSizeLimit (const wxString &aProjectPath, size_t aMaxBytes) |
| Enforce total size limit by rebuilding trimmed history keeping newest commits whose cumulative unique blob sizes fit within limit. | |
| static bool | HeadNewerThanLastSave (const wxString &aProjectPath) |
| Return true if the autosave data is newer than the last manual save. | |
| static wxString | GetHeadHash (const wxString &aProjectPath) |
| Return the current head commit hash. | |
| static bool | RestoreCommit (const wxString &aProjectPath, const wxString &aHash) |
| Restore the project files to the state recorded by the given commit hash. | |
| static void | ShowRestoreDialog (const wxString &aProjectPath, wxWindow *aParent) |
| Show a dialog allowing the user to choose a snapshot to restore. | |
Simple local history manager built on libgit2.
Stores history for project files in a hidden .history git repository within the project directory.
Definition at line 35 of file local_history.h.
|
static |
Create a new commit duplicating the tree pointed to by Last_Save_<fileType> and move the Last_Save_<fileType> tag to the new commit (used when user discards changes).
Definition at line 579 of file local_history.cpp.
References HISTORY_LOCK_MANAGER::GetRepository(), HISTORY_LOCK_MANAGER::IsLocked(), and traceAutoSave.
Referenced by PCB_EDIT_FRAME::canCloseWindow(), and SCH_EDIT_FRAME::canCloseWindow().
|
static |
Commit a snapshot of the entire project directory (excluding the .history directory and ignored transient files) to the local history repository.
This does not modify any document dirty flags; it purely mirrors on-disk state for history purposes.
Definition at line 418 of file local_history.cpp.
References CommitSnapshot(), name, and path.
Referenced by RestoreCommit(), PCB_EDIT_FRAME::SavePcbFile(), and SCH_EDIT_FRAME::saveSchematicFile().
|
static |
Commit any pending modified files to the history repository.
Definition at line 259 of file local_history.cpp.
References CommitSnapshot(), and s_pendingFiles.
|
static |
Commit the given files to the local history repository.
Definition at line 301 of file local_history.cpp.
References delta, HISTORY_LOCK_MANAGER::GetIndex(), HISTORY_LOCK_MANAGER::GetLockError(), HISTORY_LOCK_MANAGER::GetRepository(), historyPath(), HISTORY_LOCK_MANAGER::IsLocked(), Pgm(), and traceAutoSave.
Referenced by CommitFullProjectSnapshot(), and CommitPending().
|
static |
Enforce total size limit by rebuilding trimmed history keeping newest commits whose cumulative unique blob sizes fit within limit.
Definition at line 671 of file local_history.cpp.
References dirSizeRecursive(), HISTORY_LOCK_MANAGER::GetRepository(), historyPath(), HISTORY_LOCK_MANAGER::IsLocked(), name, and traceAutoSave.
Referenced by KICAD_MANAGER_FRAME::CloseProject().
|
static |
Return the current head commit hash.
Definition at line 1028 of file local_history.cpp.
References historyPath().
Referenced by KICAD_MANAGER_FRAME::LoadProject(), and RestoreCommit().
|
static |
Return true if the autosave data is newer than the last manual save.
Definition at line 529 of file local_history.cpp.
References historyPath().
Referenced by KICAD_MANAGER_FRAME::LoadProject().
|
static |
Return true if history exists for the project.
Definition at line 474 of file local_history.cpp.
References historyPath().
Referenced by PCB_EDIT_FRAME::canCloseWindow(), SCH_EDIT_FRAME::canCloseWindow(), KICAD_MANAGER_FRAME::doReCreateMenuBar(), and ShowRestoreDialog().
|
static |
Initialize the local history repository for the given project path.
Definition at line 267 of file local_history.cpp.
References historyPath(), and Pgm().
Referenced by EDA_BASE_FRAME::CommonSettingsChanged(), KICAD_MANAGER_FRAME::LoadProject(), PCB_EDIT_FRAME::OnBoardLoaded(), PCB_EDIT_FRAME::OpenProjectFiles(), and SCH_EDIT_FRAME::OpenProjectFiles().
|
static |
Record that a file has been modified and should be included in the next snapshot.
Definition at line 60 of file local_history.cpp.
References Pgm(), and s_pendingFiles.
Referenced by PCB_EDIT_FRAME::OnModify(), and SCH_EDIT_FRAME::OnModify().
|
static |
Register a saver callback invoked during autosave history commits.
The callback receives the project path and should append absolute file paths (within that project) to aFiles for inclusion.
Definition at line 71 of file local_history.cpp.
References s_savers.
Referenced by EDA_BASE_FRAME::EDA_BASE_FRAME(), ensureSchSaverRegistered(), and PCB_EDIT_FRAME::ProjectChanged().
|
static |
Restore the project files to the state recorded by the given commit hash.
Definition at line 1048 of file local_history.cpp.
References CommitFullProjectSnapshot(), GetHeadHash(), HISTORY_LOCK_MANAGER::GetRepository(), HISTORY_LOCK_MANAGER::IsLocked(), LOCKFILE::IsLockedByMe(), name, traceAutoSave, and LOCKFILE::Valid().
Referenced by KICAD_MANAGER_FRAME::LoadProject(), KICAD_MANAGER_FRAME::RestoreCommitFromHistory(), and ShowRestoreDialog().
|
static |
Run all registered savers and, if any staged changes differ from HEAD, create a commit.
Definition at line 76 of file local_history.cpp.
References Pgm(), s_savers, and traceAutoSave.
Referenced by EDA_BASE_FRAME::doAutoSave().
|
static |
Show a dialog allowing the user to choose a snapshot to restore.
Definition at line 1415 of file local_history.cpp.
References _, HistoryExists(), historyPath(), and RestoreCommit().
Referenced by KICAD_MANAGER_FRAME::RestoreLocalHistory().
|
static |
Tag a manual save in the local history repository.
Definition at line 479 of file local_history.cpp.
References HISTORY_LOCK_MANAGER::GetRepository(), HISTORY_LOCK_MANAGER::IsLocked(), and traceAutoSave.
Referenced by PCB_EDIT_FRAME::SavePcbFile(), and SCH_EDIT_FRAME::saveSchematicFile().