KiCad PCB EDA Suite
Loading...
Searching...
No Matches
local_history.cpp File Reference
#include <local_history.h>
#include <dialogs/dialog_restore_local_history.h>
#include <history_lock.h>
#include <paths.h>
#include <io/kicad/kicad_io_utils.h>
#include <lockfile.h>
#include <settings/common_settings.h>
#include <settings/settings_manager.h>
#include <pgm_base.h>
#include <thread_pool.h>
#include <trace_helpers.h>
#include <wildcards_and_files_ext.h>
#include <confirm.h>
#include <progress_reporter.h>
#include <kiplatform/io.h>
#include <git2.h>
#include <wx/filename.h>
#include <wx/filefn.h>
#include <wx/ffile.h>
#include <wx/dir.h>
#include <wx/datetime.h>
#include <wx/log.h>
#include <wx/msgdlg.h>
#include <vector>
#include <string>
#include <memory>
#include <algorithm>
#include <set>
#include <map>
#include <functional>
#include <cstring>

Go to the source code of this file.

Enumerations

enum class  SNAPSHOT_COMMIT_RESULT { Error , NoChanges , Committed }
 

Functions

static wxString historyPath (const wxString &aProjectPath)
 
static wxString joinHistoryDestination (const wxString &aHistoryRoot, const wxString &aRelativePath)
 
static wxString resolveAutosaveDestination (const wxString &aAutosaveRoot, const wxString &aRelativePath, BACKUP_LOCATION aLocation)
 
static wxString sourceForAutosaveFile (const wxString &aAutosavePath, const wxString &aProjectPath, const wxString &aAutosaveRoot, BACKUP_LOCATION aLocation)
 
static bool commitSnapshotForProject (const wxString &aProjectPath, const std::vector< wxString > &aFiles, const wxString &aTitle)
 
static bool formatUsesIncrementalHistory ()
 
static bool isProjectDirectory (const wxString &aProjectPath)
 
static bool isRestoreProtectedEntry (const wxString &aName)
 
static std::vector< std::pair< wxString, wxString > > findAutosaveFilePairs (const wxString &aProjectPath)
 
static SNAPSHOT_COMMIT_RESULT commitSnapshotWithLock (git_repository *repo, git_index *index, const wxString &aHistoryPath, const wxString &aProjectPath, const std::vector< wxString > &aFiles, const wxString &aTitle)
 
static bool isKiCadProjectFile (const wxFileName &aFile)
 
static void collectProjectFiles (const wxString &aProjectPath, std::vector< wxString > &aFiles)
 
static size_t dirSizeRecursive (const wxString &path)
 
static bool copyTreeObjects (git_repository *aSrcRepo, git_odb *aSrcOdb, git_odb *aDstOdb, const git_oid *aTreeOid, std::set< git_oid, bool(*)(const git_oid &, const git_oid &)> &aCopied)
 
static bool compactRepository (git_repository *aRepo, PROGRESS_REPORTER *aReporter=nullptr)
 

Variables

static const wxString AUTOSAVE_PREFIX = wxS( "_autosave-" )
 

Enumeration Type Documentation

◆ SNAPSHOT_COMMIT_RESULT

enum class SNAPSHOT_COMMIT_RESULT
strong
Enumerator
Error 
NoChanges 
Committed 

Definition at line 931 of file local_history.cpp.

Function Documentation

◆ collectProjectFiles()

static void collectProjectFiles ( const wxString & aProjectPath,
std::vector< wxString > & aFiles )
static

◆ commitSnapshotForProject()

static bool commitSnapshotForProject ( const wxString & aProjectPath,
const std::vector< wxString > & aFiles,
const wxString & aTitle )
static

◆ commitSnapshotWithLock()

static SNAPSHOT_COMMIT_RESULT commitSnapshotWithLock ( git_repository * repo,
git_index * index,
const wxString & aHistoryPath,
const wxString & aProjectPath,
const std::vector< wxString > & aFiles,
const wxString & aTitle )
static

◆ compactRepository()

static bool compactRepository ( git_repository * aRepo,
PROGRESS_REPORTER * aReporter = nullptr )
static

Definition at line 1501 of file local_history.cpp.

References name, and PROGRESS_REPORTER::SetCurrentProgress().

Referenced by LOCAL_HISTORY::EnforceSizeLimit().

◆ copyTreeObjects()

static bool copyTreeObjects ( git_repository * aSrcRepo,
git_odb * aSrcOdb,
git_odb * aDstOdb,
const git_oid * aTreeOid,
std::set< git_oid, bool(* aCopied )(const git_oid &, const git_oid &)> & )
static

Definition at line 1427 of file local_history.cpp.

References copyTreeObjects().

Referenced by copyTreeObjects(), and LOCAL_HISTORY::EnforceSizeLimit().

◆ dirSizeRecursive()

static size_t dirSizeRecursive ( const wxString & path)
static

Definition at line 1404 of file local_history.cpp.

References dirSizeRecursive(), name, and path.

Referenced by dirSizeRecursive(), and LOCAL_HISTORY::EnforceSizeLimit().

◆ findAutosaveFilePairs()

◆ formatUsesIncrementalHistory()

◆ historyPath()

static wxString historyPath ( const wxString & aProjectPath)
static

◆ isKiCadProjectFile()

static bool isKiCadProjectFile ( const wxFileName & aFile)
static

Definition at line 1120 of file local_history.cpp.

References name.

Referenced by collectProjectFiles().

◆ isProjectDirectory()

◆ isRestoreProtectedEntry()

static bool isRestoreProtectedEntry ( const wxString & aName)
static

Definition at line 189 of file local_history.cpp.

References PROJECT_BACKUPS_DIR_SUFFIX.

Referenced by collectProjectFiles().

◆ joinHistoryDestination()

static wxString joinHistoryDestination ( const wxString & aHistoryRoot,
const wxString & aRelativePath )
static

Definition at line 69 of file local_history.cpp.

Referenced by LOCAL_HISTORY::commitInBackground().

◆ resolveAutosaveDestination()

static wxString resolveAutosaveDestination ( const wxString & aAutosaveRoot,
const wxString & aRelativePath,
BACKUP_LOCATION aLocation )
static

Definition at line 101 of file local_history.cpp.

References AUTOSAVE_PREFIX, and PROJECT_DIR.

Referenced by LOCAL_HISTORY::RunRegisteredSaversAsAutosaveFiles().

◆ sourceForAutosaveFile()

static wxString sourceForAutosaveFile ( const wxString & aAutosavePath,
const wxString & aProjectPath,
const wxString & aAutosaveRoot,
BACKUP_LOCATION aLocation )
static

Definition at line 124 of file local_history.cpp.

References AUTOSAVE_PREFIX, name, and PROJECT_DIR.

Referenced by findAutosaveFilePairs().

Variable Documentation

◆ AUTOSAVE_PREFIX

const wxString AUTOSAVE_PREFIX = wxS( "_autosave-" )
static