本文整理汇总了C++中CCachedDirectory::GetCurrentFullStatus方法的典型用法代码示例。如果您正苦于以下问题:C++ CCachedDirectory::GetCurrentFullStatus方法的具体用法?C++ CCachedDirectory::GetCurrentFullStatus怎么用?C++ CCachedDirectory::GetCurrentFullStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCachedDirectory
的用法示例。
在下文中一共展示了CCachedDirectory::GetCurrentFullStatus方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
void
CCachedDirectory::AddEntry(const CTSVNPath& path, const svn_client_status_t* pSVNStatus, bool needsLock, bool forceNormal)
{
svn_wc_status_kind nodestatus = forceNormal ? svn_wc_status_normal : (pSVNStatus ? pSVNStatus->node_status : svn_wc_status_none);
if(path.IsDirectory())
{
// no lock here:
// AutoLocker lock(m_critSec);
// because GetDirectoryCacheEntry() can try to obtain a write lock
CCachedDirectory * childDir = CSVNStatusCache::Instance().GetDirectoryCacheEntry(path);
if (childDir)
{
if ((childDir->GetCurrentFullStatus() != svn_wc_status_ignored)||(pSVNStatus==NULL)||(nodestatus != svn_wc_status_unversioned))
childDir->m_ownStatus.SetStatus(pSVNStatus, needsLock, forceNormal);
childDir->m_ownStatus.SetKind(svn_node_dir);
}
}
else
{
AutoLocker lock(m_critSec);
CStringA cachekey = GetCacheKey(path);
CacheEntryMap::iterator entry_it = m_entryCache.lower_bound(cachekey);
if (entry_it != m_entryCache.end() && entry_it->first == cachekey)
{
if (pSVNStatus)
{
if (entry_it->second.GetEffectiveStatus() > svn_wc_status_none &&
entry_it->second.GetEffectiveStatus() != nodestatus)
{
CSVNStatusCache::Instance().UpdateShell(path);
CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) _T(": shell update for %s\n"), path.GetWinPath());
}
}
}
else
{
entry_it = m_entryCache.insert(entry_it, std::make_pair(cachekey, CStatusCacheEntry()));
}
entry_it->second = CStatusCacheEntry(pSVNStatus, needsLock, path.GetLastWriteTime(), forceNormal);
}
}
示例2: Create
void CGitStatusCache::Create()
{
ATLASSERT(m_pInstance == NULL);
m_pInstance = new CGitStatusCache;
m_pInstance->watcher.SetFolderCrawler(&m_pInstance->m_folderCrawler);
#define LOADVALUEFROMFILE(x) if (fread(&x, sizeof(x), 1, pFile)!=1) goto exit;
#define LOADVALUEFROMFILE2(x) if (fread(&x, sizeof(x), 1, pFile)!=1) goto error;
unsigned int value = (unsigned int)-1;
FILE * pFile = NULL;
// find the location of the cache
TCHAR path[MAX_PATH]; //MAX_PATH ok here.
TCHAR path2[MAX_PATH];
if (SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, path)==S_OK)
{
_tcscat_s(path, MAX_PATH, _T("\\TGitCache"));
if (!PathIsDirectory(path))
{
if (CreateDirectory(path, NULL)==0)
goto error;
}
_tcscat_s(path, MAX_PATH, _T("\\cache"));
// in case the cache file is corrupt, we could crash while
// reading it! To prevent crashing every time once that happens,
// we make a copy of the cache file and use that copy to read from.
// if that copy is corrupt, the original file won't exist anymore
// and the second time we start up and try to read the file,
// it's not there anymore and we start from scratch without a crash.
_tcscpy_s(path2, MAX_PATH, path);
_tcscat_s(path2, MAX_PATH, _T("2"));
DeleteFile(path2);
CopyFile(path, path2, FALSE);
DeleteFile(path);
pFile = _tfsopen(path2, _T("rb"), _SH_DENYNO);
if (pFile)
{
try
{
LOADVALUEFROMFILE(value);
if (value != 2)
{
goto error;
}
int mapsize = 0;
LOADVALUEFROMFILE(mapsize);
for (int i=0; i<mapsize; ++i)
{
LOADVALUEFROMFILE2(value);
if (value > MAX_PATH)
goto error;
if (value)
{
CString sKey;
if (fread(sKey.GetBuffer(value+1), sizeof(TCHAR), value, pFile)!=value)
{
sKey.ReleaseBuffer(0);
goto error;
}
sKey.ReleaseBuffer(value);
CCachedDirectory * cacheddir = new CCachedDirectory();
if (cacheddir == NULL)
goto error;
if (!cacheddir->LoadFromDisk(pFile))
goto error;
CTGitPath KeyPath = CTGitPath(sKey);
if (m_pInstance->IsPathAllowed(KeyPath))
{
m_pInstance->m_directoryCache[KeyPath] = cacheddir;
// only add the path to the watch list if it is versioned
if ((cacheddir->GetCurrentFullStatus() != git_wc_status_unversioned)&&(cacheddir->GetCurrentFullStatus() != git_wc_status_none))
m_pInstance->watcher.AddPath(KeyPath, false);
// do *not* add the paths for crawling!
// because crawled paths will trigger a shell
// notification, which makes the desktop flash constantly
// until the whole first time crawling is over
// m_pInstance->AddFolderForCrawling(KeyPath);
}
}
}
}
catch (CAtlException)
{
goto error;
}
}
}
exit:
if (pFile)
fclose(pFile);
DeleteFile(path2);
m_pInstance->watcher.ClearInfoMap();
ATLTRACE("cache loaded from disk successfully!\n");
return;
error:
if (pFile)
fclose(pFile);
DeleteFile(path2);
m_pInstance->watcher.ClearInfoMap();
Destroy();
m_pInstance = new CGitStatusCache;
//.........这里部分代码省略.........
示例3: GetStatusCallback
BOOL CCachedDirectory::GetStatusCallback(const CString & path, git_wc_status_kind status,bool isDir, void *, bool assumeValid, bool skipWorktree)
{
git_wc_status2_t _status;
git_wc_status2_t *status2 = &_status;
status2->prop_status = status2->text_status = status;
status2->assumeValid = assumeValid;
status2->skipWorktree = skipWorktree;
CTGitPath gitPath(path);
CCachedDirectory *pThis = CGitStatusCache::Instance().GetDirectoryCacheEntry(gitPath.GetContainingDirectory());
if(pThis == NULL)
return FALSE;
// if(status->entry)
{
if (isDir)
{ /*gitpath is directory*/
//if ( !gitPath.IsEquivalentToWithoutCase(pThis->m_directoryPath) )
{
if (!gitPath.Exists())
{
CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) _T(": Miss dir %s \n"), gitPath.GetWinPath());
pThis->m_mostImportantFileStatus = GitStatus::GetMoreImportant(pThis->m_mostImportantFileStatus, git_wc_status_deleted);
}
if ( status < git_wc_status_normal)
{
if( ::PathFileExists(path+_T("\\.git")))
{ // this is submodule
CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) _T(": skip submodule %s\n"), path);
return FALSE;
}
}
if (pThis->m_bRecursive)
{
// Add any versioned directory, which is not our 'self' entry, to the list for having its status updated
//OutputDebugStringA("AddFolderCrawl: ");OutputDebugStringW(svnPath.GetWinPathString());OutputDebugStringA("\r\n");
if (status >= git_wc_status_normal || (CGitStatusCache::Instance().IsUnversionedAsModified() && status == git_wc_status_unversioned))
CGitStatusCache::Instance().AddFolderForCrawling(gitPath);
}
// Make sure we know about this child directory
// This initial status value is likely to be overwritten from below at some point
git_wc_status_kind s = GitStatus::GetMoreImportant(status2->text_status, status2->prop_status);
// folders must not be displayed as added or deleted only as modified
if (s == git_wc_status_deleted || s == git_wc_status_added)
s = git_wc_status_modified;
CCachedDirectory * cdir = CGitStatusCache::Instance().GetDirectoryCacheEntryNoCreate(gitPath);
if (cdir)
{
// This child directory is already in our cache!
// So ask this dir about its recursive status
git_wc_status_kind st = GitStatus::GetMoreImportant(s, cdir->GetCurrentFullStatus());
AutoLocker lock(pThis->m_critSec);
pThis->m_childDirectories[gitPath] = st;
CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) _T(": call 1 Update dir %s %d\n"), gitPath.GetWinPath(), st);
}
else
{
AutoLocker lock(pThis->m_critSec);
// the child directory is not in the cache. Create a new entry for it in the cache which is
// initially 'unversioned'. But we added that directory to the crawling list above, which
// means the cache will be updated soon.
CGitStatusCache::Instance().GetDirectoryCacheEntry(gitPath);
pThis->m_childDirectories[gitPath] = s;
CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) _T(": call 2 Update dir %s %d\n"), gitPath.GetWinPath(), s);
}
}
}
else /* gitpath is file*/
{
// Keep track of the most important status of all the files in this directory
// Don't include subdirectories in this figure, because they need to provide their
// own 'most important' value
pThis->m_mostImportantFileStatus = GitStatus::GetMoreImportant(pThis->m_mostImportantFileStatus, status2->text_status);
pThis->m_mostImportantFileStatus = GitStatus::GetMoreImportant(pThis->m_mostImportantFileStatus, status2->prop_status);
if ((status2->text_status == git_wc_status_unversioned) && (CGitStatusCache::Instance().IsUnversionedAsModified()))
{
// treat unversioned files as modified
if (pThis->m_mostImportantFileStatus != git_wc_status_added)
pThis->m_mostImportantFileStatus = GitStatus::GetMoreImportant(pThis->m_mostImportantFileStatus, git_wc_status_modified);
}
}
}
pThis->AddEntry(gitPath, status2);
return FALSE;
}
示例4: lock
void
CCachedDirectory::AddEntry(const CTGitPath& path, const git_wc_status2_t* pGitStatus, DWORD validuntil /* = 0*/)
{
AutoLocker lock(m_critSec);
if(path.IsDirectory())
{
CCachedDirectory * childDir = CGitStatusCache::Instance().GetDirectoryCacheEntry(path);
if (childDir)
{
if ((childDir->GetCurrentFullStatus() != git_wc_status_missing)||(pGitStatus==NULL)||(pGitStatus->text_status != git_wc_status_unversioned))
{
if(pGitStatus)
{
if(childDir->GetCurrentFullStatus() != GitStatus::GetMoreImportant(pGitStatus->prop_status, pGitStatus->text_status))
{
CGitStatusCache::Instance().UpdateShell(path);
//CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) _T(": shell update for %s\n"), path.GetWinPath());
childDir->m_ownStatus.SetKind(git_node_dir);
childDir->m_ownStatus.SetStatus(pGitStatus);
}
}
}
childDir->m_ownStatus.SetKind(git_node_dir);
}
}
else
{
CCachedDirectory * childDir = CGitStatusCache::Instance().GetDirectoryCacheEntry(path.GetContainingDirectory());
bool bNotified = false;
if(!childDir)
return ;
AutoLocker lock2(childDir->m_critSec);
CString cachekey = GetCacheKey(path);
CacheEntryMap::iterator entry_it = childDir->m_entryCache.lower_bound(cachekey);
if (entry_it != childDir->m_entryCache.end() && entry_it->first == cachekey)
{
if (pGitStatus)
{
if (entry_it->second.GetEffectiveStatus() > git_wc_status_none &&
entry_it->second.GetEffectiveStatus() != GitStatus::GetMoreImportant(pGitStatus->prop_status, pGitStatus->text_status)
)
{
bNotified =true;
}
}
}
else
{
entry_it = childDir->m_entryCache.insert(entry_it, std::make_pair(cachekey, CStatusCacheEntry()));
bNotified = true;
}
entry_it->second = CStatusCacheEntry(pGitStatus, path.GetLastWriteTime(), path.IsReadOnly(), validuntil);
// TEMP(?): git status doesn't not have "entry" that contains node type, so manually set as file
entry_it->second.SetKind(git_node_file);
childDir->m_entryCache_tmp[cachekey] = entry_it->second;
if(bNotified)
{
CGitStatusCache::Instance().UpdateShell(path);
//CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) _T(": shell update for %s\n"), path.GetWinPath());
}
//CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) _T(": Path Entry Add %s %s %s %d\n"), path.GetWinPath(), cachekey, m_directoryPath.GetWinPath(), pGitStatus->text_status);
}
}
示例5: GetStatusFromGit
CStatusCacheEntry CCachedDirectory::GetStatusFromGit(const CTGitPath &path, CString sProjectRoot)
{
CString subpaths = path.GetGitPathString();
if(subpaths.GetLength() >= sProjectRoot.GetLength())
{
if(subpaths[sProjectRoot.GetLength()] == _T('/'))
subpaths=subpaths.Right(subpaths.GetLength() - sProjectRoot.GetLength()-1);
else
subpaths=subpaths.Right(subpaths.GetLength() - sProjectRoot.GetLength());
}
GitStatus *pGitStatus = &CGitStatusCache::Instance().m_GitStatus;
UNREFERENCED_PARAMETER(pGitStatus);
bool isVersion =true;
pGitStatus->IsUnderVersionControl(sProjectRoot, subpaths, path.IsDirectory(), &isVersion);
if(!isVersion)
{ //untracked file
bool isDir = path.IsDirectory();
bool isIgnoreFileChanged = pGitStatus->HasIgnoreFilesChanged(sProjectRoot, subpaths, isDir);
if( isIgnoreFileChanged)
{
pGitStatus->LoadIgnoreFile(sProjectRoot, subpaths, isDir);
}
if (isDir)
{
CCachedDirectory * dirEntry = CGitStatusCache::Instance().GetDirectoryCacheEntry(path,
false); /* we needn't watch untracked directory*/
if(dirEntry)
{
AutoLocker lock(dirEntry->m_critSec);
git_wc_status_kind dirstatus = dirEntry->GetCurrentFullStatus() ;
if (CGitStatusCache::Instance().IsUnversionedAsModified() || dirstatus == git_wc_status_none || dirstatus >= git_wc_status_normal || isIgnoreFileChanged)
{/* status have not initialized*/
bool isignore = false;
pGitStatus->IsIgnore(sProjectRoot, subpaths, &isignore, isDir);
if (!isignore && CGitStatusCache::Instance().IsUnversionedAsModified())
{
dirEntry->EnumFiles(path, TRUE);
dirEntry->UpdateCurrentStatus();
return CStatusCacheEntry(dirEntry->GetCurrentFullStatus());
}
git_wc_status2_t status2;
status2.text_status = status2.prop_status =
(isignore? git_wc_status_ignored:git_wc_status_unversioned);
// we do not know anything about files here, all we know is that there are not versioned files in this dir
dirEntry->m_mostImportantFileStatus = git_wc_status_none;
dirEntry->m_ownStatus.SetKind(git_node_dir);
dirEntry->m_ownStatus.SetStatus(&status2);
dirEntry->m_currentFullStatus = status2.text_status;
}
return dirEntry->m_ownStatus;
}
}
else /* path is file */
{
AutoLocker lock(m_critSec);
CString strCacheKey = GetCacheKey(path);
if (strCacheKey.IsEmpty())
return CStatusCacheEntry();
CacheEntryMap::iterator itMap = m_entryCache.find(strCacheKey);
if(itMap == m_entryCache.end() || isIgnoreFileChanged)
{
git_wc_status2_t status2;
bool isignore = false;
pGitStatus->IsIgnore(sProjectRoot, subpaths, &isignore, isDir);
status2.text_status = status2.prop_status =
(isignore? git_wc_status_ignored:git_wc_status_unversioned);
AddEntry(path, &status2);
return m_entryCache[strCacheKey];
}
else
{
return itMap->second;
}
}
return CStatusCacheEntry();
}
else
{
EnumFiles(path, TRUE);
UpdateCurrentStatus();
if (!path.IsDirectory())
return GetCacheStatusForMember(path);
return CStatusCacheEntry(m_ownStatus);
}
}
示例6: if
svn_error_t * CCachedDirectory::GetStatusCallback(void *baton, const char *path, const svn_client_status_t *status, apr_pool_t * pool)
{
CCachedDirectory* pThis = (CCachedDirectory*)baton;
if (path == NULL)
return SVN_NO_ERROR;
CTSVNPath svnPath;
bool forceNormal = false;
bool needsLock = false;
const svn_wc_status_kind nodeStatus = status->node_status;
if(status->versioned)
{
if ((nodeStatus != svn_wc_status_none)&&(nodeStatus != svn_wc_status_ignored))
svnPath.SetFromSVN(path, (status->kind == svn_node_dir));
else
svnPath.SetFromSVN(path);
if(svnPath.IsDirectory())
{
if(!svnPath.IsEquivalentToWithoutCase(pThis->m_directoryPath))
{
// Make sure we know about this child directory
// This initial status value is likely to be overwritten from below at some point
svn_wc_status_kind s = nodeStatus;
if (status->conflicted)
s = SVNStatus::GetMoreImportant(s, svn_wc_status_conflicted);
CCachedDirectory * cdir = CSVNStatusCache::Instance().GetDirectoryCacheEntryNoCreate(svnPath);
if (cdir)
{
// This child directory is already in our cache!
// So ask this dir about its recursive status
svn_wc_status_kind st = SVNStatus::GetMoreImportant(s, cdir->GetCurrentFullStatus());
pThis->SetChildStatus(svnPath, st);
}
else
{
// the child directory is not in the cache. Create a new entry for it in the cache which is
// initially 'unversioned'. But we added that directory to the crawling list above, which
// means the cache will be updated soon.
CSVNStatusCache::Instance().GetDirectoryCacheEntry(svnPath);
pThis->SetChildStatus(svnPath, s);
}
}
}
else
{
// only fetch the svn:needs-lock property if the status of this file is 'normal', because
// if the status is something else, the needs-lock overlay won't show up anyway
if ((pThis->m_pCtx)&&(nodeStatus == svn_wc_status_normal))
{
const svn_string_t * value = NULL;
svn_error_t * err = svn_wc_prop_get2(&value, pThis->m_pCtx->wc_ctx, path, "svn:needs-lock", pool, pool);
if ((err==NULL) && value)
needsLock = true;
if (err)
svn_error_clear(err);
}
}
}
else
{
if ((status->kind != svn_node_unknown)&&(status->kind != svn_node_none))
svnPath.SetFromSVN(path, status->kind == svn_node_dir);
else
svnPath.SetFromSVN(path);
// Subversion returns no 'entry' field for versioned folders if they're
// part of another working copy (nested layouts).
// So we have to make sure that such an 'unversioned' folder really
// is unversioned.
if (((nodeStatus == svn_wc_status_unversioned)||(nodeStatus == svn_wc_status_ignored))&&(!svnPath.IsEquivalentToWithoutCase(pThis->m_directoryPath))&&(svnPath.IsDirectory()))
{
if (svnPath.IsWCRoot())
{
CSVNStatusCache::Instance().AddFolderForCrawling(svnPath);
// Mark the directory as 'versioned' (status 'normal' for now).
// This initial value will be overwritten from below some time later
pThis->SetChildStatus(svnPath, svn_wc_status_normal);
// Make sure the entry is also in the cache
CSVNStatusCache::Instance().GetDirectoryCacheEntry(svnPath);
// also mark the status in the status object as normal
forceNormal = true;
}
else
{
pThis->SetChildStatus(svnPath, nodeStatus);
}
}
else if (nodeStatus == svn_wc_status_external)
{
if ((status->kind == svn_node_dir) || (svnPath.IsDirectory()))
{
CSVNStatusCache::Instance().AddFolderForCrawling(svnPath);
// Mark the directory as 'versioned' (status 'normal' for now).
// This initial value will be overwritten from below some time later
pThis->SetChildStatus(svnPath, svn_wc_status_normal);
// we have added a directory to the child-directory list of this
// directory. We now must make sure that this directory also has
//.........这里部分代码省略.........
示例7: WorkerThread
//.........这里部分代码省略.........
// But for now, we have to crawl the parent folder
// no matter what.
//if (lowerpath.Find(_T("\\lock"))>0)
// continue;
}
else if (!workingPath.Exists())
{
CGitStatusCache::Instance().WaitToWrite();
CGitStatusCache::Instance().RemoveCacheForPath(workingPath);
CGitStatusCache::Instance().Done();
continue;
}
do
{
workingPath = workingPath.GetContainingDirectory();
} while(workingPath.IsAdminDir());
ATLTRACE(_T("Invalidating and refreshing folder: %s\n"), workingPath.GetWinPath());
{
AutoLocker print(critSec);
_stprintf_s(szCurrentCrawledPath[nCurrentCrawledpathIndex], MAX_CRAWLEDPATHSLEN, _T("Invalidating and refreshing folder: %s"), workingPath.GetWinPath());
nCurrentCrawledpathIndex++;
if (nCurrentCrawledpathIndex >= MAX_CRAWLEDPATHS)
nCurrentCrawledpathIndex = 0;
}
InvalidateRect(hWnd, NULL, FALSE);
CGitStatusCache::Instance().WaitToRead();
// Invalidate the cache of this folder, to make sure its status is fetched again.
CCachedDirectory * pCachedDir = CGitStatusCache::Instance().GetDirectoryCacheEntry(workingPath);
if (pCachedDir)
{
git_wc_status_kind status = pCachedDir->GetCurrentFullStatus();
pCachedDir->Invalidate();
if (workingPath.Exists())
{
pCachedDir->RefreshStatus(bRecursive);
// if the previous status wasn't normal and now it is, then
// send a notification too.
// We do this here because GetCurrentFullStatus() doesn't send
// notifications for 'normal' status - if it would, we'd get tons
// of notifications when crawling a working copy not yet in the cache.
if ((status != git_wc_status_normal)&&(pCachedDir->GetCurrentFullStatus() != status))
{
CGitStatusCache::Instance().UpdateShell(workingPath);
ATLTRACE(_T("shell update in crawler for %s\n"), workingPath.GetWinPath());
}
}
else
{
CGitStatusCache::Instance().Done();
CGitStatusCache::Instance().WaitToWrite();
CGitStatusCache::Instance().RemoveCacheForPath(workingPath);
}
}
CGitStatusCache::Instance().Done();
//In case that svn_client_stat() modified a file and we got
//a notification about that in the directory watcher,
//remove that here again - this is to prevent an endless loop
AutoLocker lock(m_critSec);
m_pathsToUpdate.erase(std::remove(m_pathsToUpdate.begin(), m_pathsToUpdate.end(), workingPath), m_pathsToUpdate.end());
}
else if (workingPath.HasAdminDir())
{
if (!workingPath.Exists())
示例8: WorkerThread
//.........这里部分代码省略.........
CAutoWriteLock writeLock(CGitStatusCache::Instance().GetGuard());
CGitStatusCache::Instance().RemoveCacheForPath(workingPath);
continue;
}
if (!CGitStatusCache::Instance().IsPathGood(workingPath))
{
AutoLocker lock(m_critSec);
// move the path, the root of the repository, to the end of the list
if (projectroot.IsEmpty())
m_pathsToUpdate.Push(workingPath);
else
m_pathsToUpdate.Push(CTGitPath(projectroot));
if (m_pathsToUpdate.size() < 3)
Sleep(50);
continue;
}
CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) L": Invalidating and refreshing folder: %s\n", workingPath.GetWinPath());
{
AutoLocker print(critSec);
_sntprintf_s(szCurrentCrawledPath[nCurrentCrawledpathIndex], MAX_CRAWLEDPATHSLEN, _TRUNCATE, L"Invalidating and refreshing folder: %s", workingPath.GetWinPath());
++nCurrentCrawledpathIndex;
if (nCurrentCrawledpathIndex >= MAX_CRAWLEDPATHS)
nCurrentCrawledpathIndex = 0;
}
InvalidateRect(hWndHidden, nullptr, FALSE);
{
CAutoReadLock readLock(CGitStatusCache::Instance().GetGuard());
// Invalidate the cache of this folder, to make sure its status is fetched again.
CCachedDirectory * pCachedDir = CGitStatusCache::Instance().GetDirectoryCacheEntry(workingPath);
if (pCachedDir)
{
git_wc_status_kind status = pCachedDir->GetCurrentFullStatus();
pCachedDir->Invalidate();
if (workingPath.Exists())
{
pCachedDir->RefreshStatus(bRecursive);
// if the previous status wasn't normal and now it is, then
// send a notification too.
// We do this here because GetCurrentFullStatus() doesn't send
// notifications for 'normal' status - if it would, we'd get tons
// of notifications when crawling a working copy not yet in the cache.
if ((status != git_wc_status_normal) && (pCachedDir->GetCurrentFullStatus() != status))
{
CGitStatusCache::Instance().UpdateShell(workingPath);
CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) L": shell update in crawler for %s\n", workingPath.GetWinPath());
}
}
else
{
CAutoWriteLock writeLock(CGitStatusCache::Instance().GetGuard());
CGitStatusCache::Instance().RemoveCacheForPath(workingPath);
}
}
}
//In case that svn_client_stat() modified a file and we got
//a notification about that in the directory watcher,
//remove that here again - this is to prevent an endless loop
AutoLocker lock(m_critSec);
m_pathsToUpdate.erase(workingPath);
}
else if (workingPath.HasAdminDir())
{
if (!workingPath.Exists())
{
示例9: lock
git_error_t * CCachedDirectory::GetStatusCallback(void *baton, const char *path, git_wc_status2_t *status)
{
CCachedDirectory* pThis = (CCachedDirectory*)baton;
if (path == NULL)
return 0;
CTGitPath svnPath;
if(status->entry)
{
if ((status->text_status != git_wc_status_none)&&(status->text_status != git_wc_status_missing))
svnPath.SetFromSVN(path, (status->entry->kind == svn_node_dir));
else
svnPath.SetFromSVN(path);
if(svnPath.IsDirectory())
{
if(!svnPath.IsEquivalentToWithoutCase(pThis->m_directoryPath))
{
if (pThis->m_bRecursive)
{
// Add any versioned directory, which is not our 'self' entry, to the list for having its status updated
CGitStatusCache::Instance().AddFolderForCrawling(svnPath);
}
// Make sure we know about this child directory
// This initial status value is likely to be overwritten from below at some point
git_wc_status_kind s = GitStatus::GetMoreImportant(status->text_status, status->prop_status);
CCachedDirectory * cdir = CGitStatusCache::Instance().GetDirectoryCacheEntryNoCreate(svnPath);
if (cdir)
{
// This child directory is already in our cache!
// So ask this dir about its recursive status
git_wc_status_kind st = GitStatus::GetMoreImportant(s, cdir->GetCurrentFullStatus());
AutoLocker lock(pThis->m_critSec);
pThis->m_childDirectories[svnPath] = st;
}
else
{
// the child directory is not in the cache. Create a new entry for it in the cache which is
// initially 'unversioned'. But we added that directory to the crawling list above, which
// means the cache will be updated soon.
CGitStatusCache::Instance().GetDirectoryCacheEntry(svnPath);
AutoLocker lock(pThis->m_critSec);
pThis->m_childDirectories[svnPath] = s;
}
}
}
else
{
// Keep track of the most important status of all the files in this directory
// Don't include subdirectories in this figure, because they need to provide their
// own 'most important' value
pThis->m_mostImportantFileStatus = GitStatus::GetMoreImportant(pThis->m_mostImportantFileStatus, status->text_status);
pThis->m_mostImportantFileStatus = GitStatus::GetMoreImportant(pThis->m_mostImportantFileStatus, status->prop_status);
if (((status->text_status == git_wc_status_unversioned)||(status->text_status == git_wc_status_none))
&&(CGitStatusCache::Instance().IsUnversionedAsModified()))
{
// treat unversioned files as modified
if (pThis->m_mostImportantFileStatus != git_wc_status_added)
pThis->m_mostImportantFileStatus = GitStatus::GetMoreImportant(pThis->m_mostImportantFileStatus, git_wc_status_modified);
}
}
}
else
{
svnPath.SetFromSVN(path);
// Subversion returns no 'entry' field for versioned folders if they're
// part of another working copy (nested layouts).
// So we have to make sure that such an 'unversioned' folder really
// is unversioned.
if (((status->text_status == git_wc_status_unversioned)||(status->text_status == git_wc_status_missing))&&(!svnPath.IsEquivalentToWithoutCase(pThis->m_directoryPath))&&(svnPath.IsDirectory()))
{
if (svnPath.HasAdminDir())
{
CGitStatusCache::Instance().AddFolderForCrawling(svnPath);
// Mark the directory as 'versioned' (status 'normal' for now).
// This initial value will be overwritten from below some time later
{
AutoLocker lock(pThis->m_critSec);
pThis->m_childDirectories[svnPath] = git_wc_status_normal;
}
// Make sure the entry is also in the cache
CGitStatusCache::Instance().GetDirectoryCacheEntry(svnPath);
// also mark the status in the status object as normal
status->text_status = git_wc_status_normal;
}
}
else if (status->text_status == git_wc_status_external)
{
CGitStatusCache::Instance().AddFolderForCrawling(svnPath);
// Mark the directory as 'versioned' (status 'normal' for now).
// This initial value will be overwritten from below some time later
{
AutoLocker lock(pThis->m_critSec);
pThis->m_childDirectories[svnPath] = git_wc_status_normal;
}
// we have added a directory to the child-directory list of this
// directory. We now must make sure that this directory also has
//.........这里部分代码省略.........
示例10: GetStatusFromGit
CStatusCacheEntry CCachedDirectory::GetStatusFromGit(const CTGitPath &path, CString sProjectRoot)
{
CString subpaths = path.GetGitPathString();
if(subpaths.GetLength() >= sProjectRoot.GetLength())
{
if(subpaths[sProjectRoot.GetLength()] == _T('/'))
subpaths=subpaths.Right(subpaths.GetLength() - sProjectRoot.GetLength()-1);
else
subpaths=subpaths.Right(subpaths.GetLength() - sProjectRoot.GetLength());
}
GitStatus *pGitStatus = &CGitStatusCache::Instance().m_GitStatus;
CGitHash head;
pGitStatus->GetHeadHash(sProjectRoot,head);
bool isVersion =true;
pGitStatus->IsUnderVersionControl(sProjectRoot, subpaths, path.IsDirectory(), &isVersion);
if(!isVersion)
{ //untracked file
bool isIgnoreFileChanged=false;
isIgnoreFileChanged = pGitStatus->IsGitReposChanged(sProjectRoot, subpaths, GIT_MODE_IGNORE);
if( isIgnoreFileChanged)
{
pGitStatus->LoadIgnoreFile(sProjectRoot, subpaths);
}
if(path.IsDirectory())
{
CCachedDirectory * dirEntry = CGitStatusCache::Instance().GetDirectoryCacheEntry(path,
false); /* we needn't watch untracked directory*/
if(dirEntry)
{
AutoLocker lock(dirEntry->m_critSec);
git_wc_status_kind dirstatus = dirEntry->GetCurrentFullStatus() ;
if( dirstatus == git_wc_status_none || dirstatus >= git_wc_status_normal || isIgnoreFileChanged )
{/* status have not initialized*/
git_wc_status2_t status2;
bool isignore = false;
pGitStatus->IsIgnore(sProjectRoot,subpaths,&isignore);
status2.text_status = status2.prop_status =
(isignore? git_wc_status_ignored:git_wc_status_unversioned);
dirEntry->m_ownStatus.SetStatus(&status2);
dirEntry->m_ownStatus.SetKind(git_node_dir);
}
return dirEntry->m_ownStatus;
}
}
else /* path is file */
{
AutoLocker lock(m_critSec);
CString strCacheKey = GetCacheKey(path);
CacheEntryMap::iterator itMap = m_entryCache.find(strCacheKey);
if(itMap == m_entryCache.end() || isIgnoreFileChanged)
{
git_wc_status2_t status2;
bool isignore = false;
pGitStatus->IsIgnore(sProjectRoot,subpaths,&isignore);
status2.text_status = status2.prop_status =
(isignore? git_wc_status_ignored:git_wc_status_unversioned);
AddEntry(path, &status2);
return m_entryCache[strCacheKey];
}
else
{
return itMap->second;
}
}
return CStatusCacheEntry();
}
else
{
EnumFiles((CTGitPath*)&path, TRUE);
UpdateCurrentStatus();
return CStatusCacheEntry(m_ownStatus);
}
}