180 const git_error* err = git_error_last();
182 _(
"Failed to open git repository: %s" ),
183 err ? wxString::FromUTF8( err->message ) : wxString(
"Unknown error" ) );
192 const git_error* err = git_error_last();
194 err ? wxString::FromUTF8( err->message ) : wxString(
"Unknown error" ) );
231 if( aStaleTimeoutSec <= 0 )
235 wxFileName lockPath( histPath, wxS(
".repo.lock" ) );
237 if( !lockPath.FileExists() )
241 if( !lockPath.GetTimes(
nullptr, &modTime,
nullptr ) )
244 wxDateTime now = wxDateTime::Now();
245 wxTimeSpan age = now - modTime;
248 (
int)age.GetSeconds().ToLong(), aStaleTimeoutSec );
250 return age.GetSeconds().ToLong() > aStaleTimeoutSec;
257 wxFileName lockPath( histPath, wxS(
".repo.lock" ) );
259 if( !lockPath.FileExists() )
263 wxFileName lockFilePath( histPath, wxS(
".repo" ) );
269 if( lockPath.FileExists() )
271 result = wxRemoveFile( lockPath.GetFullPath() );
275 wxLogError(
"Failed to remove stale lock: %s", lockPath.GetFullPath() );
278 if( lockFilePath.FileExists() )
280 bool lockFileResult = wxRemoveFile( lockFilePath.GetFullPath() );
282 wxLogTrace(
HISTORY_LOCK_TRACE,
"Removed stale lockfile: %s", lockFilePath.GetFullPath() );
wxString GetLockHolder() const
Get information about who currently holds the lock.
HISTORY_LOCK_MANAGER(const wxString &aProjectPath, int aStaleTimeoutSec=0)
Construct a lock manager and attempt to acquire locks.
~HISTORY_LOCK_MANAGER()
Destructor releases all locks and closes git repository.
wxString GetLockError() const
Get error message describing why lock could not be acquired.
static bool BreakStaleLock(const wxString &aProjectPath)
Forcibly remove a stale lock file.
std::unique_ptr< LOCKFILE > m_fileLock
static bool IsLockStale(const wxString &aProjectPath, int aStaleTimeoutSec=0)
Check if a lock file exists and is stale (older than timeout).
bool IsLocked() const
Check if locks were successfully acquired.
static wxString historyPath(const wxString &aProjectPath)
#define HISTORY_LOCK_TRACE
wxString result
Test unit parsing edge cases and error handling.