OSDN Git Service

initial icon overlay support using the wingit lib
[tortoisegit/TortoiseGitJp.git] / src / TGitCache / FolderCrawler.cpp
index f1033be..bab47be 100644 (file)
@@ -19,7 +19,7 @@
 \r
 #include "StdAfx.h"\r
 #include ".\foldercrawler.h"\r
-#include "SVNStatusCache.h"\r
+#include "GitStatusCache.h"\r
 #include "registry.h"\r
 #include "TSVNCache.h"\r
 #include "shlobj.h"\r
@@ -77,9 +77,9 @@ void CFolderCrawler::Initialise()
        SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_IDLE);\r
 }\r
 \r
-void CFolderCrawler::AddDirectoryForUpdate(const CTSVNPath& path)\r
+void CFolderCrawler::AddDirectoryForUpdate(const CTGitPath& path)\r
 {\r
-       if (!CSVNStatusCache::Instance().IsPathGood(path))\r
+       if (!CGitStatusCache::Instance().IsPathGood(path))\r
                return;\r
        {\r
                AutoLocker lock(m_critSec);\r
@@ -94,9 +94,9 @@ void CFolderCrawler::AddDirectoryForUpdate(const CTSVNPath& path)
                SetEvent(m_hWakeEvent);\r
 }\r
 \r
-void CFolderCrawler::AddPathForUpdate(const CTSVNPath& path)\r
+void CFolderCrawler::AddPathForUpdate(const CTGitPath& path)\r
 {\r
-       if (!CSVNStatusCache::Instance().IsPathGood(path))\r
+       if (!CGitStatusCache::Instance().IsPathGood(path))\r
                return;\r
        {\r
                AutoLocker lock(m_critSec);\r
@@ -119,7 +119,7 @@ void CFolderCrawler::WorkerThread()
        HANDLE hWaitHandles[2];\r
        hWaitHandles[0] = m_hTerminationEvent;  \r
        hWaitHandles[1] = m_hWakeEvent;\r
-       CTSVNPath workingPath;\r
+       CTGitPath workingPath;\r
        bool bFirstRunAfterWakeup = false;\r
        DWORD currentTicks = 0;\r
 \r
@@ -132,7 +132,7 @@ void CFolderCrawler::WorkerThread()
 \r
        for(;;)\r
        {\r
-               bool bRecursive = !!(DWORD)CRegStdWORD(_T("Software\\TortoiseSVN\\RecursiveOverlay"), TRUE);\r
+               bool bRecursive = !!(DWORD)CRegStdWORD(_T("Software\\TortoiseGit\\RecursiveOverlay"), TRUE);\r
 \r
                if (fullver >= 0x0600)\r
                {\r
@@ -164,12 +164,12 @@ void CFolderCrawler::WorkerThread()
                        if (!m_bRun)\r
                                break;\r
                        // Any locks today?\r
-                       if (CSVNStatusCache::Instance().m_bClearMemory)\r
+                       if (CGitStatusCache::Instance().m_bClearMemory)\r
                        {\r
-                               CSVNStatusCache::Instance().WaitToWrite();\r
-                               CSVNStatusCache::Instance().ClearCache();\r
-                               CSVNStatusCache::Instance().Done();\r
-                               CSVNStatusCache::Instance().m_bClearMemory = false;\r
+                               CGitStatusCache::Instance().WaitToWrite();\r
+                               CGitStatusCache::Instance().ClearCache();\r
+                               CGitStatusCache::Instance().Done();\r
+                               CGitStatusCache::Instance().m_bClearMemory = false;\r
                        }\r
                        if(m_lCrawlInhibitSet > 0)\r
                        {\r
@@ -205,7 +205,7 @@ void CFolderCrawler::WorkerThread()
                                        {\r
                                                // The queue has changed - it's worth sorting and de-duping\r
                                                std::sort(m_pathsToUpdate.begin(), m_pathsToUpdate.end());\r
-                                               m_pathsToUpdate.erase(std::unique(m_pathsToUpdate.begin(), m_pathsToUpdate.end(), &CTSVNPath::PredLeftSameWCPathAsRight), m_pathsToUpdate.end());\r
+                                               m_pathsToUpdate.erase(std::unique(m_pathsToUpdate.begin(), m_pathsToUpdate.end(), &CTGitPath::PredLeftSameWCPathAsRight), m_pathsToUpdate.end());\r
                                                m_bPathsAddedSinceLastCrawl = false;\r
                                        }\r
                                        workingPath = m_pathsToUpdate.front();\r
@@ -219,7 +219,7 @@ void CFolderCrawler::WorkerThread()
                                                // to crawl. That way, we still reduce the size of the list.\r
                                                if (m_pathsToUpdate.size() > 10)\r
                                                        ATLTRACE("attention: the list of paths to update is now %ld big!\n", m_pathsToUpdate.size());\r
-                                               for (std::deque<CTSVNPath>::iterator it = m_pathsToUpdate.begin(); it != m_pathsToUpdate.end(); ++it)\r
+                                               for (std::deque<CTGitPath>::iterator it = m_pathsToUpdate.begin(); it != m_pathsToUpdate.end(); ++it)\r
                                                {\r
                                                        workingPath = *it;\r
                                                        if ((DWORD(workingPath.GetCustomData()) < currentTicks)||(DWORD(workingPath.GetCustomData()) > (currentTicks + 200000)))\r
@@ -238,7 +238,7 @@ void CFolderCrawler::WorkerThread()
                                if ((!m_blockedPath.IsEmpty())&&(m_blockedPath.IsAncestorOf(workingPath)))\r
                                        continue;\r
                                // don't crawl paths that are excluded\r
-                               if (!CSVNStatusCache::Instance().IsPathAllowed(workingPath))\r
+                               if (!CGitStatusCache::Instance().IsPathAllowed(workingPath))\r
                                        continue;\r
                                // check if the changed path is inside an .svn folder\r
                                if ((workingPath.HasAdminDir()&&workingPath.IsDirectory())||workingPath.IsAdminDir())\r
@@ -270,9 +270,9 @@ void CFolderCrawler::WorkerThread()
                                        }\r
                                        else if (!workingPath.Exists())\r
                                        {\r
-                                               CSVNStatusCache::Instance().WaitToWrite();\r
-                                               CSVNStatusCache::Instance().RemoveCacheForPath(workingPath);\r
-                                               CSVNStatusCache::Instance().Done();\r
+                                               CGitStatusCache::Instance().WaitToWrite();\r
+                                               CGitStatusCache::Instance().RemoveCacheForPath(workingPath);\r
+                                               CGitStatusCache::Instance().Done();\r
                                                continue;\r
                                        }\r
 \r
@@ -290,12 +290,12 @@ void CFolderCrawler::WorkerThread()
                                                        nCurrentCrawledpathIndex = 0;\r
                                        }\r
                                        InvalidateRect(hWnd, NULL, FALSE);\r
-                                       CSVNStatusCache::Instance().WaitToRead();\r
+                                       CGitStatusCache::Instance().WaitToRead();\r
                                        // Invalidate the cache of this folder, to make sure its status is fetched again.\r
-                                       CCachedDirectory * pCachedDir = CSVNStatusCache::Instance().GetDirectoryCacheEntry(workingPath);\r
+                                       CCachedDirectory * pCachedDir = CGitStatusCache::Instance().GetDirectoryCacheEntry(workingPath);\r
                                        if (pCachedDir)\r
                                        {\r
-                                               svn_wc_status_kind status = pCachedDir->GetCurrentFullStatus();\r
+                                               git_wc_status_kind status = pCachedDir->GetCurrentFullStatus();\r
                                                pCachedDir->Invalidate();\r
                                                if (workingPath.Exists())\r
                                                {\r
@@ -305,20 +305,20 @@ void CFolderCrawler::WorkerThread()
                                                        // We do this here because GetCurrentFullStatus() doesn't send\r
                                                        // notifications for 'normal' status - if it would, we'd get tons\r
                                                        // of notifications when crawling a working copy not yet in the cache.\r
-                                                       if ((status != svn_wc_status_normal)&&(pCachedDir->GetCurrentFullStatus() != status))\r
+                                                       if ((status != git_wc_status_normal)&&(pCachedDir->GetCurrentFullStatus() != status))\r
                                                        {\r
-                                                               CSVNStatusCache::Instance().UpdateShell(workingPath);\r
+                                                               CGitStatusCache::Instance().UpdateShell(workingPath);\r
                                                                ATLTRACE(_T("shell update in crawler for %s\n"), workingPath.GetWinPath());\r
                                                        }\r
                                                }\r
                                                else\r
                                                {\r
-                                                       CSVNStatusCache::Instance().Done();\r
-                                                       CSVNStatusCache::Instance().WaitToWrite();\r
-                                                       CSVNStatusCache::Instance().RemoveCacheForPath(workingPath);\r
+                                                       CGitStatusCache::Instance().Done();\r
+                                                       CGitStatusCache::Instance().WaitToWrite();\r
+                                                       CGitStatusCache::Instance().RemoveCacheForPath(workingPath);\r
                                                }\r
                                        }\r
-                                       CSVNStatusCache::Instance().Done();\r
+                                       CGitStatusCache::Instance().Done();\r
                                        //In case that svn_client_stat() modified a file and we got\r
                                        //a notification about that in the directory watcher,\r
                                        //remove that here again - this is to prevent an endless loop\r
@@ -329,9 +329,9 @@ void CFolderCrawler::WorkerThread()
                                {\r
                                        if (!workingPath.Exists())\r
                                        {\r
-                                               CSVNStatusCache::Instance().WaitToWrite();\r
-                                               CSVNStatusCache::Instance().RemoveCacheForPath(workingPath);\r
-                                               CSVNStatusCache::Instance().Done();\r
+                                               CGitStatusCache::Instance().WaitToWrite();\r
+                                               CGitStatusCache::Instance().RemoveCacheForPath(workingPath);\r
+                                               CGitStatusCache::Instance().Done();\r
                                                continue;\r
                                        }\r
                                        if (!workingPath.Exists())\r
@@ -349,23 +349,23 @@ void CFolderCrawler::WorkerThread()
                                        DWORD flags = TSVNCACHE_FLAGS_FOLDERISKNOWN;\r
                                        flags |= (workingPath.IsDirectory() ? TSVNCACHE_FLAGS_ISFOLDER : 0);\r
                                        flags |= (bRecursive ? TSVNCACHE_FLAGS_RECUSIVE_STATUS : 0);\r
-                                       CSVNStatusCache::Instance().WaitToRead();\r
+                                       CGitStatusCache::Instance().WaitToRead();\r
                                        // Invalidate the cache of folders manually. The cache of files is invalidated\r
                                        // automatically if the status is asked for it and the file times don't match\r
                                        // anymore, so we don't need to manually invalidate those.\r
                                        if (workingPath.IsDirectory())\r
                                        {\r
-                                               CCachedDirectory * cachedDir = CSVNStatusCache::Instance().GetDirectoryCacheEntry(workingPath);\r
+                                               CCachedDirectory * cachedDir = CGitStatusCache::Instance().GetDirectoryCacheEntry(workingPath);\r
                                                if (cachedDir)\r
                                                        cachedDir->Invalidate();\r
                                        }\r
-                                       CStatusCacheEntry ce = CSVNStatusCache::Instance().GetStatusForPath(workingPath, flags);\r
-                                       if (ce.GetEffectiveStatus() > svn_wc_status_unversioned)\r
+                                       CStatusCacheEntry ce = CGitStatusCache::Instance().GetStatusForPath(workingPath, flags);\r
+                                       if (ce.GetEffectiveStatus() > git_wc_status_unversioned)\r
                                        {\r
-                                               CSVNStatusCache::Instance().UpdateShell(workingPath);\r
+                                               CGitStatusCache::Instance().UpdateShell(workingPath);\r
                                                ATLTRACE(_T("shell update in folder crawler for %s\n"), workingPath.GetWinPath());\r
                                        }\r
-                                       CSVNStatusCache::Instance().Done();\r
+                                       CGitStatusCache::Instance().Done();\r
                                        AutoLocker lock(m_critSec);\r
                                        m_pathsToUpdate.erase(std::remove(m_pathsToUpdate.begin(), m_pathsToUpdate.end(), workingPath), m_pathsToUpdate.end());\r
                                }\r
@@ -373,9 +373,9 @@ void CFolderCrawler::WorkerThread()
                                {\r
                                        if (!workingPath.Exists())\r
                                        {\r
-                                               CSVNStatusCache::Instance().WaitToWrite();\r
-                                               CSVNStatusCache::Instance().RemoveCacheForPath(workingPath);\r
-                                               CSVNStatusCache::Instance().Done();\r
+                                               CGitStatusCache::Instance().WaitToWrite();\r
+                                               CGitStatusCache::Instance().RemoveCacheForPath(workingPath);\r
+                                               CGitStatusCache::Instance().Done();\r
                                        }\r
                                }\r
                        }\r
@@ -388,13 +388,13 @@ void CFolderCrawler::WorkerThread()
                                        {\r
                                                // The queue has changed - it's worth sorting and de-duping\r
                                                std::sort(m_foldersToUpdate.begin(), m_foldersToUpdate.end());\r
-                                               m_foldersToUpdate.erase(std::unique(m_foldersToUpdate.begin(), m_foldersToUpdate.end(), &CTSVNPath::PredLeftEquivalentToRight), m_foldersToUpdate.end());\r
+                                               m_foldersToUpdate.erase(std::unique(m_foldersToUpdate.begin(), m_foldersToUpdate.end(), &CTGitPath::PredLeftEquivalentToRight), m_foldersToUpdate.end());\r
                                                m_bItemsAddedSinceLastCrawl = false;\r
                                        }\r
-                                       // create a new CTSVNPath object to make sure the cached flags are requested again.\r
+                                       // create a new CTGitPath object to make sure the cached flags are requested again.\r
                                        // without this, a missing file/folder is still treated as missing even if it is available\r
                                        // now when crawling.\r
-                                       workingPath = CTSVNPath(m_foldersToUpdate.front().GetWinPath());\r
+                                       workingPath = CTGitPath(m_foldersToUpdate.front().GetWinPath());\r
                                        workingPath.SetCustomData(m_foldersToUpdate.front().GetCustomData());\r
                                        if ((DWORD(workingPath.GetCustomData()) < currentTicks)||(DWORD(workingPath.GetCustomData()) > (currentTicks + 200000)))\r
                                                m_foldersToUpdate.pop_front();\r
@@ -406,7 +406,7 @@ void CFolderCrawler::WorkerThread()
                                                // to crawl. That way, we still reduce the size of the list.\r
                                                if (m_foldersToUpdate.size() > 10)\r
                                                        ATLTRACE("attention: the list of folders to update is now %ld big!\n", m_foldersToUpdate.size());\r
-                                               for (std::deque<CTSVNPath>::iterator it = m_foldersToUpdate.begin(); it != m_foldersToUpdate.end(); ++it)\r
+                                               for (std::deque<CTGitPath>::iterator it = m_foldersToUpdate.begin(); it != m_foldersToUpdate.end(); ++it)\r
                                                {\r
                                                        workingPath = *it;\r
                                                        if ((DWORD(workingPath.GetCustomData()) < currentTicks)||(DWORD(workingPath.GetCustomData()) > (currentTicks + 200000)))\r
@@ -424,7 +424,7 @@ void CFolderCrawler::WorkerThread()
                                }\r
                                if ((!m_blockedPath.IsEmpty())&&(m_blockedPath.IsAncestorOf(workingPath)))\r
                                        continue;\r
-                               if (!CSVNStatusCache::Instance().IsPathAllowed(workingPath))\r
+                               if (!CGitStatusCache::Instance().IsPathAllowed(workingPath))\r
                                        continue;\r
 \r
                                ATLTRACE(_T("Crawling folder: %s\n"), workingPath.GetWinPath());\r
@@ -436,22 +436,22 @@ void CFolderCrawler::WorkerThread()
                                                nCurrentCrawledpathIndex = 0;\r
                                }\r
                                InvalidateRect(hWnd, NULL, FALSE);\r
-                               CSVNStatusCache::Instance().WaitToRead();\r
+                               CGitStatusCache::Instance().WaitToRead();\r
                                // Now, we need to visit this folder, to make sure that we know its 'most important' status\r
-                               CCachedDirectory * cachedDir = CSVNStatusCache::Instance().GetDirectoryCacheEntry(workingPath.GetDirectory());\r
+                               CCachedDirectory * cachedDir = CGitStatusCache::Instance().GetDirectoryCacheEntry(workingPath.GetDirectory());\r
                                // check if the path is monitored by the watcher. If it isn't, then we have to invalidate the cache\r
                                // for that path and add it to the watcher.\r
-                               if (!CSVNStatusCache::Instance().IsPathWatched(workingPath))\r
+                               if (!CGitStatusCache::Instance().IsPathWatched(workingPath))\r
                                {\r
                                        if (workingPath.HasAdminDir())\r
-                                               CSVNStatusCache::Instance().AddPathToWatch(workingPath);\r
+                                               CGitStatusCache::Instance().AddPathToWatch(workingPath);\r
                                        if (cachedDir)\r
                                                cachedDir->Invalidate();\r
                                        else\r
                                        {\r
-                                               CSVNStatusCache::Instance().Done();\r
-                                               CSVNStatusCache::Instance().WaitToWrite();\r
-                                               CSVNStatusCache::Instance().RemoveCacheForPath(workingPath);\r
+                                               CGitStatusCache::Instance().Done();\r
+                                               CGitStatusCache::Instance().WaitToWrite();\r
+                                               CGitStatusCache::Instance().RemoveCacheForPath(workingPath);\r
                                        }\r
                                }\r
                                if (cachedDir)\r
@@ -469,7 +469,7 @@ void CFolderCrawler::WorkerThread()
                                                m_bItemsAddedSinceLastCrawl = false;\r
                                        }\r
                                }\r
-                               CSVNStatusCache::Instance().Done();\r
+                               CGitStatusCache::Instance().Done();\r
                        }\r
                }\r
        }\r
@@ -484,7 +484,7 @@ bool CFolderCrawler::SetHoldoff(DWORD milliseconds /* = 100*/)
        return ret;\r
 }\r
 \r
-void CFolderCrawler::BlockPath(const CTSVNPath& path, DWORD ticks)\r
+void CFolderCrawler::BlockPath(const CTGitPath& path, DWORD ticks)\r
 {\r
        ATLTRACE(_T("block path %s from being crawled\n"), path.GetWinPath());\r
        m_blockedPath = path;\r