X-Git-Url: http://git.sourceforge.jp/view?p=tortoisegit%2FTortoiseGitJp.git;a=blobdiff_plain;f=src%2FTortoiseProc%2FGitLogListBase.cpp;h=59c63868ccb279b2ec394e75aa10614f583acdc9;hp=9dae894d643935d008319597ccf68eaee489efd4;hb=a538c21dc94c861b40cad6d76db392887077f9f9;hpb=006ab8b10ea52676d2ba201efdb609fb19b47078 diff --git a/src/TortoiseProc/GitLogListBase.cpp b/src/TortoiseProc/GitLogListBase.cpp index 9dae894..59c6386 100644 --- a/src/TortoiseProc/GitLogListBase.cpp +++ b/src/TortoiseProc/GitLogListBase.cpp @@ -58,6 +58,8 @@ CGitLogListBase::CGitLogListBase():CHintListCtrl() , m_pStoreSelection(NULL) , 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 @@ -72,8 +74,13 @@ CGitLogListBase::CGitLogListBase():CHintListCtrl() m_IsIDReplaceAction=FALSE; - m_wcRev.m_CommitHash=GIT_REV_ZERO; - m_wcRev.m_Subject=_T("Working Copy"); + 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('-'); + m_wcRev.m_IsUpdateing=FALSE; + m_wcRev.m_IsFull = TRUE; m_hModifiedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONMODIFIED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE); m_hReplacedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONREPLACED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE); @@ -196,7 +203,9 @@ void CGitLogListBase::PreSubclassWindow() { SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES); // load the icons for the action columns - m_Theme.SetWindowTheme(GetSafeHwnd(), L"Explorer", NULL); +// m_Theme.Open(m_hWnd, L"ListView"); + m_Theme.Open(m_hWnd, L"Explorer::ListView;ListView"); + m_Theme.SetWindowTheme(m_hWnd, L"Explorer", NULL); CHintListCtrl::PreSubclassWindow(); } @@ -204,7 +213,7 @@ void CGitLogListBase::InsertGitColumn() { CString temp; - int c = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1; + int c = GetHeaderCtrl()->GetItemCount()-1; while (c>=0) DeleteColumn(c--); @@ -313,7 +322,7 @@ void CGitLogListBase::ResizeAllListCtrlCols() BOOL CGitLogListBase::GetShortName(CString ref, CString &shortname,CString prefix) { - TRACE(_T("%s %s\r\n"),ref,prefix); + //TRACE(_T("%s %s\r\n"),ref,prefix); if(ref.Left(prefix.GetLength()) == prefix) { shortname = ref.Right(ref.GetLength()-prefix.GetLength()); @@ -323,6 +332,7 @@ BOOL CGitLogListBase::GetShortName(CString ref, CString &shortname,CString prefi } return FALSE; } + void CGitLogListBase::FillBackGround(HDC hdc, int Index,CRect &rect) { // HBRUSH brush; @@ -334,12 +344,11 @@ void CGitLogListBase::FillBackGround(HDC hdc, int Index,CRect &rect) GetItem(&rItem); GitRev* pLogEntry = (GitRev*)m_arShownList.GetAt(Index); - HBRUSH brush; + HBRUSH brush = NULL; if (m_Theme.IsAppThemed() && m_bVista) { - m_Theme.Open(m_hWnd, L"Explorer"); int state = LISS_NORMAL; if (rItem.state & LVIS_SELECTED) { @@ -354,19 +363,26 @@ void CGitLogListBase::FillBackGround(HDC hdc, int Index,CRect &rect) brush = ::CreateSolidBrush(RGB(156,156,156)); else if(pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT) brush = ::CreateSolidBrush(RGB(200,200,128)); + } - if (brush == NULL) - return; - + if (brush != NULL) + { ::FillRect(hdc, &rect, brush); ::DeleteObject(brush); - } - - if (m_Theme.IsBackgroundPartiallyTransparent(LVP_LISTDETAIL, state)) - m_Theme.DrawParentBackground(m_hWnd, hdc, &rect); else - m_Theme.DrawBackground(hdc, LVP_LISTDETAIL, state, &rect, NULL); + { + if (m_Theme.IsBackgroundPartiallyTransparent(LVP_LISTITEM, state)) + m_Theme.DrawParentBackground(m_hWnd, hdc, &rect); + + CRect rectDraw = rect; + if(rItem.state & LVIS_SELECTED) + rectDraw.InflateRect(1,0); + else + rectDraw.InflateRect(1,1); + + m_Theme.DrawBackground(hdc, LVP_LISTITEM, state, rectDraw, &rect); + } } else { @@ -387,7 +403,7 @@ void CGitLogListBase::FillBackGround(HDC hdc, int Index,CRect &rect) brush = ::CreateSolidBrush(RGB(156,156,156)); else if(pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT) brush = ::CreateSolidBrush(RGB(200,200,128)); - else + else brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW)); } if (brush == NULL) @@ -416,28 +432,38 @@ void CGitLogListBase::DrawTagBranch(HDC hdc,CRect &rect,INT_PTR index) str=m_HashMap[data->m_CommitHash][i]; CString shortname; - HBRUSH brush=0; - shortname=_T(""); + HBRUSH brush = 0; + shortname = _T(""); + COLORREF colRef = 0; + + //Determine label color if(GetShortName(str,shortname,_T("refs/heads/"))) { if( shortname == m_CurrentBranch ) - brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::CurrentBranch)); + colRef = m_Colors.GetColor(CColors::CurrentBranch); else - brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::LocalBranch)); + colRef = m_Colors.GetColor(CColors::LocalBranch); }else if(GetShortName(str,shortname,_T("refs/remotes/"))) { - brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::RemoteBranch)); + colRef = m_Colors.GetColor(CColors::RemoteBranch); } else if(GetShortName(str,shortname,_T("refs/tags/"))) { - brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::Tag)); + colRef = m_Colors.GetColor(CColors::Tag); } else if(GetShortName(str,shortname,_T("refs/stash"))) { - brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::Stash)); + colRef = m_Colors.GetColor(CColors::Stash); shortname=_T("stash"); } + + //When row selected, ajust label color + if (!(m_Theme.IsAppThemed() && m_bVista)) + if (rItem.state & LVIS_SELECTED) + colRef = CColors::MixColors(colRef, ::GetSysColor(COLOR_HIGHLIGHT), 150); + + brush = ::CreateSolidBrush(colRef); if(!shortname.IsEmpty()) @@ -447,42 +473,81 @@ void CGitLogListBase::DrawTagBranch(HDC hdc,CRect &rect,INT_PTR index) GetTextExtentPoint32(hdc, shortname,shortname.GetLength(),&size); rt.SetRect(rt.left,rt.top,rt.left+size.cx,rt.bottom); - rt.right+=4; + rt.right+=8; + + //Fill interior of ref label ::FillRect(hdc, &rt, brush); - if (rItem.state & LVIS_SELECTED) + + //Draw edge of label + CDC W_Dc; + W_Dc.Attach(hdc); + + CRect rectEdge = rt; + + W_Dc.Draw3dRect(rectEdge, m_Colors.Lighten(colRef,100), m_Colors.Darken(colRef,100)); + rectEdge.DeflateRect(1,1); + W_Dc.Draw3dRect(rectEdge, m_Colors.Lighten(colRef,50), m_Colors.Darken(colRef,50)); + + W_Dc.Detach(); + + //Draw text inside label + if (m_Theme.IsAppThemed() && m_bVista) { - COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT)); - ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER); - ::SetTextColor(hdc,clrOld); - }else + int txtState = LISS_NORMAL; + if (rItem.state & LVIS_SELECTED) + txtState = LISS_SELECTED; + + m_Theme.DrawText(hdc, LVP_LISTITEM, txtState, shortname, -1, DT_CENTER | DT_SINGLELINE | DT_VCENTER, 0, &rt); + } + else { - ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER); + if (rItem.state & LVIS_SELECTED) + { + COLORREF clrNew = ::GetSysColor(COLOR_HIGHLIGHTTEXT); + COLORREF clrOld = ::SetTextColor(hdc,clrNew); + ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER | DT_SINGLELINE | DT_VCENTER); + ::SetTextColor(hdc,clrOld); + }else + { + ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER | DT_SINGLELINE | DT_VCENTER); + } } - ::MoveToEx(hdc,rt.left,rt.top,NULL); - ::LineTo(hdc,rt.right,rt.top); - ::LineTo(hdc,rt.right,rt.bottom); - ::LineTo(hdc,rt.left,rt.bottom); - ::LineTo(hdc,rt.left,rt.top); + //::MoveToEx(hdc,rt.left,rt.top,NULL); + //::LineTo(hdc,rt.right,rt.top); + //::LineTo(hdc,rt.right,rt.bottom); + //::LineTo(hdc,rt.left,rt.bottom); + //::LineTo(hdc,rt.left,rt.top); + - rt.left=rt.right+3; + rt.left=rt.right+1; } if(brush) ::DeleteObject(brush); } rt.right=rect.right; - if (rItem.state & LVIS_SELECTED) + if (m_Theme.IsAppThemed() && m_bVista) { - COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT)); - ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT); - ::SetTextColor(hdc,clrOld); - }else + int txtState = LISS_NORMAL; + if (rItem.state & LVIS_SELECTED) + txtState = LISS_SELECTED; + + m_Theme.DrawText(hdc, LVP_LISTITEM, txtState, data->m_Subject, -1, DT_LEFT | DT_SINGLELINE | DT_VCENTER, 0, &rt); + } + else { - ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT); + if (rItem.state & LVIS_SELECTED) + { + COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT)); + ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT | DT_SINGLELINE | DT_VCENTER); + ::SetTextColor(hdc,clrOld); + }else + { + ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT | DT_SINGLELINE | DT_VCENTER); + } } - } static COLORREF blend(const COLORREF& col1, const COLORREF& col2, int amount = 128) { @@ -791,7 +856,7 @@ void CGitLogListBase::DrawGraph(HDC hdc,CRect &rect,INT_PTR index) continue; COLORREF color = i == activeLane ? activeColor : m_LineColors[i % Lanes::COLORS_NUM]; - paintGraphLane(hdc, rect.Height(),ln, x1, x2, color,activeColor, rect.top); + paintGraphLane(hdc, rect.Height(),ln, x1+rect.left, x2+rect.left, color,activeColor, rect.top); } #if 0 @@ -815,7 +880,6 @@ void CGitLogListBase::DrawGraph(HDC hdc,CRect &rect,INT_PTR index) } #endif - TRACE(_T("index %d %d\r\n"),index,data->m_Lanes.size()); } void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult) @@ -871,7 +935,7 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult) pLVCD->clrTextBk = RGB(156,156,156); else if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT) pLVCD->clrTextBk = RGB(200,200,128); - else + else pLVCD->clrTextBk = ::GetSysColor(COLOR_WINDOW); if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_CURRENT) @@ -880,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; @@ -888,13 +952,15 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult) // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end())) // crText = GetSysColor(COLOR_GRAYTEXT); -// if (data->Rev == m_wcRev) -// { -// SelectObject(pLVCD->nmcd.hdc, m_boldFont); +// + if (data->m_CommitHash.IsEmpty()) + { + //crText = GetSysColor(RGB(200,200,0)); + //SelectObject(pLVCD->nmcd.hdc, m_boldFont); // We changed the font, so we're returning CDRF_NEWFONT. This // tells the control to recalculate the extent of the text. -// *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT; -// } + *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT; + } } } if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec) @@ -920,9 +986,19 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult) { CRect rect; GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect); + if(pLVCD->iSubItem == 0) + { + CRect second; + GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem+1, LVIR_BOUNDS, second); + rect.right=second.left; + } + //TRACE(_T("A Graphic left %d right %d\r\n"),rect.left,rect.right); FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect); - DrawGraph(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec); + + GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec); + if( !data ->m_CommitHash.IsEmpty()) + DrawGraph(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec); *pResult = CDRF_SKIPDEFAULT; return; @@ -955,7 +1031,8 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult) return; } - } + + } } if (pLVCD->iSubItem == 1) @@ -977,6 +1054,7 @@ void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult) GitRev* pLogEntry = reinterpret_cast(m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec)); CRect rect; GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect); + //TRACE(_T("Action left %d right %d\r\n"),rect.left,rect.right); // Get the selected state of the // item being drawn. @@ -1075,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) + if ( pLogEntry && (!pLogEntry->m_CommitHash.IsEmpty()) ) lstrcpyn(pItem->pszText, CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat, true, m_bRelativeTimes ), pItem->cchTextMax); @@ -1181,7 +1259,7 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) { if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_PICK)) - popup.AppendMenuIcon(ID_REBASE_PICK, IDS_REBASE_SKIP, IDI_PICK); + popup.AppendMenuIcon(ID_REBASE_PICK, IDS_REBASE_PICK, IDI_PICK); if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_SQUASH)) popup.AppendMenuIcon(ID_REBASE_SQUASH,IDS_REBASE_SQUASH, IDI_SQUASH); @@ -1198,8 +1276,9 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) if (GetSelectedCount() == 1) { + { - if (m_hasWC) + if( !pSelLogEntry->m_CommitHash.IsEmpty()) { if(m_ContextMenuMask&GetContextMenuBit(ID_COMPARE)) popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF); @@ -1210,6 +1289,10 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) // But until that's implemented, the context menu entry for // this feature is commented out. //popup.AppendMenu(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME); + }else + { + if(m_ContextMenuMask&GetContextMenuBit(ID_COMMIT)) + popup.AppendMenuIcon(ID_COMMIT, IDS_LOG_POPUP_COMMIT, IDI_COMMIT); } if(m_ContextMenuMask&GetContextMenuBit(ID_GNUDIFF1)) popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF); @@ -1245,30 +1328,33 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) format.LoadString(IDS_RESET_TO_THIS_FORMAT); str.Format(format,g_Git.GetCurrentBranch()); - if(m_ContextMenuMask&GetContextMenuBit(ID_RESET)) - popup.AppendMenuIcon(ID_RESET,str,IDI_REVERT); + if(!pSelLogEntry->m_CommitHash.IsEmpty()) + { + if(m_ContextMenuMask&GetContextMenuBit(ID_RESET)) + popup.AppendMenuIcon(ID_RESET,str,IDI_REVERT); - if(m_ContextMenuMask&GetContextMenuBit(ID_SWITCHTOREV)) - popup.AppendMenuIcon(ID_SWITCHTOREV, IDS_SWITCH_TO_THIS , IDI_SWITCH); + if(m_ContextMenuMask&GetContextMenuBit(ID_SWITCHTOREV)) + popup.AppendMenuIcon(ID_SWITCHTOREV, IDS_SWITCH_TO_THIS , IDI_SWITCH); - if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_BRANCH)) - popup.AppendMenuIcon(ID_CREATE_BRANCH, IDS_CREATE_BRANCH_AT_THIS , IDI_COPY); + if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_BRANCH)) + popup.AppendMenuIcon(ID_CREATE_BRANCH, IDS_CREATE_BRANCH_AT_THIS , IDI_COPY); - if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_TAG)) - popup.AppendMenuIcon(ID_CREATE_TAG,IDS_CREATE_TAG_AT_THIS , IDI_COPY); + if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_TAG)) + popup.AppendMenuIcon(ID_CREATE_TAG,IDS_CREATE_TAG_AT_THIS , IDI_COPY); - format.LoadString(IDS_REBASE_THIS_FORMAT); - str.Format(format,g_Git.GetCurrentBranch()); + format.LoadString(IDS_REBASE_THIS_FORMAT); + str.Format(format,g_Git.GetCurrentBranch()); - if(pSelLogEntry->m_CommitHash != m_HeadHash) - if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_TO_VERSION)) - popup.AppendMenuIcon(ID_REBASE_TO_VERSION, str , IDI_REBASE); + if(pSelLogEntry->m_CommitHash != m_HeadHash) + if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_TO_VERSION)) + popup.AppendMenuIcon(ID_REBASE_TO_VERSION, str , IDI_REBASE); - if(m_ContextMenuMask&GetContextMenuBit(ID_EXPORT)) - popup.AppendMenuIcon(ID_EXPORT,IDS_EXPORT_TO_THIS, IDI_EXPORT); + if(m_ContextMenuMask&GetContextMenuBit(ID_EXPORT)) + popup.AppendMenuIcon(ID_EXPORT,IDS_EXPORT_TO_THIS, IDI_EXPORT); - popup.AppendMenu(MF_SEPARATOR, NULL); + popup.AppendMenu(MF_SEPARATOR, NULL); + } } @@ -1307,7 +1393,7 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) popup.AppendMenu(MF_SEPARATOR, NULL); } - if ( GetSelectedCount() >0 ) + if ( GetSelectedCount() >0 && (!pSelLogEntry->m_CommitHash.IsEmpty())) { if ( IsSelectionContinuous() && GetSelectedCount() >= 2 ) { @@ -1322,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); } } @@ -1330,7 +1416,7 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point) if(m_ContextMenuMask&GetContextMenuBit(ID_CHERRY_PICK)) popup.AppendMenuIcon(ID_CHERRY_PICK, IDS_CHERRY_PICK_VERSION, IDI_EXPORT); - if(GetSelectedCount()<=2) + if(GetSelectedCount()<=2 || (IsSelectionContinuous() && GetSelectedCount() > 0)) if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_PATCH)) popup.AppendMenuIcon(ID_CREATE_PATCH, IDS_CREATE_PATCH, IDI_PATCH); @@ -1642,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]); } } @@ -1658,11 +1744,14 @@ int CGitLogListBase::FillGitLog(CTGitPath *path,int info,CString *from,CString * } -int CGitLogListBase::FillGitShortLog() +int CGitLogListBase::BeginFetchLog() { ClearText(); this->m_logEntries.ClearAll(); + git_init(); + + this->m_LogCache.ClearAllParent(); m_LogCache.FetchCacheIndex(g_Git.m_CurrentDir); @@ -1676,30 +1765,33 @@ int CGitLogListBase::FillGitShortLog() int mask; mask = CGit::LOG_INFO_ONLY_HASH | CGit::LOG_INFO_BOUNDARY; // if(this->m_bAllBranch) - mask |= m_ShowMask; - - this->m_logEntries.FetchShortLog(path,m_StartRef,-1,mask); + mask |= m_ShowMask ; + this->m_arShownList.RemoveAll(); + + if(m_bShowWC) + { + this->m_logEntries.insert(m_logEntries.begin(),this->m_wcRev.m_CommitHash); + this->m_LogCache.m_HashMap[m_wcRev.m_CommitHash]=m_wcRev; + } + + CString cmd=g_Git.GetLogCmd(m_StartRef,path,-1,mask,NULL,NULL,true); + //this->m_logEntries.ParserFromLog(); if(IsInWorkingThread()) + { PostMessage(LVM_SETITEMCOUNT, (WPARAM) this->m_logEntries.size(),(LPARAM) LVSICF_NOINVALIDATEALL); + } else + { SetItemCountEx(this->m_logEntries.size()); - - this->m_arShownList.RemoveAll(); - - for(unsigned int i=0;im_IsOldFirst) - { - this->m_arShownList.Add(&m_logEntries[m_logEntries.size()-1-i]); - - }else - { - this->m_arShownList.Add(&m_logEntries[i]); - } + return -1; } + return 0; } @@ -1778,11 +1870,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() < oldest.GetTime()) + oldest = m_logEntries.GetGitRevAt(i).m_AuthorDate.GetTime(); + + if(m_logEntries.GetGitRevAt(i).m_AuthorDate.GetTime() > latest.GetTime()) + latest = m_logEntries.GetGitRevAt(i).m_AuthorDate.GetTime(); } } @@ -1836,17 +1931,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; } @@ -1898,6 +1994,7 @@ void CGitLogListBase::FetchFullLogInfo(CString &from, CString &to) { CGitCall_FetchFullLogInfo fetcher(this); int mask= + CGit::LOG_INFO_FULL_DIFF| CGit::LOG_INFO_STAT| CGit::LOG_INFO_FILESTATE| CGit::LOG_INFO_DETECT_COPYRENAME| @@ -1921,22 +2018,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); @@ -1953,7 +2051,102 @@ 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; + + TRACE(_T("\n===Begin===\n")); + //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); + int total = git_get_log_estimate_commit_count(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); + + }else + { + ASSERT(pRev->m_CommitHash == hash); + pRev->ParserParentFromCommit(&commit); + } +#ifdef DEBUG + pRev->DbgPrint(); + TRACE(_T("\n")); +#endif + git_free_commit(&commit); + + this->m_critSec.Lock(); + m_logEntries.push_back(hash); + m_arShownList.Add(pRev); + this->m_critSec.Unlock(); + + if(t2-t1>500 || (m_logEntries.size()-oldsize >100)) + { + //update UI + int percent=m_logEntries.size()*100/total + GITLOG_START+1; + if(percent > 99) + percent =99; + if(percent < GITLOG_START) + percent = GITLOG_START +1; + + 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) percent,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); @@ -1983,21 +2176,38 @@ UINT CGitLogListBase::LogThread() int update=0; for(int i=0;im_logEntries[i].ParserFromLog(m_logEntries.m_RawlogData,start); - m_logEntries.m_HashMap[m_logEntries[i].m_CommitHash]=i; + if( i==0 && m_logEntries.GetGitRevAt(i).m_CommitHash.IsEmpty() ) + { + 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.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.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()) @@ -2006,7 +2216,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) { @@ -2056,7 +2265,7 @@ UINT CGitLogListBase::LogThread() ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_END,0); InterlockedExchange(&m_bThreadRunning, FALSE); - +#endif return 0; } @@ -2069,7 +2278,8 @@ void CGitLogListBase::Refresh() if(ret == WAIT_TIMEOUT) TerminateThread(); } - + + this->SetItemCountEx(0); this->Clear(); //Update branch and Tag info @@ -2077,7 +2287,7 @@ void CGitLogListBase::Refresh() //Assume Thread have exited //if(!m_bThreadRunning) { - this->SetItemCountEx(0); + m_logEntries.clear(); m_bExitThread=FALSE; InterlockedExchange(&m_bThreadRunning, TRUE); @@ -2135,17 +2345,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]); + pShownlist->Add(&m_logEntries.GetGitRevAt(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; } } @@ -2183,18 +2393,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.ToString()); if (regex_search(wstring((LPCTSTR)sRev), pat, flags)&&IsEntryInDateRange(i)) { - pShownlist->Add(&m_logEntries[i]); + pShownlist->Add(&m_logEntries.GetGitRevAt(i)); continue; } } @@ -2218,20 +2428,20 @@ 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))) { - pShownlist->Add(&m_logEntries[i]); + pShownlist->Add(&m_logEntries.GetGitRevAt(i)); continue; } } @@ -2273,20 +2483,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.ToString()); if ((sRev.Find(find) >= 0)&&(IsEntryInDateRange(i))) { - pShownlist->Add(&m_logEntries[i]); + pShownlist->Add(&m_logEntries.GetGitRevAt(i)); continue; } } @@ -2297,7 +2507,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; @@ -2395,6 +2605,11 @@ LRESULT CGitLogListBase::OnLoad(WPARAM wParam,LPARAM lParam) int i=(int)wParam; this->GetItemRect(i,&rect,LVIR_BOUNDS); this->InvalidateRect(rect); + + if(this->GetItemState(i,LVIF_STATE) & LVIS_SELECTED) + { + int i=0; + } return 0; } @@ -2428,7 +2643,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; } }