1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2012 - TortoiseGit
4 // Copyright (C) 2003-2006,2008,2011 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "GitStatus.h"
24 #include "SmartHandle.h"
26 typedef struct FileStatusCacheEntry
28 git_wc_status_kind status
;
32 } FileStatusCacheEntry
;
34 #define GITFOLDERSTATUS_CACHETIMES 10
35 #define GITFOLDERSTATUS_CACHETIMEOUT 2000
36 #define GITFOLDERSTATUS_RECURSIVECACHETIMEOUT 4000
37 #define GITFOLDERSTATUS_FOLDER 500
39 * \ingroup TortoiseShell
40 * This class represents a caching mechanism for the
41 * subversion statuses. Once a status for a versioned
42 * file is requested (GetFileStatus()) first its checked
43 * if that status is already in the cache. If it is not
44 * then the subversion statuses for ALL files in the same
45 * directory is fetched and cached. This is because subversion
46 * needs almost the same time to get one or all status (in
47 * the same directory).
48 * To prevent a cache flush for the explorer folder view
49 * the cache is only fetched for versioned files and
55 GitFolderStatus(void);
56 ~GitFolderStatus(void);
57 const FileStatusCacheEntry
* GetFullStatus(const CTGitPath
& filepath
, BOOL bIsFolder
, BOOL bColumnProvider
= FALSE
);
58 const FileStatusCacheEntry
* GetCachedItem(const CTGitPath
& filepath
);
60 FileStatusCacheEntry invalidstatus
;
62 GitStatus m_GitStatus
;
65 const FileStatusCacheEntry
* BuildCache(const CTGitPath
& filepath
, const CString
& sProjectRoot
, BOOL bIsFolder
, BOOL bDirectFolder
= FALSE
);
66 DWORD
GetTimeoutValue();
71 typedef std::map
<stdstring
, FileStatusCacheEntry
> FileStatusMap
;
72 FileStatusMap m_cache
;
74 FileStatusCacheEntry dirstat
;
75 FileStatusCacheEntry filestat
;
76 git_wc_status2_t
* dirstatus
;
80 CAutoGeneralHandle m_hInvalidationEvent
;
82 // The item we most recently supplied status for
83 CTGitPath m_mostRecentPath
;
84 const FileStatusCacheEntry
* m_mostRecentStatus
;