X-Git-Url: http://git.sourceforge.jp/view?p=tortoisegit%2FTortoiseGitJp.git;a=blobdiff_plain;f=src%2FTortoiseProc%2FGitLogListBase.cpp;h=188c70fff93d96a31ffbb43ccf9dca2db730af9b;hp=04ebca90e65b1455d2d1a28ee6f05f9a65c7024c;hb=8feb7c6a89a613054e5f42da7a0d99d022747c90;hpb=02b4972b0212d4374a62ed129185269da504c78a diff --git a/src/TortoiseProc/GitLogListBase.cpp b/src/TortoiseProc/GitLogListBase.cpp index 04ebca9..188c70f 100644 --- a/src/TortoiseProc/GitLogListBase.cpp +++ b/src/TortoiseProc/GitLogListBase.cpp @@ -59,6 +59,7 @@ CGitLogListBase::CGitLogListBase():CHintListCtrl() , m_nSelectedFilter(LOGFILTER_ALL) , m_bVista(false) , m_bShowWC(false) + , m_logEntries(&m_LogCache) { // use the default GUI font, create a copy of it and // change the copy to BOLD (leave the rest of the font @@ -73,7 +74,8 @@ CGitLogListBase::CGitLogListBase():CHintListCtrl() m_IsIDReplaceAction=FALSE; - m_wcRev.m_CommitHash=GIT_REV_ZERO; + this->m_critSec.Init(); + m_wcRev.m_CommitHash.Empty(); m_wcRev.m_Subject=_T("Working dir changes"); m_wcRev.m_ParentHash.clear(); m_wcRev.m_Mark=_T('-'); @@ -942,7 +944,7 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult) *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT; } - if(data->m_CommitHash == m_HeadHash) + if(data->m_CommitHash.ToString() == m_HeadHash) { SelectObject(pLVCD->nmcd.hdc, m_boldFont); *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT; @@ -951,7 +953,7 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult) // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end())) // crText = GetSysColor(COLOR_GRAYTEXT); // - if (data->m_CommitHash == GIT_REV_ZERO) + if (data->m_CommitHash.IsEmpty()) { //crText = GetSysColor(RGB(200,200,0)); //SelectObject(pLVCD->nmcd.hdc, m_boldFont); @@ -995,7 +997,7 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult) FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect); GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec); - if( data ->m_CommitHash != GIT_REV_ZERO) + if( !data ->m_CommitHash.IsEmpty()) DrawGraph(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec); *pResult = CDRF_SKIPDEFAULT; @@ -1151,7 +1153,7 @@ void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult) lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorName, pItem->cchTextMax); break; case this->LOGLIST_DATE: //Date - if (pLogEntry && pLogEntry->m_CommitHash != GIT_REV_ZERO) + if ( pLogEntry && (!pLogEntry->m_CommitHash.IsEmpty()) ) lstrcpyn(pItem->pszText, CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat, true, m_bRelativeTimes ), pItem->cchTextMax); @@ -1276,7 +1278,7 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) { { - if(pSelLogEntry->m_CommitHash != GIT_REV_ZERO) + if( !pSelLogEntry->m_CommitHash.IsEmpty()) { if(m_ContextMenuMask&GetContextMenuBit(ID_COMPARE)) popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF); @@ -1326,7 +1328,7 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) format.LoadString(IDS_RESET_TO_THIS_FORMAT); str.Format(format,g_Git.GetCurrentBranch()); - if(pSelLogEntry->m_CommitHash != GIT_REV_ZERO) + if(!pSelLogEntry->m_CommitHash.IsEmpty()) { if(m_ContextMenuMask&GetContextMenuBit(ID_RESET)) popup.AppendMenuIcon(ID_RESET,str,IDI_REVERT); @@ -1391,7 +1393,7 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) popup.AppendMenu(MF_SEPARATOR, NULL); } - if ( GetSelectedCount() >0 && pSelLogEntry->m_CommitHash != GIT_REV_ZERO) + if ( GetSelectedCount() >0 && (!pSelLogEntry->m_CommitHash.IsEmpty())) { if ( IsSelectionContinuous() && GetSelectedCount() >= 2 ) { @@ -1406,7 +1408,7 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) CString hash=g_Git.GetHash(head); hash=hash.Left(40); GitRev* pLastEntry = reinterpret_cast(m_arShownList.GetAt(LastSelect)); - if(pLastEntry->m_CommitHash == hash) + if(pLastEntry->m_CommitHash.ToString() == hash) popup.AppendMenuIcon(ID_COMBINE_COMMIT,IDS_COMBINE_TO_ONE,IDI_COMBINE); } } @@ -1726,12 +1728,12 @@ int CGitLogListBase::FillGitLog(CTGitPath *path,int info,CString *from,CString * { if(m_IsOldFirst) { - m_logEntries[m_logEntries.size()-i-1].m_IsFull=TRUE; + m_logEntries.GetGitRevAt(m_logEntries.size()-i-1).m_IsFull=TRUE; this->m_arShownList.Add(&m_logEntries[m_logEntries.size()-i-1]); }else { - m_logEntries[i].m_IsFull=TRUE; + m_logEntries.GetGitRevAt(i).m_IsFull=TRUE; this->m_arShownList.Add(&m_logEntries[i]); } } @@ -1742,11 +1744,12 @@ int CGitLogListBase::FillGitLog(CTGitPath *path,int info,CString *from,CString * } -int CGitLogListBase::FillGitShortLog() +int CGitLogListBase::BeginFetchLog() { ClearText(); this->m_logEntries.ClearAll(); + git_init(); m_LogCache.FetchCacheIndex(g_Git.m_CurrentDir); @@ -1762,10 +1765,15 @@ int CGitLogListBase::FillGitShortLog() // if(this->m_bAllBranch) mask |= m_ShowMask; + this->m_arShownList.RemoveAll(); + if(m_bShowWC) - this->m_logEntries.insert(m_logEntries.begin(),this->m_wcRev); + { + this->m_logEntries.insert(m_logEntries.begin(),this->m_wcRev.m_CommitHash); + this->m_LogCache.m_HashMap[m_wcRev.m_CommitHash]=m_wcRev; + } - this->m_logEntries.FetchShortLog(path,m_StartRef,-1,mask,m_bShowWC?1:0); + CString cmd=g_Git.GetLogCmd(m_StartRef,path,-1,mask,NULL,NULL,true); //this->m_logEntries.ParserFromLog(); if(IsInWorkingThread()) @@ -1776,23 +1784,12 @@ int CGitLogListBase::FillGitShortLog() { SetItemCountEx(this->m_logEntries.size()); } - - this->m_arShownList.RemoveAll(); - - for(unsigned int i=0;i0 || m_logEntries[i].m_CommitHash != GIT_REV_ZERO) - m_logEntries[i].m_Subject=_T("parser..."); - - if(this->m_IsOldFirst) - { - this->m_arShownList.Add(&m_logEntries[m_logEntries.size()-1-i]); - - }else - { - this->m_arShownList.Add(&m_logEntries[i]); - } + return -1; } + return 0; } @@ -1871,11 +1868,14 @@ void CGitLogListBase::GetTimeRange(CTime &oldest, CTime &latest) latest=CTime(1971,1,2,0,0,0); for(unsigned int i=0;i latest.GetTime()) - latest = m_logEntries[i].m_AuthorDate.GetTime(); + if(m_logEntries.GetGitRevAt(i).m_AuthorDate.GetTime() > latest.GetTime()) + latest = m_logEntries.GetGitRevAt(i).m_AuthorDate.GetTime(); } } @@ -1929,17 +1929,18 @@ public: } //Set updating int rev=itRev->second; - GitRev* revInVector=&m_ploglist->m_logEntries[rev]; + GitRev* revInVector=&m_ploglist->m_logEntries.GetGitRevAt(rev); if(revInVector->m_IsFull) return; - if(!m_ploglist->m_LogCache.GetCacheData(m_ploglist->m_logEntries[rev])) + GitRev *pRev= m_ploglist->m_LogCache.GetCacheData(m_ploglist->m_logEntries[rev]); + if(pRev) { ++m_CollectedCount; - InterlockedExchange(&m_ploglist->m_logEntries[rev].m_IsUpdateing,FALSE); - InterlockedExchange(&m_ploglist->m_logEntries[rev].m_IsFull,TRUE); + InterlockedExchange(&pRev->m_IsUpdateing,FALSE); + InterlockedExchange(&pRev->m_IsFull,TRUE); ::PostMessage(m_ploglist->m_hWnd,MSG_LOADED,(WPARAM)rev,0); return; } @@ -2015,22 +2016,23 @@ void CGitLogListBase::FetchLastLogInfo() { for(unsigned int i=0;im_IsUpdateing,FALSE); + InterlockedExchange(&pRev->m_IsFull,TRUE); } ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM)i,0); @@ -2047,7 +2049,92 @@ void CGitLogListBase::FetchLastLogInfo() UINT CGitLogListBase::LogThread() { + ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_START,0); + + InterlockedExchange(&m_bThreadRunning, TRUE); + InterlockedExchange(&m_bNoDispUpdates, TRUE); + + ULONGLONG t1,t2; + + if(BeginFetchLog()) + return -1; + //Update work copy item; + if( m_logEntries.size() > 0) + { + GitRev *pRev = &m_logEntries.GetGitRevAt(0); + + m_arShownList.Add(pRev); + + if( pRev->m_CommitHash.IsEmpty() ) + { + pRev->m_Files.Clear(); + pRev->m_ParentHash.clear(); + pRev->m_ParentHash.push_back(m_HeadHash); + g_Git.GetCommitDiffList(pRev->m_CommitHash.ToString(),this->m_HeadHash, pRev->m_Files); + pRev->m_Action =0; + + for(int j=0;j< pRev->m_Files.GetCount();j++) + pRev->m_Action |= pRev->m_Files[j].m_Action; + + pRev->m_Body.Format(_T("%d files changed"),m_logEntries.GetGitRevAt(0).m_Files.GetCount()); + ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM)0,0); + } + } + + InterlockedExchange(&m_bNoDispUpdates, FALSE); + + git_get_log_firstcommit(m_DllGitLog); + GIT_COMMIT commit; + t1=GetTickCount(); + + int oldsize=m_logEntries.size(); + while( git_get_log_nextcommit(this->m_DllGitLog,&commit) == 0) + { + //printf("%s\r\n",commit.m_Subject); + if(m_bExitThread) + break; + + CGitHash hash = (char*)commit.m_hash ; + + + GitRev *pRev = m_LogCache.GetCacheData(hash); + + if(pRev == NULL || !pRev->m_IsFull) + { + pRev->ParserFromCommit(&commit); + pRev->ParserParentFromCommit(&commit); + + pRev->SafeFetchFullInfo(&g_Git); + git_free_commit(&commit); + + }else + { + ASSERT(pRev->m_CommitHash == hash); + pRev->ParserParentFromCommit(&commit); + } + + this->m_critSec.Lock(); + m_logEntries.push_back(hash); + m_arShownList.Add(pRev); + this->m_critSec.Unlock(); + + if(t2-t1>500 ) + { + //update UI + oldsize = m_logEntries.size(); + PostMessage(LVM_SETITEMCOUNT, (WPARAM) this->m_logEntries.size(),(LPARAM) LVSICF_NOINVALIDATEALL|LVSICF_NOSCROLL); + ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_END,0); + } + } + + //Update UI; + PostMessage(LVM_SETITEMCOUNT, (WPARAM) this->m_logEntries.size(),(LPARAM) LVSICF_NOINVALIDATEALL|LVSICF_NOSCROLL); + ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_END,0); + + InterlockedExchange(&m_bThreadRunning, FALSE); + +#if 0 // if(m_ProcCallBack) // m_ProcCallBack(m_ProcData,GITLOG_START); ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_START,0); @@ -2077,36 +2164,38 @@ UINT CGitLogListBase::LogThread() int update=0; for(int i=0;im_HeadHash,m_logEntries[i].m_Files); - m_logEntries[i].m_Action =0; - for(int j=0;j< m_logEntries[i].m_Files.GetCount();j++) - m_logEntries[i].m_Action |= m_logEntries[i].m_Files[j].m_Action; + m_logEntries.GetGitRevAt(i).m_Files.Clear(); + m_logEntries.GetGitRevAt(i).m_ParentHash.clear(); + m_logEntries.GetGitRevAt(i).m_ParentHash.push_back(m_HeadHash); + g_Git.GetCommitDiffList(m_logEntries.GetGitRevAt(i).m_CommitHash.ToString(),this->m_HeadHash,m_logEntries.GetGitRevAt(i).m_Files); + m_logEntries.GetGitRevAt(i).m_Action =0; + for(int j=0;j< m_logEntries.GetGitRevAt(i).m_Files.GetCount();j++) + m_logEntries.GetGitRevAt(i).m_Action |= m_logEntries.GetGitRevAt(i).m_Files[j].m_Action; - m_logEntries[i].m_Body.Format(_T("%d files changed"),m_logEntries[i].m_Files.GetCount()); + m_logEntries.GetGitRevAt(i).m_Body.Format(_T("%d files changed"),m_logEntries.GetGitRevAt(i).m_Files.GetCount()); ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM)0,0); continue; } - start=this->m_logEntries[i].ParserFromLog(m_logEntries.m_RawlogData,start); - m_logEntries.m_HashMap[m_logEntries[i].m_CommitHash]=i; + start=this->m_logEntries.GetGitRevAt(i).ParserFromLog(m_logEntries.m_RawlogData,start); + m_logEntries.m_HashMap[m_logEntries.GetGitRevAt(i).m_CommitHash.ToString()]=i; - if(m_LogCache.GetCacheData(m_logEntries[i])) + if(m_LogCache.GetCacheData(m_logEntries.GetGitRevAt(i))) { if(firstcommit.IsEmpty()) - firstcommit=m_logEntries[i].m_CommitHash; - lastcommit=m_logEntries[i].m_CommitHash; + firstcommit=m_logEntries.GetGitRevAt(i).m_CommitHash.ToString(); + lastcommit=m_logEntries.GetGitRevAt(i).m_CommitHash.ToString(); }else { - InterlockedExchange(&m_logEntries[i].m_IsUpdateing,FALSE); - InterlockedExchange(&m_logEntries[i].m_IsFull,TRUE); + InterlockedExchange(&m_logEntries.GetGitRevAt(i).m_IsUpdateing,FALSE); + InterlockedExchange(&m_logEntries.GetGitRevAt(i).m_IsFull,TRUE); update++; } + ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM) i, 0); + if(start<0) break; if(start>=m_logEntries.m_RawlogData.size()) @@ -2115,7 +2204,6 @@ UINT CGitLogListBase::LogThread() int percent=i*30/m_logEntries.size() + GITLOG_START+1; ::PostMessage(GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) percent, 0); - ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM) i, 0); if(this->m_bExitThread) { @@ -2165,7 +2253,7 @@ UINT CGitLogListBase::LogThread() ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_END,0); InterlockedExchange(&m_bThreadRunning, FALSE); - +#endif return 0; } @@ -2245,17 +2333,17 @@ void CGitLogListBase::RecalculateShownList(CPtrArray * pShownlist) #endif if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES)) { - ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries[i].m_Subject); - if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_Subject), pat, flags)&&IsEntryInDateRange(i)) + ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries.GetGitRevAt(i).m_Subject); + if (regex_search(wstring((LPCTSTR)m_logEntries.GetGitRevAt(i).m_Subject), pat, flags)&&IsEntryInDateRange(i)) { pShownlist->Add(&m_logEntries[i]); continue; } - ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries[i].m_Body); - if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_Body), pat, flags)&&IsEntryInDateRange(i)) + ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries.GetGitRevAt(i).m_Body); + if (regex_search(wstring((LPCTSTR)m_logEntries.GetGitRevAt(i).m_Body), pat, flags)&&IsEntryInDateRange(i)) { - pShownlist->Add(&m_logEntries[i]); + pShownlist->Add(&m_logEntries.GetGitRevAt(i)); continue; } } @@ -2293,18 +2381,18 @@ void CGitLogListBase::RecalculateShownList(CPtrArray * pShownlist) #endif if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS)) { - if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_AuthorName), pat, flags)&&IsEntryInDateRange(i)) + if (regex_search(wstring((LPCTSTR)m_logEntries.GetGitRevAt(i).m_AuthorName), pat, flags)&&IsEntryInDateRange(i)) { - pShownlist->Add(&m_logEntries[i]); + pShownlist->Add(&m_logEntries.GetGitRevAt(i)); continue; } } if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS)) { - sRev.Format(_T("%s"), m_logEntries[i].m_CommitHash); + sRev.Format(_T("%s"), m_logEntries.GetGitRevAt(i).m_CommitHash); if (regex_search(wstring((LPCTSTR)sRev), pat, flags)&&IsEntryInDateRange(i)) { - pShownlist->Add(&m_logEntries[i]); + pShownlist->Add(&m_logEntries.GetGitRevAt(i)); continue; } } @@ -2328,15 +2416,15 @@ void CGitLogListBase::RecalculateShownList(CPtrArray * pShownlist) #endif if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES)) { - CString msg = m_logEntries[i].m_Subject; + CString msg = m_logEntries.GetGitRevAt(i).m_Subject; msg = msg.MakeLower(); if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i))) { - pShownlist->Add(&m_logEntries[i]); + pShownlist->Add(&m_logEntries.GetGitRevAt(i)); continue; } - msg = m_logEntries[i].m_Body; + msg = m_logEntries.GetGitRevAt(i).m_Body; msg = msg.MakeLower(); if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i))) @@ -2383,20 +2471,20 @@ void CGitLogListBase::RecalculateShownList(CPtrArray * pShownlist) #endif if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS)) { - CString msg = m_logEntries[i].m_AuthorName; + CString msg = m_logEntries.GetGitRevAt(i).m_AuthorName; msg = msg.MakeLower(); if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i))) { - pShownlist->Add(&m_logEntries[i]); + pShownlist->Add(&m_logEntries.GetGitRevAt(i)); continue; } } if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS)) { - sRev.Format(_T("%s"), m_logEntries[i].m_CommitHash); + sRev.Format(_T("%s"), m_logEntries.GetGitRevAt(i).m_CommitHash); if ((sRev.Find(find) >= 0)&&(IsEntryInDateRange(i))) { - pShownlist->Add(&m_logEntries[i]); + pShownlist->Add(&m_logEntries.GetGitRevAt(i)); continue; } } @@ -2407,7 +2495,7 @@ void CGitLogListBase::RecalculateShownList(CPtrArray * pShownlist) BOOL CGitLogListBase::IsEntryInDateRange(int i) { - __time64_t time = m_logEntries[i].m_AuthorDate.GetTime(); + __time64_t time = m_logEntries.GetGitRevAt(i).m_AuthorDate.GetTime(); if ((time >= m_From.GetTime())&&(time <= m_To.GetTime())) return TRUE; @@ -2543,7 +2631,7 @@ int CGitLogListBase::GetHeadIndex() GitRev *pRev = (GitRev*)m_arShownList[i]; if(pRev) { - if(pRev->m_CommitHash == m_HeadHash ) + if(pRev->m_CommitHash.ToString() == m_HeadHash ) return i; } }