From 8540c9607bece3f8c35a3edd7740a686ef0c0892 Mon Sep 17 00:00:00 2001 From: Frank Li Date: Sat, 2 Jan 2010 22:34:19 +0800 Subject: [PATCH] Change Log Code structure Unfinished Signed-off-by: Frank Li --- src/Git/Git.vcproj | 8 +-- src/Git/GitHash.h | 101 ++++++++++++++++++++++++++++++++++ src/Git/GitRev.cpp | 5 +- src/Git/GitRev.h | 5 +- src/TortoiseGit.sln | 3 + src/TortoiseProc/GitLogCache.cpp | 38 ++++++------- src/TortoiseProc/GitLogListAction.cpp | 44 +++++++-------- src/TortoiseProc/GitLogListBase.cpp | 79 +++++++++++++------------- src/TortoiseProc/LogDataVector.cpp | 2 + src/TortoiseProc/LogDlgHelper.h | 14 ++++- src/TortoiseProc/TortoiseProc.vcproj | 24 ++++---- src/TortoiseProc/gitlogcache.h | 20 +++++-- src/TortoiseShell/SVNPropertyPage.cpp | 4 +- src/Utils/TempFile.cpp | 4 +- 14 files changed, 239 insertions(+), 112 deletions(-) create mode 100644 src/Git/GitHash.h diff --git a/src/Git/Git.vcproj b/src/Git/Git.vcproj index 5d039e7c1..4ed73dfd3 100644 --- a/src/Git/Git.vcproj +++ b/src/Git/Git.vcproj @@ -46,7 +46,7 @@ = _T('0') && ch <= _T('9')) + a |= (ch - _T('0'))&0xF; + else if(ch >=_T('A') && ch <= _T('F')) + a |= (ch - _T('A'))&0xF; + else if(ch >=_T('a') && ch <= _T('f')) + a |= (ch - _T('a'))&0xF; + + a =a<<4; + } + m_hash[i]=a; + } + } + void Empty() + { + memset(m_hash,0, GIT_HASH_SIZE); + } + bool IsEmpty() + { + for(int i=0;i(const CGitHash& left, const CGitHash& right) + { + return memcmp(left.m_hash, right.m_hash, GIT_HASH_SIZE) > 0; + } + +#if defined(_MFC_VER) + friend CArchive& AFXAPI operator<<(CArchive& ar, CGitHash& hash) + { + for(int i=0;i>(CArchive& ar, CGitHash& hash) + { + for(int i=0;i>hash.m_hash[i]; + return ar; + } +#endif +}; + diff --git a/src/Git/GitRev.cpp b/src/Git/GitRev.cpp index f8e741bde..145dbe9bf 100644 --- a/src/Git/GitRev.cpp +++ b/src/Git/GitRev.cpp @@ -2,6 +2,7 @@ #include "ATLComTime.h" #include "GitRev.h" #include "Git.h" +#include "GitDLL.h" class CException; //Just in case afx.h is not included (cannot be included in every project which uses this file) @@ -254,8 +255,8 @@ int GitRev::SafeFetchFullInfo(CGit *git) //GitRev rev; BYTE_VECTOR onelog; TCHAR oldmark=this->m_Mark; - - git->GetLog(onelog,m_CommitHash,NULL,1,CGit::LOG_INFO_FULL_DIFF|CGit::LOG_INFO_STAT|CGit::LOG_INFO_FILESTATE|CGit::LOG_INFO_DETECT_COPYRENAME|CGit::LOG_INFO_SHOW_MERGEDFILE); + CString commithash = m_CommitHash; + git->GetLog(onelog,commithash,NULL,1,CGit::LOG_INFO_FULL_DIFF|CGit::LOG_INFO_STAT|CGit::LOG_INFO_FILESTATE|CGit::LOG_INFO_DETECT_COPYRENAME|CGit::LOG_INFO_SHOW_MERGEDFILE); CString oldhash=m_CommitHash; GIT_REV_LIST oldlist=this->m_ParentHash; ParserFromLog(onelog); diff --git a/src/Git/GitRev.h b/src/Git/GitRev.h index 2fc1cf2f7..320a75b2b 100644 --- a/src/Git/GitRev.h +++ b/src/Git/GitRev.h @@ -2,8 +2,9 @@ #include "gittype.h" #include "GitStatus.h" #include "AtlTime.h" +#include "GitHash.h" -typedef std::vector GIT_REV_LIST; +typedef std::vector GIT_REV_LIST; #define LOG_REV_AUTHOR_NAME _T('0') #define LOG_REV_AUTHOR_EMAIL _T('1') @@ -50,7 +51,7 @@ public: CTime m_CommitterDate; CString m_Subject; CString m_Body; - git_revnum_t m_CommitHash; + CGitHash m_CommitHash; GIT_REV_LIST m_ParentHash; CTGitPathList m_Files; int m_Action; diff --git a/src/TortoiseGit.sln b/src/TortoiseGit.sln index 2882ba69c..95680bf56 100644 --- a/src/TortoiseGit.sln +++ b/src/TortoiseGit.sln @@ -2,6 +2,9 @@ Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Git", "Git\Git.vcproj", "{7CA5B1EB-8CC9-40A6-96D8-83649C1A870B}" + ProjectSection(ProjectDependencies) = postProject + {4F0A55DE-DAFD-4A0B-A03D-2C14CB77E08F} = {4F0A55DE-DAFD-4A0B-A03D-2C14CB77E08F} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TortoiseProc", "TortoiseProc\TortoiseProc.vcproj", "{50797F06-39C5-4802-8E2B-7B7A4EF03214}" ProjectSection(ProjectDependencies) = postProject diff --git a/src/TortoiseProc/GitLogCache.cpp b/src/TortoiseProc/GitLogCache.cpp index a167e0ac1..8b0458c22 100644 --- a/src/TortoiseProc/GitLogCache.cpp +++ b/src/TortoiseProc/GitLogCache.cpp @@ -13,7 +13,7 @@ CLogCache::~CLogCache() } int CLogCache::AddCacheEntry(GitRev &Rev) { - this->m_NewCacheEntry.push_back(Rev); + this->m_HashMap[Rev.m_CommitHash] = Rev; return 0; } @@ -21,13 +21,10 @@ int CLogCache::GetCacheData(GitRev &Rev) { if(this->m_HashMapIndex.find(Rev.m_CommitHash)==m_HashMapIndex.end()) { - for(int i=0;im_NewCacheEntry.size();i++) + if(this->m_HashMap.IsExist(Rev.m_CommitHash)) { - if(m_NewCacheEntry[i].m_CommitHash==Rev.m_CommitHash) - { - Rev.CopyFrom(m_NewCacheEntry[i],true); - return 0; - } + Rev.CopyFrom(m_HashMap[Rev.m_CommitHash]); + return 0; } return -1; } @@ -78,9 +75,7 @@ int CLogCache::FetchCacheIndex(CString GitDir) if( count != sizeof(SLogCacheItem) ) break; - CString str; - g_Git.StringAppend(&str,Item.m_Hash,CP_UTF8,40); - this->m_HashMapIndex[str]=Item.m_Offset; + this->m_HashMapIndex[Item.m_Hash]=Item.m_Offset; } return 0; @@ -225,7 +220,7 @@ int CLogCache::RebuildCacheFile() } int CLogCache::SaveCache() { - if( this->m_NewCacheEntry.size() == 0 ) + if( this->m_HashMap.size() == 0 ) return 0; bool bIsRebuild=false; @@ -283,19 +278,22 @@ int CLogCache::SaveCache() m_DataFile.SeekToEnd(); m_IndexFile.SeekToEnd(); - for(int i=0;im_NewCacheEntry.size();i++) + CGitHashMap::iterator i; + for(i=m_HashMap.begin();i!=m_HashMap.end();i++) { - if(this->m_HashMapIndex.find(m_NewCacheEntry[i].m_CommitHash) == m_HashMapIndex.end() || bIsRebuild) + if(this->m_HashMapIndex.find((*i).second.m_CommitHash) == m_HashMapIndex.end() || bIsRebuild) { - ULONGLONG offset = m_DataFile.GetPosition(); - this->SaveOneItem(m_NewCacheEntry[i],offset); + if((*i).second.m_IsFull) + { + ULONGLONG offset = m_DataFile.GetPosition(); + this->SaveOneItem((*i).second,offset); - SLogCacheItem item; - for(int j=0; j<40;j++) - item.m_Hash[j]=(BYTE)m_NewCacheEntry[i].m_CommitHash[j]; - item.m_Offset=offset; + SLogCacheItem item; + item.m_Hash = (*i).second.m_CommitHash; + item.m_Offset=offset; - m_IndexFile.Write(&item,sizeof(SLogCacheItem)); + m_IndexFile.Write(&item,sizeof(SLogCacheItem)); + } } } m_IndexFile.Close(); diff --git a/src/TortoiseProc/GitLogListAction.cpp b/src/TortoiseProc/GitLogListAction.cpp index ac8813710..21558ccaa 100644 --- a/src/TortoiseProc/GitLogListAction.cpp +++ b/src/TortoiseProc/GitLogListAction.cpp @@ -53,7 +53,7 @@ IMPLEMENT_DYNAMIC(CGitLogList, CHintListCtrl) int CGitLogList::CherryPickFrom(CString from, CString to) { - CLogDataVector logs; + CLogDataVector logs(&m_LogCache); if(logs.ParserFromLog(NULL,-1,0,&from,&to)) return -1; @@ -73,8 +73,8 @@ int CGitLogList::CherryPickFrom(CString from, CString to) { if (progress.IsValid()) { - progress.FormatPathLine(1, _T("Pick up %s"), logs[i].m_CommitHash); - progress.FormatPathLine(2, _T("%s"), logs[i].m_Subject); + progress.FormatPathLine(1, _T("Pick up %s"), logs.GetGitRevAt(i).m_CommitHash); + progress.FormatPathLine(2, _T("%s"), logs.GetGitRevAt(i).m_Subject); progress.SetProgress(logs.size()-i, logs.size()); } if ((progress.IsValid())&&(progress.HasUserCancelled())) @@ -84,7 +84,7 @@ int CGitLogList::CherryPickFrom(CString from, CString to) return -1; } CString cmd,out; - cmd.Format(_T("git.exe cherry-pick %s"),logs[i].m_CommitHash); + cmd.Format(_T("git.exe cherry-pick %s"),logs.GetGitRevAt(i).m_CommitHash); out.Empty(); if(g_Git.Run(cmd,&out,CP_UTF8)) { @@ -124,14 +124,14 @@ void CGitLogList::ContextMenuAction(int cmd,int FirstSelect, int LastSelect) CString tempfile=GetTempFile(); CString cmd; GitRev * r1 = reinterpret_cast(m_arShownList.GetAt(FirstSelect)); - if(r1->m_CommitHash != GIT_REV_ZERO) + if(!r1->m_CommitHash.IsEmpty()) { cmd.Format(_T("git.exe diff-tree -r -p --stat %s"),r1->m_CommitHash); }else cmd.Format(_T("git.exe diff -r -p --stat")); g_Git.RunLogFile(cmd,tempfile); - CAppUtils::StartUnifiedDiffViewer(tempfile,r1->m_CommitHash.Left(6)+_T(":")+r1->m_Subject); + CAppUtils::StartUnifiedDiffViewer(tempfile,r1->m_CommitHash.ToString().Left(6)+_T(":")+r1->m_Subject); } break; @@ -142,17 +142,17 @@ void CGitLogList::ContextMenuAction(int cmd,int FirstSelect, int LastSelect) GitRev * r1 = reinterpret_cast(m_arShownList.GetAt(FirstSelect)); GitRev * r2 = reinterpret_cast(m_arShownList.GetAt(LastSelect)); - if( r1->m_CommitHash == GIT_REV_ZERO) + if( r1->m_CommitHash.IsEmpty()) { cmd.Format(_T("git.exe diff -r -p --stat %s"),r2->m_CommitHash); - }else if( r2->m_CommitHash == GIT_REV_ZERO) + }else if( r2->m_CommitHash.IsEmpty()) { cmd.Format(_T("git.exe diff -r -p --stat %s"),r1->m_CommitHash); }else cmd.Format(_T("git.exe diff-tree -r -p --stat %s %s"),r1->m_CommitHash,r2->m_CommitHash); g_Git.RunLogFile(cmd,tempfile); - CAppUtils::StartUnifiedDiffViewer(tempfile,r1->m_CommitHash.Left(6)+_T(":")+r2->m_CommitHash.Left(6)); + CAppUtils::StartUnifiedDiffViewer(tempfile,r1->m_CommitHash.ToString().Left(6)+_T(":")+r2->m_CommitHash.ToString().Left(6)); } break; @@ -198,7 +198,7 @@ void CGitLogList::ContextMenuAction(int cmd,int FirstSelect, int LastSelect) if(pSelLogEntry->m_ParentHash.size()>0) //if(m_logEntries.m_HashMap[pSelLogEntry->m_ParentHash[0]]>=0) { - dlg.SetDiff(NULL,pSelLogEntry->m_CommitHash,pSelLogEntry->m_ParentHash[0]); + dlg.SetDiff(NULL,pSelLogEntry->m_CommitHash.ToString(),pSelLogEntry->m_ParentHash[0].ToString()); dlg.DoModal(); }else { @@ -226,25 +226,25 @@ void CGitLogList::ContextMenuAction(int cmd,int FirstSelect, int LastSelect) } break; case ID_EXPORT: - CAppUtils::Export(&pSelLogEntry->m_CommitHash); + CAppUtils::Export(&pSelLogEntry->m_CommitHash.ToString()); break; case ID_CREATE_BRANCH: - CAppUtils::CreateBranchTag(FALSE,&pSelLogEntry->m_CommitHash); + CAppUtils::CreateBranchTag(FALSE,&pSelLogEntry->m_CommitHash.ToString()); ReloadHashMap(); Invalidate(); break; case ID_CREATE_TAG: - CAppUtils::CreateBranchTag(TRUE,&pSelLogEntry->m_CommitHash); + CAppUtils::CreateBranchTag(TRUE,&pSelLogEntry->m_CommitHash.ToString()); ReloadHashMap(); Invalidate(); break; case ID_SWITCHTOREV: - CAppUtils::Switch(&pSelLogEntry->m_CommitHash); + CAppUtils::Switch(&pSelLogEntry->m_CommitHash.ToString()); ReloadHashMap(); Invalidate(); break; case ID_RESET: - CAppUtils::GitReset(&pSelLogEntry->m_CommitHash); + CAppUtils::GitReset(&pSelLogEntry->m_CommitHash.ToString()); ReloadHashMap(); Invalidate(); break; @@ -413,8 +413,8 @@ void CGitLogList::ContextMenuAction(int cmd,int FirstSelect, int LastSelect) while(pos) { int indexNext = GetNextSelectedItem(pos); - dlg.m_CommitList.m_logEntries.push_back(*(GitRev*)m_arShownList[indexNext]); - dlg.m_CommitList.m_logEntries.at(dlg.m_CommitList.m_logEntries.size()-1).m_Action |= CTGitPath::LOGACTIONS_REBASE_PICK; + dlg.m_CommitList.m_logEntries.push_back( ((GitRev*)m_arShownList[indexNext])->m_CommitHash ); + dlg.m_CommitList.m_logEntries.GetGitRevAt(dlg.m_CommitList.m_logEntries.size()-1).m_Action |= CTGitPath::LOGACTIONS_REBASE_PICK; } if(dlg.DoModal() == IDOK) @@ -474,20 +474,20 @@ void CGitLogList::ContextMenuAction(int cmd,int FirstSelect, int LastSelect) GitRev * r2 = NULL; if(select == 1) { - cmd += _T(" /startrev:")+r1->m_CommitHash; + cmd += _T(" /startrev:")+r1->m_CommitHash.ToString(); } else { r2 = reinterpret_cast(m_arShownList.GetAt(LastSelect)); if( this->m_IsOldFirst ) { - cmd += _T(" /startrev:")+r1->m_CommitHash+_T("~1"); - cmd += _T(" /endrev:")+r2->m_CommitHash; + cmd += _T(" /startrev:")+r1->m_CommitHash.ToString()+_T("~1"); + cmd += _T(" /endrev:")+r2->m_CommitHash.ToString(); }else { - cmd += _T(" /startrev:")+r2->m_CommitHash+_T("~1"); - cmd += _T(" /endrev:")+r1->m_CommitHash; + cmd += _T(" /startrev:")+r2->m_CommitHash.ToString()+_T("~1"); + cmd += _T(" /endrev:")+r1->m_CommitHash.ToString(); } } diff --git a/src/TortoiseProc/GitLogListBase.cpp b/src/TortoiseProc/GitLogListBase.cpp index f4e23143f..bc888ecf0 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,7 @@ CGitLogListBase::CGitLogListBase():CHintListCtrl() m_IsIDReplaceAction=FALSE; - m_wcRev.m_CommitHash=GIT_REV_ZERO; + m_wcRev.m_CommitHash.Empty(); m_wcRev.m_Subject=_T("Working dir changes"); m_wcRev.m_ParentHash.clear(); m_wcRev.m_Mark=_T('-'); @@ -823,7 +824,7 @@ void CGitLogListBase::DrawGraph(HDC hdc,CRect &rect,INT_PTR index) if (data->m_Lanes.size() == 0) - m_logEntries.setLane(data->m_CommitHash); + m_logEntries.setLane(data->m_CommitHash.ToString()); std::vector& lanes=data->m_Lanes; UINT laneNum = lanes.size(); @@ -951,7 +952,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 +996,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 +1152,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 +1277,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 +1327,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 +1392,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 ) { @@ -1726,12 +1727,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]); } } @@ -1763,7 +1764,7 @@ int CGitLogListBase::FillGitShortLog() mask |= m_ShowMask; 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_logEntries.FetchShortLog(path,m_StartRef,-1,mask,m_bShowWC?1:0); @@ -1781,8 +1782,8 @@ int CGitLogListBase::FillGitShortLog() for(unsigned int i=0;i0 || m_logEntries[i].m_CommitHash != GIT_REV_ZERO) - m_logEntries[i].m_Subject=_T("parser..."); + if(i>0 || !m_logEntries.GetGitRevAt(i).m_CommitHash.IsEmpty()) + m_logEntries.GetGitRevAt(i).m_Subject=_T("parser..."); if(this->m_IsOldFirst) { @@ -1871,11 +1872,11 @@ 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 +1930,17 @@ 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])) + if(!m_ploglist->m_LogCache.GetCacheData(m_ploglist->m_logEntries.GetGitRevAt(rev))) { ++m_CollectedCount; - InterlockedExchange(&m_ploglist->m_logEntries[rev].m_IsUpdateing,FALSE); - InterlockedExchange(&m_ploglist->m_logEntries[rev].m_IsFull,TRUE); + InterlockedExchange(&m_ploglist->m_logEntries.GetGitRevAt(rev).m_IsUpdateing,FALSE); + InterlockedExchange(&m_ploglist->m_logEntries.GetGitRevAt(rev).m_IsFull,TRUE); ::PostMessage(m_ploglist->m_hWnd,MSG_LOADED,(WPARAM)rev,0); return; } @@ -2015,22 +2016,22 @@ void CGitLogListBase::FetchLastLogInfo() { for(unsigned 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,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); + start=this->m_logEntries.GetGitRevAt(i).ParserFromLog(m_logEntries.m_RawlogData,start); m_logEntries.m_HashMap[m_logEntries[i].m_CommitHash]=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; @@ -2103,8 +2104,8 @@ UINT CGitLogListBase::LogThread() }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); diff --git a/src/TortoiseProc/LogDataVector.cpp b/src/TortoiseProc/LogDataVector.cpp index 35057e4c3..8e9214d92 100644 --- a/src/TortoiseProc/LogDataVector.cpp +++ b/src/TortoiseProc/LogDataVector.cpp @@ -62,6 +62,8 @@ //#include "RepositoryInfo.h" //#include "EditPropertiesDlg.h" #include "FileDiffDlg.h" +#include "GitHash.h" +CGitHashMap a; void CLogDataVector::ClearAll() { diff --git a/src/TortoiseProc/LogDlgHelper.h b/src/TortoiseProc/LogDlgHelper.h index 1b0e56ca4..ce2db33f9 100644 --- a/src/TortoiseProc/LogDlgHelper.h +++ b/src/TortoiseProc/LogDlgHelper.h @@ -23,7 +23,8 @@ #include "ILogReceiver.h" #include "lanes.h" #include - +#include "GitHash.h" +#include "GitLogCache.h" class CLogDlg; /** @@ -49,14 +50,21 @@ protected: * Helper class for the log dialog, handles all the log entries, including * sorting. */ -class CLogDataVector : public std::vector +class CLogDataVector : public std::vector { public: + CLogCache *m_pLogCache; /// De-allocates log items. - CLogDataVector() + CLogDataVector(CLogCache *pLogCache) { + m_pLogCache=pLogCache; m_FirstFreeLane=0; } + GitRev & GetGitRevAt(int i) + { + ASSERT(im_HashMap[(*this)[i]]; + } void ClearAll(); int ParserFromLog(CTGitPath *path =NULL,int count = -1,int infomask=CGit::LOG_INFO_STAT|CGit::LOG_INFO_FILESTATE|CGit::LOG_INFO_SHOW_MERGEDFILE, CString *from=NULL,CString *to=NULL); diff --git a/src/TortoiseProc/TortoiseProc.vcproj b/src/TortoiseProc/TortoiseProc.vcproj index e29bd6096..b2c917785 100644 --- a/src/TortoiseProc/TortoiseProc.vcproj +++ b/src/TortoiseProc/TortoiseProc.vcproj @@ -588,11 +588,11 @@ > +{ +public: + bool IsExist(CGitHash &hash) + { + return find(hash) != end(); + } +}; + #define INDEX_FILE_NAME _T("tortoisegit.index") #define DATA_FILE_NAME _T("tortoisegit.data") #define LOCK_FILE_NAME _T("tortoisegit.lock") @@ -89,8 +99,10 @@ public: CLogCache(); ~CLogCache(); int FetchCacheIndex(CString GitDir); - std::vector m_NewCacheEntry; - std::map m_HashMapIndex; + + CGitHashMap m_HashMap; + std::map m_HashMapIndex; + int GetCacheData(GitRev &Rev); int AddCacheEntry(GitRev &Rev); int SaveCache(); diff --git a/src/TortoiseShell/SVNPropertyPage.cpp b/src/TortoiseShell/SVNPropertyPage.cpp index f59322f09..078d52d8c 100644 --- a/src/TortoiseShell/SVNPropertyPage.cpp +++ b/src/TortoiseShell/SVNPropertyPage.cpp @@ -281,7 +281,7 @@ void CGitPropertyPage::InitWorkfileView() SetDlgItemText(m_hwnd,IDC_SHELL_CURRENT_BRANCH,branch); SetDlgItemText(m_hwnd,IDC_SHELL_REMOTE_BRANCH,remotebranch); - SetDlgItemText(m_hwnd,IDC_HEAD_HASH,rev.m_CommitHash); + SetDlgItemText(m_hwnd,IDC_HEAD_HASH,rev.m_CommitHash.ToString()); SetDlgItemText(m_hwnd,IDC_HEAD_SUBJECT,rev.m_Subject); SetDlgItemText(m_hwnd,IDC_HEAD_AUTHOR,rev.m_AuthorName); SetDlgItemText(m_hwnd,IDC_HEAD_DATE,rev.m_AuthorDate.Format(_T("%Y-%m-%d %H:%M:%S"))); @@ -313,7 +313,7 @@ void CGitPropertyPage::InitWorkfileView() rev.Clear(); rev.ParserFromLog(logout); - SetDlgItemText(m_hwnd,IDC_LAST_HASH,rev.m_CommitHash); + SetDlgItemText(m_hwnd,IDC_LAST_HASH,rev.m_CommitHash.ToString()); SetDlgItemText(m_hwnd,IDC_LAST_SUBJECT,rev.m_Subject); SetDlgItemText(m_hwnd,IDC_LAST_AUTHOR,rev.m_AuthorName); SetDlgItemText(m_hwnd,IDC_LAST_DATE,rev.m_AuthorDate.Format(_T("%Y-%m-%d %H:%M:%S"))); diff --git a/src/Utils/TempFile.cpp b/src/Utils/TempFile.cpp index d223bb4e3..e15fe92db 100644 --- a/src/Utils/TempFile.cpp +++ b/src/Utils/TempFile.cpp @@ -54,9 +54,9 @@ CTGitPath CTempFiles::GetTempFilePath(bool bRemoveAtEnd, const CTGitPath& path / int i=0; do { - if (!revision.m_CommitHash.IsEmpty()) + if (!((GitRev&)revision).m_CommitHash.IsEmpty()) { - possibletempfile.Format(_T("%s%s-rev%s.git%3.3x.tmp%s"), temppath, (LPCTSTR)path.GetFileOrDirectoryName(), (LPCTSTR)revision.m_CommitHash.Left(7), i, (LPCTSTR)path.GetFileExtension()); + possibletempfile.Format(_T("%s%s-rev%s.git%3.3x.tmp%s"), temppath, (LPCTSTR)path.GetFileOrDirectoryName(), (LPCTSTR)((GitRev&)revision).m_CommitHash.ToString().Left(7), i, (LPCTSTR)path.GetFileExtension()); } else { -- 2.11.4.GIT