OSDN Git Service

RebaseDlg: Disable Reset\Swtich Command at context menu.
[tortoisegit/TortoiseGitJp.git] / src / TGitCache / CachedDirectory.h
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // External Cache Copyright (C) 2005 - 2006, 2008 - TortoiseSVN\r
4 \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
9 \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
14 \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
18 //\r
19 #pragma once\r
20 \r
21 #include "StatusCacheEntry.h"\r
22 #include "TGitPath.h"\r
23 \r
24 /**\r
25  * \ingroup TSVNCache\r
26  * Holds the status for a folder and all files and folders directly inside\r
27  * that folder.\r
28  */\r
29 class CCachedDirectory\r
30 {\r
31 public:\r
32         typedef std::map<CTGitPath, CCachedDirectory *> CachedDirMap; \r
33         typedef CachedDirMap::iterator ItDir;\r
34 \r
35 public:\r
36 \r
37         CCachedDirectory();\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
43         void Invalidate();\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
50 private:\r
51 //      static git_error_t* GetStatusCallback(void *baton, const char *path, git_wc_status2_t *status);\r
52         static BOOL GetStatusCallback(const struct wgFile_s *pFile, void *pUserData);\r
53         void AddEntry(const CTGitPath& path, const git_wc_status2_t* pGitStatus, DWORD validuntil = 0);\r
54         CString GetCacheKey(const CTGitPath& path);\r
55         CString GetFullPathString(const CString& cacheKey);\r
56         CStatusCacheEntry LookForItemInCache(const CTGitPath& path, bool &bFound);\r
57         void UpdateChildDirectoryStatus(const CTGitPath& childDir, git_wc_status_kind childStatus);\r
58 \r
59         // Calculate the complete, composite status from ourselves, our files, and our descendants\r
60         git_wc_status_kind CalculateRecursiveStatus();\r
61 \r
62         // Update our composite status and deal with things if it's changed\r
63         void UpdateCurrentStatus();\r
64 \r
65 \r
66 private:\r
67         CComAutoCriticalSection m_critSec;\r
68         CComAutoCriticalSection m_critSecPath;\r
69 \r
70         CTGitPath       m_currentStatusFetchingPath;\r
71         DWORD           m_currentStatusFetchingPathTicks;\r
72         // The cache of files and directories within this directory\r
73         typedef std::map<CString, CStatusCacheEntry> CacheEntryMap; \r
74         CacheEntryMap m_entryCache; \r
75 \r
76         /// A vector if iterators to child directories - used to put-together recursive status\r
77         typedef std::map<CTGitPath, git_wc_status_kind>  ChildDirStatus;\r
78         ChildDirStatus m_childDirectories;\r
79 \r
80         // The timestamp of the .git\index file.  For an unversioned directory, this will be zero\r
81         __int64 m_indexFileTime;\r
82         // The timestamp of the .SVN\props dir.  For an unversioned directory, this will be zero\r
83 //      __int64 m_propsFileTime;\r
84         \r
85         // The path of the directory with this object looks after\r
86         CTGitPath       m_directoryPath;\r
87 \r
88         // The status of THIS directory (not a composite of children or members)\r
89         CStatusCacheEntry m_ownStatus;\r
90 \r
91         // Our current fully recursive status\r
92         git_wc_status_kind  m_currentFullStatus;\r
93         bool m_bCurrentFullStatusValid;\r
94 \r
95         // The most important status from all our file entries\r
96         git_wc_status_kind m_mostImportantFileStatus;\r
97 \r
98         bool m_bRecursive;              // used in the status callback\r
99         friend class CGitStatusCache;           \r
100 };\r
101 \r