1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-2006,2008 - Stefan Kueng
\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 "GitStatus.h"
\r
22 #include "TGitPath.h"
\r
25 * \ingroup TortoiseShell
\r
26 * a simple utility class:
\r
27 * stores unique copies of given string values,
\r
28 * i.e. for a given value, always the same const char*
\r
31 * The strings returned are owned by the pool!
\r
37 StringPool() {emptyString[0] = 0;}
\r
38 ~StringPool() {clear();}
\r
41 * Return a string equal to value from the internal pool.
\r
42 * If no such string is available, a new one is allocated.
\r
43 * NULL is valid for value.
\r
45 const char* GetString (const char* value);
\r
48 * invalidates all strings returned by GetString()
\r
49 * frees all internal data
\r
55 // comparator: compare C-style strings
\r
59 bool operator()(const char* lhs, const char* rhs) const
\r
61 return strcmp (lhs, rhs) < 0;
\r
65 // store the strings in a map
\r
66 // caution: modifying the map must not modify the string pointers
\r
68 typedef std::set<const char*, LessString> pool_type;
\r
70 char emptyString[1];
\r
74 typedef struct FileStatusCacheEntry
\r
76 git_wc_status_kind status;
\r
77 const char* author; ///< points to a (possibly) shared value
\r
78 const char* url; ///< points to a (possibly) shared value
\r
79 const char* owner; ///< points to a (possible) lock owner
\r
83 //git_lock_t * lock;
\r
85 } FileStatusCacheEntry;
\r
87 #define GITFOLDERSTATUS_CACHETIMES 10
\r
88 #define GITFOLDERSTATUS_CACHETIMEOUT 2000
\r
89 #define GITFOLDERSTATUS_RECURSIVECACHETIMEOUT 4000
\r
90 #define GITFOLDERSTATUS_FOLDER 500
\r
92 * \ingroup TortoiseShell
\r
93 * This class represents a caching mechanism for the
\r
94 * subversion statuses. Once a status for a versioned
\r
95 * file is requested (GetFileStatus()) first its checked
\r
96 * if that status is already in the cache. If it is not
\r
97 * then the subversion statuses for ALL files in the same
\r
98 * directory is fetched and cached. This is because subversion
\r
99 * needs almost the same time to get one or all status (in
\r
100 * the same directory).
\r
101 * To prevent a cache flush for the explorer folder view
\r
102 * the cache is only fetched for versioned files and
\r
105 class GitFolderStatus
\r
108 GitFolderStatus(void);
\r
109 ~GitFolderStatus(void);
\r
110 const FileStatusCacheEntry * GetFullStatus(const CTGitPath& filepath, BOOL bIsFolder, BOOL bColumnProvider = FALSE);
\r
111 const FileStatusCacheEntry * GetCachedItem(const CTGitPath& filepath);
\r
113 FileStatusCacheEntry invalidstatus;
\r
116 const FileStatusCacheEntry * BuildCache(const CTGitPath& filepath, const CString& sProjectRoot, BOOL bIsFolder, BOOL bDirectFolder = FALSE);
\r
117 DWORD GetTimeoutValue();
\r
118 //static git_error_t* fillstatusmap (void *baton, const char *path, git_wc_status2_t *status, apr_pool_t *pool);
\r
119 //static git_error_t* findfolderstatus (void *baton, const char *path, git_wc_status2_t *status, apr_pool_t *pool);
\r
120 static BOOL fillstatusmap(const struct wgFile_s *pFile, void *pUserData);
\r
121 static CTGitPath folderpath;
\r
125 typedef std::map<stdstring, FileStatusCacheEntry> FileStatusMap;
\r
126 FileStatusMap m_cache;
\r
128 FileStatusCacheEntry dirstat;
\r
129 FileStatusCacheEntry filestat;
\r
130 git_wc_status2_t * dirstatus;
\r
131 //apr_pool_t * rootpool;
\r
133 // merging these pools won't save memory
\r
134 // but access will become slower
\r
136 StringPool authors;
\r
139 char emptyString[1];
\r
141 stdstring sCacheKey;
\r
143 HANDLE m_hInvalidationEvent;
\r
145 // The item we most recently supplied status for
\r
146 CTGitPath m_mostRecentPath;
\r
147 const FileStatusCacheEntry* m_mostRecentStatus;
\r