1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // External Cache Copyright (C) 2005 - 2006, 2008 - TortoiseSVN
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
21 #include "StatusCacheEntry.h"
\r
22 #include "TGitPath.h"
\r
25 * \ingroup TSVNCache
\r
26 * Holds the status for a folder and all files and folders directly inside
\r
29 class CCachedDirectory
\r
32 typedef std::map<CTGitPath, CCachedDirectory *> CachedDirMap;
\r
33 typedef CachedDirMap::iterator ItDir;
\r
38 CCachedDirectory(const CTGitPath& directoryPath);
\r
39 ~CCachedDirectory(void);
\r
40 CStatusCacheEntry GetStatusForMember(const CTGitPath& path, bool bRecursive, bool bFetch = true);
\r
41 CStatusCacheEntry GetOwnStatus(bool bRecursive);
\r
42 bool IsOwnStatusValid() const;
\r
44 void RefreshStatus(bool bRecursive);
\r
45 void RefreshMostImportant();
\r
46 BOOL SaveToDisk(FILE * pFile);
\r
47 BOOL LoadFromDisk(FILE * pFile);
\r
48 /// Get the current full status of this folder
\r
49 git_wc_status_kind GetCurrentFullStatus() {return m_currentFullStatus;}
\r
51 static git_error_t* GetStatusCallback(void *baton, const char *path, git_wc_status2_t *status);
\r
52 void AddEntry(const CTGitPath& path, const git_wc_status2_t* pGitStatus, DWORD validuntil = 0);
\r
53 CString GetCacheKey(const CTGitPath& path);
\r
54 CString GetFullPathString(const CString& cacheKey);
\r
55 CStatusCacheEntry LookForItemInCache(const CTGitPath& path, bool &bFound);
\r
56 void UpdateChildDirectoryStatus(const CTGitPath& childDir, git_wc_status_kind childStatus);
\r
58 // Calculate the complete, composite status from ourselves, our files, and our descendants
\r
59 git_wc_status_kind CalculateRecursiveStatus();
\r
61 // Update our composite status and deal with things if it's changed
\r
62 void UpdateCurrentStatus();
\r
66 CComAutoCriticalSection m_critSec;
\r
67 CComAutoCriticalSection m_critSecPath;
\r
69 CTGitPath m_currentStatusFetchingPath;
\r
70 DWORD m_currentStatusFetchingPathTicks;
\r
71 // The cache of files and directories within this directory
\r
72 typedef std::map<CString, CStatusCacheEntry> CacheEntryMap;
\r
73 CacheEntryMap m_entryCache;
\r
75 /// A vector if iterators to child directories - used to put-together recursive status
\r
76 typedef std::map<CTGitPath, git_wc_status_kind> ChildDirStatus;
\r
77 ChildDirStatus m_childDirectories;
\r
79 // The timestamp of the .SVN\entries file. For an unversioned directory, this will be zero
\r
80 __int64 m_entriesFileTime;
\r
81 // The timestamp of the .SVN\props dir. For an unversioned directory, this will be zero
\r
82 __int64 m_propsFileTime;
\r
84 // The path of the directory with this object looks after
\r
85 CTGitPath m_directoryPath;
\r
87 // The status of THIS directory (not a composite of children or members)
\r
88 CStatusCacheEntry m_ownStatus;
\r
90 // Our current fully recursive status
\r
91 git_wc_status_kind m_currentFullStatus;
\r
92 bool m_bCurrentFullStatusValid;
\r
94 // The most important status from all our file entries
\r
95 git_wc_status_kind m_mostImportantFileStatus;
\r
97 bool m_bRecursive; // used in the status callback
\r
98 friend class CGitStatusCache;
\r