OSDN Git Service

Fix crash when input character at filter box
[tortoisegit/TortoiseGitJp.git] / src / TGitCache / SVNStatusCache.cpp
index ececade..8afbcd9 100644 (file)
 //\r
 \r
 #include "StdAfx.h"\r
-#include "SVNStatus.h"\r
-#include "Svnstatuscache.h"\r
+#include "GitStatus.h"\r
+#include "GitStatuscache.h"\r
 #include "CacheInterface.h"\r
 #include "shlobj.h"\r
 \r
 //////////////////////////////////////////////////////////////////////////\r
 \r
-CSVNStatusCache* CSVNStatusCache::m_pInstance;\r
+CGitStatusCache* CGitStatusCache::m_pInstance;\r
 \r
-CSVNStatusCache& CSVNStatusCache::Instance()\r
+CGitStatusCache& CGitStatusCache::Instance()\r
 {\r
        ATLASSERT(m_pInstance != NULL);\r
        return *m_pInstance;\r
 }\r
 \r
-void CSVNStatusCache::Create()\r
+void CGitStatusCache::Create()\r
 {\r
        ATLASSERT(m_pInstance == NULL);\r
-       m_pInstance = new CSVNStatusCache;\r
+       m_pInstance = new CGitStatusCache;\r
 \r
        m_pInstance->watcher.SetFolderCrawler(&m_pInstance->m_folderCrawler);\r
 #define LOADVALUEFROMFILE(x) if (fread(&x, sizeof(x), 1, pFile)!=1) goto exit;\r
@@ -48,7 +48,7 @@ void CSVNStatusCache::Create()
        TCHAR path2[MAX_PATH];\r
        if (SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, path)==S_OK)\r
        {\r
-               _tcscat_s(path, MAX_PATH, _T("\\TSVNCache"));\r
+               _tcscat_s(path, MAX_PATH, _T("\\TGitCache"));\r
                if (!PathIsDirectory(path))\r
                {\r
                        if (CreateDirectory(path, NULL)==0)\r
@@ -97,12 +97,12 @@ void CSVNStatusCache::Create()
                                                        goto error;\r
                                                if (!cacheddir->LoadFromDisk(pFile))\r
                                                        goto error;\r
-                                               CTSVNPath KeyPath = CTSVNPath(sKey);\r
+                                               CTGitPath KeyPath = CTGitPath(sKey);\r
                                                if (m_pInstance->IsPathAllowed(KeyPath))\r
                                                {\r
                                                        m_pInstance->m_directoryCache[KeyPath] = cacheddir;\r
                                                        // only add the path to the watch list if it is versioned\r
-                                                       if ((cacheddir->GetCurrentFullStatus() != svn_wc_status_unversioned)&&(cacheddir->GetCurrentFullStatus() != svn_wc_status_none))\r
+                                                       if ((cacheddir->GetCurrentFullStatus() != git_wc_status_unversioned)&&(cacheddir->GetCurrentFullStatus() != git_wc_status_none))\r
                                                                m_pInstance->watcher.AddPath(KeyPath);\r
                                                        // do *not* add the paths for crawling!\r
                                                        // because crawled paths will trigger a shell\r
@@ -134,11 +134,11 @@ error:
                Sleep(100);\r
        }\r
        delete m_pInstance;\r
-       m_pInstance = new CSVNStatusCache;\r
+       m_pInstance = new CGitStatusCache;\r
        ATLTRACE("cache not loaded from disk\n");\r
 }\r
 \r
-bool CSVNStatusCache::SaveCache()\r
+bool CGitStatusCache::SaveCache()\r
 {\r
 #define WRITEVALUETOFILE(x) if (fwrite(&x, sizeof(x), 1, pFile)!=1) goto error;\r
        unsigned int value = 0;\r
@@ -148,7 +148,7 @@ bool CSVNStatusCache::SaveCache()
        TCHAR path[MAX_PATH];           //MAX_PATH ok here.\r
        if (SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, path)==S_OK)\r
        {\r
-               _tcscat_s(path, MAX_PATH, _T("\\TSVNCache"));\r
+               _tcscat_s(path, MAX_PATH, _T("\\TGitCache"));\r
                if (!PathIsDirectory(path))\r
                        CreateDirectory(path, NULL);\r
                _tcscat_s(path, MAX_PATH, _T("\\cache"));\r
@@ -196,7 +196,7 @@ error:
        return false;\r
 }\r
 \r
-void CSVNStatusCache::Destroy()\r
+void CGitStatusCache::Destroy()\r
 {\r
        if (m_pInstance)\r
        {\r
@@ -207,38 +207,38 @@ void CSVNStatusCache::Destroy()
        m_pInstance = NULL;\r
 }\r
 \r
-void CSVNStatusCache::Stop()\r
+void CGitStatusCache::Stop()\r
 {\r
-       m_svnHelp.Cancel(true);\r
+//     m_svnHelp.Cancel(true);\r
        watcher.Stop();\r
        m_folderCrawler.Stop();\r
        m_shellUpdater.Stop();\r
 }\r
 \r
-void CSVNStatusCache::Init()\r
+void CGitStatusCache::Init()\r
 {\r
        m_folderCrawler.Initialise();\r
        m_shellUpdater.Initialise();\r
 }\r
 \r
-CSVNStatusCache::CSVNStatusCache(void)\r
+CGitStatusCache::CGitStatusCache(void)\r
 {\r
        TCHAR path[MAX_PATH];\r
        SHGetFolderPath(NULL, CSIDL_COOKIES, NULL, 0, path);\r
-       m_NoWatchPaths.insert(CTSVNPath(CString(path)));\r
+       m_NoWatchPaths.insert(CTGitPath(CString(path)));\r
        SHGetFolderPath(NULL, CSIDL_HISTORY, NULL, 0, path);\r
-       m_NoWatchPaths.insert(CTSVNPath(CString(path)));\r
+       m_NoWatchPaths.insert(CTGitPath(CString(path)));\r
        SHGetFolderPath(NULL, CSIDL_INTERNET_CACHE, NULL, 0, path);\r
-       m_NoWatchPaths.insert(CTSVNPath(CString(path)));\r
+       m_NoWatchPaths.insert(CTGitPath(CString(path)));\r
        SHGetFolderPath(NULL, CSIDL_SYSTEM, NULL, 0, path);\r
-       m_NoWatchPaths.insert(CTSVNPath(CString(path)));\r
+       m_NoWatchPaths.insert(CTGitPath(CString(path)));\r
        SHGetFolderPath(NULL, CSIDL_WINDOWS, NULL, 0, path);\r
-       m_NoWatchPaths.insert(CTSVNPath(CString(path)));\r
+       m_NoWatchPaths.insert(CTGitPath(CString(path)));\r
        m_bClearMemory = false;\r
        m_mostRecentExpiresAt = 0;\r
 }\r
 \r
-CSVNStatusCache::~CSVNStatusCache(void)\r
+CGitStatusCache::~CGitStatusCache(void)\r
 {\r
        for (CCachedDirectory::CachedDirMap::iterator I = m_pInstance->m_directoryCache.begin(); I != m_pInstance->m_directoryCache.end(); ++I)\r
        {\r
@@ -247,10 +247,10 @@ CSVNStatusCache::~CSVNStatusCache(void)
        }\r
 }\r
 \r
-void CSVNStatusCache::Refresh()\r
+void CGitStatusCache::Refresh()\r
 {\r
        m_shellCache.ForceRefresh();\r
-       m_pInstance->m_svnHelp.ReloadConfig();\r
+//     m_pInstance->m_svnHelp.ReloadConfig();\r
        if (m_pInstance->m_directoryCache.size())\r
        {\r
                CCachedDirectory::CachedDirMap::iterator I = m_pInstance->m_directoryCache.begin();\r
@@ -260,7 +260,7 @@ void CSVNStatusCache::Refresh()
                                I->second->RefreshMostImportant();\r
                        else\r
                        {\r
-                               CSVNStatusCache::Instance().RemoveCacheForPath(I->first);\r
+                               CGitStatusCache::Instance().RemoveCacheForPath(I->first);\r
                                I = m_pInstance->m_directoryCache.begin();\r
                                if (I == m_pInstance->m_directoryCache.end())\r
                                        break;\r
@@ -269,9 +269,9 @@ void CSVNStatusCache::Refresh()
        }\r
 }\r
 \r
-bool CSVNStatusCache::IsPathGood(const CTSVNPath& path)\r
+bool CGitStatusCache::IsPathGood(const CTGitPath& path)\r
 {\r
-       for (std::set<CTSVNPath>::iterator it = m_NoWatchPaths.begin(); it != m_NoWatchPaths.end(); ++it)\r
+       for (std::set<CTGitPath>::iterator it = m_NoWatchPaths.begin(); it != m_NoWatchPaths.end(); ++it)\r
        {\r
                if (it->IsAncestorOf(path))\r
                        return false;\r
@@ -279,12 +279,12 @@ bool CSVNStatusCache::IsPathGood(const CTSVNPath& path)
        return true;\r
 }\r
 \r
-void CSVNStatusCache::UpdateShell(const CTSVNPath& path)\r
+void CGitStatusCache::UpdateShell(const CTGitPath& path)\r
 {\r
        m_shellUpdater.AddPathForUpdate(path);\r
 }\r
 \r
-void CSVNStatusCache::ClearCache()\r
+void CGitStatusCache::ClearCache()\r
 {\r
        for (CCachedDirectory::CachedDirMap::iterator I = m_directoryCache.begin(); I != m_directoryCache.end(); ++I)\r
        {\r
@@ -294,18 +294,18 @@ void CSVNStatusCache::ClearCache()
        m_directoryCache.clear();\r
 }\r
 \r
-bool CSVNStatusCache::RemoveCacheForDirectory(CCachedDirectory * cdir)\r
+bool CGitStatusCache::RemoveCacheForDirectory(CCachedDirectory * cdir)\r
 {\r
        if (cdir == NULL)\r
                return false;\r
        AssertWriting();\r
-       typedef std::map<CTSVNPath, svn_wc_status_kind>  ChildDirStatus;\r
+       typedef std::map<CTGitPath, git_wc_status_kind>  ChildDirStatus;\r
        if (cdir->m_childDirectories.size())\r
        {\r
                ChildDirStatus::iterator it = cdir->m_childDirectories.begin();\r
                for (; it != cdir->m_childDirectories.end(); )\r
                {\r
-                       CCachedDirectory * childdir = CSVNStatusCache::Instance().GetDirectoryCacheEntryNoCreate(it->first);\r
+                       CCachedDirectory * childdir = CGitStatusCache::Instance().GetDirectoryCacheEntryNoCreate(it->first);\r
                        if ((childdir)&&(!cdir->m_directoryPath.IsEquivalentTo(childdir->m_directoryPath)))\r
                                RemoveCacheForDirectory(childdir);\r
                        cdir->m_childDirectories.erase(it->first);\r
@@ -314,13 +314,13 @@ bool CSVNStatusCache::RemoveCacheForDirectory(CCachedDirectory * cdir)
        }\r
        cdir->m_childDirectories.clear();\r
        m_directoryCache.erase(cdir->m_directoryPath);\r
-       ATLTRACE(_T("removed path %s from cache\n"), cdir->m_directoryPath);\r
+       ATLTRACE(_T("removed path %s from cache\n"), cdir->m_directoryPath.GetWinPathString());\r
        delete cdir;\r
        cdir = NULL;\r
        return true;\r
 }\r
 \r
-void CSVNStatusCache::RemoveCacheForPath(const CTSVNPath& path)\r
+void CGitStatusCache::RemoveCacheForPath(const CTGitPath& path)\r
 {\r
        // Stop the crawler starting on a new folder\r
        CCrawlInhibitor crawlInhibit(&m_folderCrawler);\r
@@ -337,7 +337,7 @@ void CSVNStatusCache::RemoveCacheForPath(const CTSVNPath& path)
        RemoveCacheForDirectory(dirtoremove);\r
 }\r
 \r
-CCachedDirectory * CSVNStatusCache::GetDirectoryCacheEntry(const CTSVNPath& path)\r
+CCachedDirectory * CGitStatusCache::GetDirectoryCacheEntry(const CTGitPath& path)\r
 {\r
        ATLASSERT(path.IsDirectory() || !PathFileExists(path.GetWinPath()));\r
 \r
@@ -373,10 +373,10 @@ CCachedDirectory * CSVNStatusCache::GetDirectoryCacheEntry(const CTSVNPath& path
                        m_directoryCache.erase(itMap);\r
                // We don't know anything about this directory yet - lets add it to our cache\r
                // but only if it exists!\r
-               if (path.Exists() && m_shellCache.IsPathAllowed(path.GetWinPath()) && !g_SVNAdminDir.IsAdminDirPath(path.GetWinPath()))\r
+               if (path.Exists() && m_shellCache.IsPathAllowed(path.GetWinPath()) && !g_GitAdminDir.IsAdminDirPath(path.GetWinPath()))\r
                {\r
                        // some notifications are for files which got removed/moved around.\r
-                       // In such cases, the CTSVNPath::IsDirectory() will return true (it assumes a directory if\r
+                       // In such cases, the CTGitPath::IsDirectory() will return true (it assumes a directory if\r
                        // the path doesn't exist). Which means we can get here with a path to a file\r
                        // instead of a directory.\r
                        // Since we're here most likely called from the crawler thread, the file could exist\r
@@ -399,7 +399,7 @@ CCachedDirectory * CSVNStatusCache::GetDirectoryCacheEntry(const CTSVNPath& path
        }\r
 }\r
 \r
-CCachedDirectory * CSVNStatusCache::GetDirectoryCacheEntryNoCreate(const CTSVNPath& path)\r
+CCachedDirectory * CGitStatusCache::GetDirectoryCacheEntryNoCreate(const CTGitPath& path)\r
 {\r
        ATLASSERT(path.IsDirectory() || !PathFileExists(path.GetWinPath()));\r
 \r
@@ -413,7 +413,7 @@ CCachedDirectory * CSVNStatusCache::GetDirectoryCacheEntryNoCreate(const CTSVNPa
        return NULL;\r
 }\r
 \r
-CStatusCacheEntry CSVNStatusCache::GetStatusForPath(const CTSVNPath& path, DWORD flags,  bool bFetch /* = true */)\r
+CStatusCacheEntry CGitStatusCache::GetStatusForPath(const CTGitPath& path, DWORD flags,  bool bFetch /* = true */)\r
 {\r
        bool bRecursive = !!(flags & TSVNCACHE_FLAGS_RECUSIVE_STATUS);\r
 \r
@@ -435,7 +435,7 @@ CStatusCacheEntry CSVNStatusCache::GetStatusForPath(const CTSVNPath& path, DWORD
                // Please note, that this may be a second "lock" used concurrently to the one in RemoveCacheForPath().\r
                CCrawlInhibitor crawlInhibit(&m_folderCrawler);\r
 \r
-               CTSVNPath dirpath = path.GetContainingDirectory();\r
+               CTGitPath dirpath = path.GetContainingDirectory();\r
                if ((dirpath.IsEmpty()) || (!m_shellCache.IsPathAllowed(dirpath.GetWinPath())))\r
                        dirpath = path.GetDirectory();\r
                CCachedDirectory * cachedDir = GetDirectoryCacheEntry(dirpath);\r
@@ -449,23 +449,23 @@ CStatusCacheEntry CSVNStatusCache::GetStatusForPath(const CTSVNPath& path, DWORD
        m_mostRecentStatus = CStatusCacheEntry();\r
        if (m_shellCache.ShowExcludedAsNormal() && path.IsDirectory() && m_shellCache.HasSVNAdminDir(path.GetWinPath(), true))\r
        {\r
-               m_mostRecentStatus.ForceStatus(svn_wc_status_normal);\r
+               m_mostRecentStatus.ForceStatus(git_wc_status_normal);\r
        }\r
        return m_mostRecentStatus;\r
 }\r
 \r
-void CSVNStatusCache::AddFolderForCrawling(const CTSVNPath& path)\r
+void CGitStatusCache::AddFolderForCrawling(const CTGitPath& path)\r
 {\r
        m_folderCrawler.AddDirectoryForUpdate(path);\r
 }\r
 \r
-void CSVNStatusCache::CloseWatcherHandles(HDEVNOTIFY hdev)\r
+void CGitStatusCache::CloseWatcherHandles(HDEVNOTIFY hdev)\r
 {\r
-       CTSVNPath path = watcher.CloseInfoMap(hdev);\r
+       CTGitPath path = watcher.CloseInfoMap(hdev);\r
        m_folderCrawler.BlockPath(path);\r
 }\r
 \r
-void CSVNStatusCache::CloseWatcherHandles(const CTSVNPath& path)\r
+void CGitStatusCache::CloseWatcherHandles(const CTGitPath& path)\r
 {\r
        watcher.CloseHandlesForPath(path);\r
        m_folderCrawler.BlockPath(path);\r