1 // GitLogList.cpp : implementation file
\r
4 Description: qgit revision list view
\r
6 Author: Marco Costalba (C) 2005-2007
\r
8 Copyright: See COPYING file that comes with this distribution
\r
12 #include "GitLogListBase.h"
\r
14 //#include "VssStyle.h"
\r
15 #include "IconMenu.h"
\r
18 #include "InputDlg.h"
\r
19 #include "PropDlg.h"
\r
20 #include "SVNProgressDlg.h"
\r
21 #include "ProgressDlg.h"
\r
22 //#include "RepositoryBrowser.h"
\r
23 //#include "CopyDlg.h"
\r
24 //#include "StatGraphDlg.h"
\r
26 #include "MessageBox.h"
\r
27 #include "Registry.h"
\r
28 #include "AppUtils.h"
\r
29 #include "PathUtils.h"
\r
30 #include "StringUtils.h"
\r
31 #include "UnicodeUtils.h"
\r
32 #include "TempFile.h"
\r
33 //#include "GitInfo.h"
\r
34 //#include "GitDiff.h"
\r
35 #include "IconMenu.h"
\r
36 //#include "RevisionRangeDlg.h"
\r
37 //#include "BrowseFolder.h"
\r
38 //#include "BlameDlg.h"
\r
39 //#include "Blame.h"
\r
40 //#include "GitHelpers.h"
\r
41 #include "GitStatus.h"
\r
42 //#include "LogDlgHelper.h"
\r
43 //#include "CachedLogInfo.h"
\r
44 //#include "RepositoryInfo.h"
\r
45 //#include "EditPropertiesDlg.h"
\r
46 #include "FileDiffDlg.h"
\r
47 #include "..\\TortoiseShell\\Resource.h"
\r
50 IMPLEMENT_DYNAMIC(CGitLogListBase, CHintListCtrl)
\r
52 CGitLogListBase::CGitLogListBase():CHintListCtrl()
\r
53 ,m_regMaxBugIDColWidth(_T("Software\\TortoiseGit\\MaxBugIDColWidth"), 200)
\r
55 ,m_bNoDispUpdates(FALSE)
\r
56 , m_bThreadRunning(FALSE)
\r
57 , m_bStrictStopped(false)
\r
58 , m_pStoreSelection(NULL)
\r
59 , m_nSelectedFilter(LOGFILTER_ALL)
\r
61 // use the default GUI font, create a copy of it and
\r
62 // change the copy to BOLD (leave the rest of the font
\r
64 HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
\r
66 GetObject(hFont, sizeof(LOGFONT), &lf);
\r
67 lf.lfWeight = FW_BOLD;
\r
68 m_boldFont = CreateFontIndirect(&lf);
\r
70 m_bShowBugtraqColumn=0;
\r
72 m_IsIDReplaceAction=FALSE;
\r
74 m_wcRev.m_CommitHash=GIT_REV_ZERO;
\r
75 m_wcRev.m_Subject=_T("Working Copy");
\r
77 m_hModifiedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONMODIFIED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
78 m_hReplacedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONREPLACED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
79 m_hAddedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONADDED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
80 m_hDeletedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONDELETED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
82 m_bFilterWithRegex = !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE);
\r
84 g_Git.GetMapHashToFriendName(m_HashMap);
\r
85 m_CurrentBranch=g_Git.GetCurrentBranch();
\r
87 m_From=CTime(1970,1,2,0,0,0);
\r
88 m_To=CTime::GetCurrentTime();
\r
89 m_bAllBranch = FALSE;
\r
90 m_LoadingThread = NULL;
\r
92 m_bExitThread=FALSE;
\r
94 for(int i=0;i<Lanes::COLORS_NUM;i++)
\r
96 m_LineColors[i] = m_Colors.GetColor((CColors::Colors)(CColors::BranchLine1+i));
\r
98 // get short/long datetime setting from registry
\r
99 DWORD RegUseShortDateFormat = CRegDWORD(_T("Software\\TortoiseGit\\LogDateFormat"), TRUE);
\r
100 if ( RegUseShortDateFormat )
\r
102 m_DateFormat = DATE_SHORTDATE;
\r
106 m_DateFormat = DATE_LONGDATE;
\r
110 CGitLogListBase::~CGitLogListBase()
\r
112 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
114 DestroyIcon(m_hModifiedIcon);
\r
115 DestroyIcon(m_hReplacedIcon);
\r
116 DestroyIcon(m_hAddedIcon);
\r
117 DestroyIcon(m_hDeletedIcon);
\r
118 m_logEntries.ClearAll();
\r
121 DeleteObject(m_boldFont);
\r
123 if ( m_pStoreSelection )
\r
125 delete m_pStoreSelection;
\r
126 m_pStoreSelection = NULL;
\r
129 if(this->m_bThreadRunning)
\r
131 m_bExitThread=true;
\r
132 WaitForSingleObject(m_LoadingThread->m_hThread,1000);
\r
138 BEGIN_MESSAGE_MAP(CGitLogListBase, CHintListCtrl)
\r
139 ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnNMCustomdrawLoglist)
\r
140 ON_NOTIFY_REFLECT(LVN_GETDISPINFO, OnLvnGetdispinfoLoglist)
\r
141 ON_WM_CONTEXTMENU()
\r
142 ON_NOTIFY_REFLECT(NM_DBLCLK, OnNMDblclkLoglist)
\r
143 ON_NOTIFY_REFLECT(LVN_ODFINDITEM,OnLvnOdfinditemLoglist)
\r
148 int CGitLogListBase:: OnCreate(LPCREATESTRUCT lpCreateStruct)
\r
150 PreSubclassWindow();
\r
151 return CHintListCtrl::OnCreate(lpCreateStruct);
\r
154 void CGitLogListBase::PreSubclassWindow()
\r
156 SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES);
\r
157 // load the icons for the action columns
\r
158 m_Theme.SetWindowTheme(GetSafeHwnd(), L"Explorer", NULL);
\r
159 CHintListCtrl::PreSubclassWindow();
\r
162 void CGitLogListBase::InsertGitColumn()
\r
166 int c = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;
\r
170 temp.LoadString(IDS_LOG_GRAPH);
\r
172 InsertColumn(this->LOGLIST_GRAPH, temp);
\r
175 // make the revision column right aligned
\r
177 Column.mask = LVCF_FMT;
\r
178 Column.fmt = LVCFMT_RIGHT;
\r
179 SetColumn(0, &Column);
\r
182 // g_Git.GetLog(log);
\r
184 if(m_IsIDReplaceAction)
\r
186 temp.LoadString(IDS_LOG_ID);
\r
187 InsertColumn(this->LOGLIST_ACTION, temp);
\r
191 temp.LoadString(IDS_LOG_ACTIONS);
\r
192 InsertColumn(this->LOGLIST_ACTION, temp);
\r
194 temp.LoadString(IDS_LOG_MESSAGE);
\r
195 InsertColumn(this->LOGLIST_MESSAGE, temp);
\r
197 temp.LoadString(IDS_LOG_AUTHOR);
\r
198 InsertColumn(this->LOGLIST_AUTHOR, temp);
\r
200 temp.LoadString(IDS_LOG_DATE);
\r
201 InsertColumn(this->LOGLIST_DATE, temp);
\r
204 if (m_bShowBugtraqColumn)
\r
206 // temp = m_ProjectProperties.sLabel;
\r
207 if (temp.IsEmpty())
\r
208 temp.LoadString(IDS_LOG_BUGIDS);
\r
209 InsertColumn(this->LOGLIST_BUG, temp);
\r
214 ResizeAllListCtrlCols();
\r
220 * Resizes all columns in a list control to values in registry.
\r
222 void CGitLogListBase::ResizeAllListCtrlCols()
\r
224 // column max and min widths to allow
\r
225 static const int nMinimumWidth = 10;
\r
226 static const int nMaximumWidth = 1000;
\r
227 CHeaderCtrl* pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0));
\r
230 int numcols = pHdrCtrl->GetItemCount();
\r
231 for (int col = 0; col < numcols; col++)
\r
233 // get width for this col last time from registry
\r
235 regentry.Format( _T("Software\\TortoiseGit\\log\\ColWidth%d"), col);
\r
236 CRegDWORD regwidth(regentry, 0);
\r
238 if (cx < nMinimumWidth)
\r
240 cx = nMinimumWidth;
\r
241 } else if (cx > nMaximumWidth)
\r
243 cx = nMaximumWidth;
\r
246 SetColumnWidth(col, cx);
\r
253 BOOL CGitLogListBase::GetShortName(CString ref, CString &shortname,CString prefix)
\r
255 TRACE(_T("%s %s\r\n"),ref,prefix);
\r
256 if(ref.Left(prefix.GetLength()) == prefix)
\r
258 shortname = ref.Right(ref.GetLength()-prefix.GetLength());
\r
259 if(shortname.Right(3)==_T("^{}"))
\r
260 shortname=shortname.Left(shortname.GetLength()-3);
\r
265 void CGitLogListBase::FillBackGround(HDC hdc, int Index,CRect &rect)
\r
269 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
270 rItem.mask = LVIF_STATE;
\r
271 rItem.iItem = Index;
\r
272 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
275 if (m_Theme.IsAppThemed() && m_bVista)
\r
277 m_Theme.Open(m_hWnd, L"Explorer");
\r
278 int state = LISS_NORMAL;
\r
279 if (rItem.state & LVIS_SELECTED)
\r
281 if (::GetFocus() == m_hWnd)
\r
282 state |= LISS_SELECTED;
\r
284 state |= LISS_SELECTEDNOTFOCUS;
\r
289 if (pLogEntry->bCopiedSelf)
\r
291 // unfortunately, the pLVCD->nmcd.uItemState does not contain valid
\r
292 // information at this drawing stage. But we can check the whether the
\r
293 // previous stage changed the background color of the item
\r
294 if (pLVCD->clrTextBk == GetSysColor(COLOR_MENU))
\r
297 brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
300 ::FillRect(pLVCD->nmcd.hdc, &rect, brush);
\r
301 ::DeleteObject(brush);
\r
308 if (m_Theme.IsBackgroundPartiallyTransparent(LVP_LISTDETAIL, state))
\r
309 m_Theme.DrawParentBackground(m_hWnd, hdc, &rect);
\r
311 m_Theme.DrawBackground(hdc, LVP_LISTDETAIL, state, &rect, NULL);
\r
316 if (rItem.state & LVIS_SELECTED)
\r
318 if (::GetFocus() == m_hWnd)
\r
319 brush = ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));
\r
321 brush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));
\r
325 //if (pLogEntry->bCopiedSelf)
\r
326 // brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
328 brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW));
\r
333 ::FillRect(hdc, &rect, brush);
\r
334 ::DeleteObject(brush);
\r
339 void CGitLogListBase::DrawTagBranch(HDC hdc,CRect &rect,INT_PTR index)
\r
341 GitRev* data = (GitRev*)m_arShownList.GetAt(index);
\r
344 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
345 rItem.mask = LVIF_STATE;
\r
346 rItem.iItem = index;
\r
347 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
350 for(unsigned int i=0;i<m_HashMap[data->m_CommitHash].size();i++)
\r
353 str=m_HashMap[data->m_CommitHash][i];
\r
358 if(GetShortName(str,shortname,_T("refs/heads/")))
\r
360 if( shortname == m_CurrentBranch )
\r
361 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::CurrentBranch));
\r
363 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::LocalBranch));
\r
365 }else if(GetShortName(str,shortname,_T("refs/remotes/")))
\r
367 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::RemoteBranch));
\r
369 else if(GetShortName(str,shortname,_T("refs/tags/")))
\r
371 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::Tag));
\r
374 if(!shortname.IsEmpty())
\r
377 memset(&size,0,sizeof(SIZE));
\r
378 GetTextExtentPoint32(hdc, shortname,shortname.GetLength(),&size);
\r
380 rt.SetRect(rt.left,rt.top,rt.left+size.cx,rt.bottom);
\r
382 ::FillRect(hdc, &rt, brush);
\r
383 if (rItem.state & LVIS_SELECTED)
\r
385 COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT));
\r
386 ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER);
\r
387 ::SetTextColor(hdc,clrOld);
\r
390 ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER);
\r
394 ::MoveToEx(hdc,rt.left,rt.top,NULL);
\r
395 ::LineTo(hdc,rt.right,rt.top);
\r
396 ::LineTo(hdc,rt.right,rt.bottom);
\r
397 ::LineTo(hdc,rt.left,rt.bottom);
\r
398 ::LineTo(hdc,rt.left,rt.top);
\r
400 rt.left=rt.right+3;
\r
403 ::DeleteObject(brush);
\r
405 rt.right=rect.right;
\r
407 if (rItem.state & LVIS_SELECTED)
\r
409 COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT));
\r
410 ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT);
\r
411 ::SetTextColor(hdc,clrOld);
\r
414 ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT);
\r
419 void CGitLogListBase::paintGraphLane(HDC hdc, int laneHeight,int type, int x1, int x2,
\r
420 const COLORREF& col,int top
\r
423 int h = laneHeight / 2;
\r
424 int m = (x1 + x2) / 2;
\r
425 int r = (x2 - x1) / 3;
\r
428 #define P_CENTER m , h+top
\r
429 #define P_0 x2, h+top
\r
430 #define P_90 m , 0+top
\r
431 #define P_180 x1, h+top
\r
432 #define P_270 m , 2 * h+top
\r
433 #define R_CENTER m - r, h - r+top, m - r+d, h - r+top+d
\r
435 //static QPen myPen(Qt::black, 2); // fast path here
\r
437 pen.CreatePen(PS_SOLID,2,col);
\r
438 //myPen.setColor(col);
\r
439 HPEN oldpen=(HPEN)::SelectObject(hdc,(HPEN)pen);
\r
441 //p->setPen(myPen);
\r
445 case Lanes::ACTIVE:
\r
446 case Lanes::NOT_ACTIVE:
\r
447 case Lanes::MERGE_FORK:
\r
448 case Lanes::MERGE_FORK_R:
\r
449 case Lanes::MERGE_FORK_L:
\r
451 case Lanes::JOIN_R:
\r
452 case Lanes::JOIN_L:
\r
453 DrawLine(hdc,P_90,P_270);
\r
454 //p->drawLine(P_90, P_270);
\r
457 case Lanes::HEAD_R:
\r
458 case Lanes::HEAD_L:
\r
459 case Lanes::BRANCH:
\r
460 DrawLine(hdc,P_CENTER,P_270);
\r
461 //p->drawLine(P_CENTER, P_270);
\r
464 case Lanes::TAIL_R:
\r
465 case Lanes::TAIL_L:
\r
466 case Lanes::INITIAL:
\r
467 case Lanes::BOUNDARY:
\r
468 case Lanes::BOUNDARY_C:
\r
469 case Lanes::BOUNDARY_R:
\r
470 case Lanes::BOUNDARY_L:
\r
471 DrawLine(hdc,P_90, P_CENTER);
\r
472 //p->drawLine(P_90, P_CENTER);
\r
480 case Lanes::MERGE_FORK:
\r
485 case Lanes::CROSS_EMPTY:
\r
486 case Lanes::BOUNDARY_C:
\r
487 DrawLine(hdc,P_180,P_0);
\r
488 //p->drawLine(P_180, P_0);
\r
490 case Lanes::MERGE_FORK_R:
\r
491 case Lanes::JOIN_R:
\r
492 case Lanes::HEAD_R:
\r
493 case Lanes::TAIL_R:
\r
494 case Lanes::BOUNDARY_R:
\r
495 DrawLine(hdc,P_180,P_CENTER);
\r
496 //p->drawLine(P_180, P_CENTER);
\r
498 case Lanes::MERGE_FORK_L:
\r
499 case Lanes::JOIN_L:
\r
500 case Lanes::HEAD_L:
\r
501 case Lanes::TAIL_L:
\r
502 case Lanes::BOUNDARY_L:
\r
503 DrawLine(hdc,P_CENTER,P_0);
\r
504 //p->drawLine(P_CENTER, P_0);
\r
511 brush.CreateSolidBrush(col);
\r
512 HBRUSH oldbrush=(HBRUSH)::SelectObject(hdc,(HBRUSH)brush);
\r
513 // center symbol, e.g. rect or ellipse
\r
515 case Lanes::ACTIVE:
\r
516 case Lanes::INITIAL:
\r
517 case Lanes::BRANCH:
\r
519 //p->setPen(Qt::NoPen);
\r
520 //p->setBrush(col);
\r
521 ::Ellipse(hdc, R_CENTER);
\r
522 //p->drawEllipse(R_CENTER);
\r
524 case Lanes::MERGE_FORK:
\r
525 case Lanes::MERGE_FORK_R:
\r
526 case Lanes::MERGE_FORK_L:
\r
527 //p->setPen(Qt::NoPen);
\r
528 //p->setBrush(col);
\r
529 //p->drawRect(R_CENTER);
\r
530 Rectangle(hdc,R_CENTER);
\r
532 case Lanes::UNAPPLIED:
\r
534 //p->setPen(Qt::NoPen);
\r
535 //p->setBrush(Qt::red);
\r
536 //p->drawRect(m - r, h - 1, d, 2);
\r
537 ::Rectangle(hdc,m-r,h-1,d,2);
\r
539 case Lanes::APPLIED:
\r
541 //p->setPen(Qt::NoPen);
\r
542 //p->setBrush(DARK_GREEN);
\r
543 //p->drawRect(m - r, h - 1, d, 2);
\r
544 //p->drawRect(m - 1, h - r, 2, d);
\r
545 ::Rectangle(hdc,m-r,h-1,d,2);
\r
546 ::Rectangle(hdc,m-1,h-r,2,d);
\r
548 case Lanes::BOUNDARY:
\r
549 //p->setBrush(back);
\r
550 //p->drawEllipse(R_CENTER);
\r
551 ::Ellipse(hdc, R_CENTER);
\r
553 case Lanes::BOUNDARY_C:
\r
554 case Lanes::BOUNDARY_R:
\r
555 case Lanes::BOUNDARY_L:
\r
556 //p->setBrush(back);
\r
557 //p->drawRect(R_CENTER);
\r
558 ::Rectangle(hdc,R_CENTER);
\r
564 ::SelectObject(hdc,oldpen);
\r
565 ::SelectObject(hdc,oldbrush);
\r
574 void CGitLogListBase::DrawGraph(HDC hdc,CRect &rect,INT_PTR index)
\r
578 GitRev* data = (GitRev*)m_arShownList.GetAt(index);
\r
581 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
582 rItem.mask = LVIF_STATE;
\r
583 rItem.iItem = index;
\r
584 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
588 // p->translate(QPoint(opt.rect.left(), opt.rect.top()));
\r
592 if (data->m_Lanes.size() == 0)
\r
593 m_logEntries.setLane(data->m_CommitHash);
\r
595 std::vector<int>& lanes=data->m_Lanes;
\r
596 UINT laneNum = lanes.size();
\r
597 UINT mergeLane = 0;
\r
598 for (UINT i = 0; i < laneNum; i++)
\r
599 if (Lanes::isMerge(lanes[i])) {
\r
604 int x1 = 0, x2 = 0;
\r
605 int maxWidth = rect.Width();
\r
606 int lw = 3 * rect.Height() / 4; //laneWidth()
\r
607 for (UINT i = 0; i < laneNum && x2 < maxWidth; i++) {
\r
613 if (ln == Lanes::EMPTY)
\r
616 UINT col = ( Lanes:: isHead(ln) ||Lanes:: isTail(ln) || Lanes::isJoin(ln)
\r
617 || ln ==Lanes:: CROSS_EMPTY) ? mergeLane : i;
\r
619 if (ln == Lanes::CROSS) {
\r
620 paintGraphLane(hdc, rect.Height(),Lanes::NOT_ACTIVE, x1, x2, m_LineColors[col % Lanes::COLORS_NUM],rect.top);
\r
621 paintGraphLane(hdc, rect.Height(),Lanes::CROSS, x1, x2, m_LineColors[mergeLane % Lanes::COLORS_NUM],rect.top);
\r
623 paintGraphLane(hdc, rect.Height(),ln, x1, x2, m_LineColors[col % Lanes::COLORS_NUM],rect.top);
\r
626 TRACE(_T("index %d %d\r\n"),index,data->m_Lanes.size());
\r
629 void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
632 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
\r
633 // Take the default processing unless we set this to something else below.
\r
634 *pResult = CDRF_DODEFAULT;
\r
636 if (m_bNoDispUpdates)
\r
641 switch (pLVCD->nmcd.dwDrawStage)
\r
643 case CDDS_PREPAINT:
\r
645 *pResult = CDRF_NOTIFYITEMDRAW;
\r
649 case CDDS_ITEMPREPAINT:
\r
651 // This is the prepaint stage for an item. Here's where we set the
\r
652 // item's text color.
\r
654 // Tell Windows to send draw notifications for each subitem.
\r
655 *pResult = CDRF_NOTIFYSUBITEMDRAW;
\r
657 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
\r
659 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
661 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
665 if (data->bCopiedSelf)
\r
667 // only change the background color if the item is not 'hot' (on vista with m_Themes enabled)
\r
668 if (!m_Theme.IsAppm_Themed() || !m_bVista || ((pLVCD->nmcd.uItemState & CDIS_HOT)==0))
\r
669 pLVCD->clrTextBk = GetSysColor(COLOR_MENU);
\r
673 crText = m_Colors.GetColor(CColors::Modified);
\r
675 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
\r
676 // crText = GetSysColor(COLOR_GRAYTEXT);
\r
677 // if (data->Rev == m_wcRev)
\r
679 // SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
680 // We changed the font, so we're returning CDRF_NEWFONT. This
\r
681 // tells the control to recalculate the extent of the text.
\r
682 // *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
686 if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
688 if (m_bStrictStopped)
\r
689 crText = GetSysColor(COLOR_GRAYTEXT);
\r
691 // Store the color back in the NMLVCUSTOMDRAW struct.
\r
692 pLVCD->clrText = crText;
\r
696 case CDDS_ITEMPREPAINT|CDDS_ITEM|CDDS_SUBITEM:
\r
698 if ((m_bStrictStopped)&&(m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec))
\r
700 pLVCD->nmcd.uItemState &= ~(CDIS_SELECTED|CDIS_FOCUS);
\r
703 if (pLVCD->iSubItem == LOGLIST_GRAPH)
\r
705 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
708 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
710 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
711 DrawGraph(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
\r
713 *pResult = CDRF_SKIPDEFAULT;
\r
719 if (pLVCD->iSubItem == LOGLIST_MESSAGE)
\r
721 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
723 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
724 //if(!data->m_IsFull)
\r
726 //if(data->SafeFetchFullInfo(&g_Git))
\r
727 // this->Invalidate();
\r
728 //TRACE(_T("Update ... %d\r\n"),pLVCD->nmcd.dwItemSpec);
\r
731 if(m_HashMap[data->m_CommitHash].size()!=0)
\r
735 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
737 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
738 DrawTagBranch(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
\r
740 *pResult = CDRF_SKIPDEFAULT;
\r
747 if (pLVCD->iSubItem == 1)
\r
749 if(this->m_IsIDReplaceAction)
\r
751 *pResult = CDRF_DODEFAULT;
\r
754 *pResult = CDRF_DODEFAULT;
\r
756 if (m_arShownList.GetCount() <= (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
760 int iconwidth = ::GetSystemMetrics(SM_CXSMICON);
\r
761 int iconheight = ::GetSystemMetrics(SM_CYSMICON);
\r
763 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec));
\r
765 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
766 // Get the selected state of the
\r
767 // item being drawn.
\r
769 // Fill the background
\r
770 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
772 // Draw the icon(s) into the compatible DC
\r
773 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_MODIFIED)
\r
774 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left + ICONITEMBORDER, rect.top, m_hModifiedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
777 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_ADDED)
\r
778 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hAddedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
781 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_DELETED)
\r
782 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hDeletedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
785 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_REPLACED)
\r
786 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hReplacedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
788 *pResult = CDRF_SKIPDEFAULT;
\r
794 *pResult = CDRF_DODEFAULT;
\r
798 // CGitLogListBase message handlers
\r
800 void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
802 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
\r
804 // Create a pointer to the item
\r
805 LV_ITEM* pItem = &(pDispInfo)->item;
\r
807 // Do the list need text information?
\r
808 if (!(pItem->mask & LVIF_TEXT))
\r
811 // By default, clear text buffer.
\r
812 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
814 bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();
\r
817 if (m_bNoDispUpdates || bOutOfRange)
\r
820 // Which item number?
\r
821 int itemid = pItem->iItem;
\r
822 GitRev * pLogEntry = NULL;
\r
823 if (itemid < m_arShownList.GetCount())
\r
824 pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(pItem->iItem));
\r
827 temp.Format(_T("%d"),m_arShownList.GetCount()-pItem->iItem);
\r
830 switch (pItem->iSubItem)
\r
832 case this->LOGLIST_GRAPH: //Graphic
\r
837 case this->LOGLIST_ACTION: //action -- no text in the column
\r
838 if(this->m_IsIDReplaceAction)
\r
839 lstrcpyn(pItem->pszText, temp, pItem->cchTextMax);
\r
841 case this->LOGLIST_MESSAGE: //Message
\r
843 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_Subject, pItem->cchTextMax);
\r
845 case this->LOGLIST_AUTHOR: //Author
\r
847 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorName, pItem->cchTextMax);
\r
849 case this->LOGLIST_DATE: //Date
\r
851 lstrcpyn(pItem->pszText,
\r
852 CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat ),
\r
853 pItem->cchTextMax);
\r
864 void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point)
\r
867 int selIndex = GetSelectionMark();
\r
869 return; // nothing selected, nothing to do with a context menu
\r
871 // if the user selected the info text telling about not all revisions shown due to
\r
872 // the "stop on copy/rename" option, we also don't show the context menu
\r
873 if ((m_bStrictStopped)&&(selIndex == m_arShownList.GetCount()))
\r
876 // if the context menu is invoked through the keyboard, we have to use
\r
877 // a calculated position on where to anchor the menu on
\r
878 if ((point.x == -1) && (point.y == -1))
\r
881 GetItemRect(selIndex, &rect, LVIR_LABEL);
\r
882 ClientToScreen(&rect);
\r
883 point = rect.CenterPoint();
\r
885 m_nSearchIndex = selIndex;
\r
886 m_bCancelled = FALSE;
\r
888 // calculate some information the context menu commands can use
\r
889 // CString pathURL = GetURLFromPath(m_path);
\r
891 POSITION pos = GetFirstSelectedItemPosition();
\r
892 int indexNext = GetNextSelectedItem(pos);
\r
896 GitRev* pSelLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(indexNext));
\r
898 GitRev revSelected = pSelLogEntry->Rev;
\r
899 GitRev revPrevious = git_revnum_t(revSelected)-1;
\r
900 if ((pSelLogEntry->pArChangedPaths)&&(pSelLogEntry->pArChangedPaths->GetCount() <= 2))
\r
902 for (int i=0; i<pSelLogEntry->pArChangedPaths->GetCount(); ++i)
\r
904 LogChangedPath * changedpath = (LogChangedPath *)pSelLogEntry->pArChangedPaths->GetAt(i);
\r
905 if (changedpath->lCopyFromRev)
\r
906 revPrevious = changedpath->lCopyFromRev;
\r
909 GitRev revSelected2;
\r
912 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
913 revSelected2 = pLogEntry->Rev;
\r
915 bool bAllFromTheSameAuthor = true;
\r
916 CString firstAuthor;
\r
917 CLogDataVector selEntries;
\r
918 GitRev revLowest, revHighest;
\r
919 GitRevRangeArray revisionRanges;
\r
921 POSITION pos = GetFirstSelectedItemPosition();
\r
922 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
923 revisionRanges.AddRevision(pLogEntry->Rev);
\r
924 selEntries.push_back(pLogEntry);
\r
925 firstAuthor = pLogEntry->sAuthor;
\r
926 revLowest = pLogEntry->Rev;
\r
927 revHighest = pLogEntry->Rev;
\r
930 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
931 revisionRanges.AddRevision(pLogEntry->Rev);
\r
932 selEntries.push_back(pLogEntry);
\r
933 if (firstAuthor.Compare(pLogEntry->sAuthor))
\r
934 bAllFromTheSameAuthor = false;
\r
935 revLowest = (git_revnum_t(pLogEntry->Rev) > git_revnum_t(revLowest) ? revLowest : pLogEntry->Rev);
\r
936 revHighest = (git_revnum_t(pLogEntry->Rev) < git_revnum_t(revHighest) ? revHighest : pLogEntry->Rev);
\r
942 int FirstSelect=-1, LastSelect=-1;
\r
943 pos = GetFirstSelectedItemPosition();
\r
944 FirstSelect = GetNextSelectedItem(pos);
\r
947 LastSelect = GetNextSelectedItem(pos);
\r
949 //entry is selected, now show the popup menu
\r
951 if (popup.CreatePopupMenu())
\r
953 if (GetSelectedCount() == 1)
\r
956 if (!m_path.IsDirectory())
\r
960 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
961 popup.AppendMenuIcon(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
963 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
964 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
965 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
966 popup.AppendMenuIcon(ID_SAVEAS, IDS_LOG_POPUP_SAVE, IDI_SAVEAS);
\r
967 popup.AppendMenuIcon(ID_OPEN, IDS_LOG_POPUP_OPEN, IDI_OPEN);
\r
968 popup.AppendMenuIcon(ID_OPENWITH, IDS_LOG_POPUP_OPENWITH, IDI_OPEN);
\r
969 popup.AppendMenuIcon(ID_BLAME, IDS_LOG_POPUP_BLAME, IDI_BLAME);
\r
970 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
977 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
979 // TortoiseMerge could be improved to take a /blame switch
\r
980 // and then not 'cat' the files from a unified diff but
\r
982 // But until that's implemented, the context menu entry for
\r
983 // this feature is commented out.
\r
984 //popup.AppendMenu(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
986 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
987 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
988 //popup.AppendMenuIcon(ID_BLAMEWITHPREVIOUS, IDS_LOG_POPUP_BLAMEWITHPREVIOUS, IDI_BLAME);
\r
989 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
992 // if (!m_ProjectProperties.sWebViewerRev.IsEmpty())
\r
994 // popup.AppendMenuIcon(ID_VIEWREV, IDS_LOG_POPUP_VIEWREV);
\r
996 // if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
\r
998 // popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
\r
1000 // if ((!m_ProjectProperties.sWebViewerPathRev.IsEmpty())||
\r
1001 // (!m_ProjectProperties.sWebViewerRev.IsEmpty()))
\r
1003 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1007 // popup.AppendMenuIcon(ID_REVERTTOREV, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT);
\r
1009 // popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT);
\r
1011 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREV, IDI_MERGE);
\r
1014 str.Format(_T("Reset %s to this"),g_Git.GetCurrentBranch());
\r
1015 popup.AppendMenuIcon(ID_RESET,str,IDI_REVERT);
\r
1016 popup.AppendMenuIcon(ID_SWITCHTOREV, _T("Switch/Checkout to this") , IDI_SWITCH);
\r
1017 popup.AppendMenuIcon(ID_CREATE_BRANCH, _T("Create Branch at this version") , IDI_COPY);
\r
1018 popup.AppendMenuIcon(ID_CREATE_TAG, _T("Create Tag at this version"), IDI_COPY);
\r
1019 popup.AppendMenuIcon(ID_CHERRY_PICK, _T("Cherry Pick this version"), IDI_EXPORT);
\r
1020 popup.AppendMenuIcon(ID_EXPORT, _T("Export this version"), IDI_EXPORT);
\r
1023 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1025 else if (GetSelectedCount() >= 2)
\r
1027 bool bAddSeparator = false;
\r
1028 if (IsSelectionContinuous() || (GetSelectedCount() == 2))
\r
1030 popup.AppendMenuIcon(ID_COMPARETWO, IDS_LOG_POPUP_COMPARETWO, IDI_DIFF);
\r
1032 if (GetSelectedCount() == 2)
\r
1034 //popup.AppendMenuIcon(ID_BLAMETWO, IDS_LOG_POPUP_BLAMEREVS, IDI_BLAME);
\r
1035 popup.AppendMenuIcon(ID_GNUDIFF2, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);
\r
1036 bAddSeparator = true;
\r
1040 //popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREVS, IDI_REVERT);
\r
1042 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREVS, IDI_MERGE);
\r
1043 bAddSeparator = true;
\r
1045 if (bAddSeparator)
\r
1046 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1049 // if ((selEntries.size() > 0)&&(bAllFromTheSameAuthor))
\r
1051 // popup.AppendMenuIcon(ID_EDITAUTHOR, IDS_LOG_POPUP_EDITAUTHOR);
\r
1053 // if (GetSelectedCount() == 1)
\r
1055 // popup.AppendMenuIcon(ID_EDITLOG, IDS_LOG_POPUP_EDITLOG);
\r
1056 // popup.AppendMenuIcon(ID_REVPROPS, IDS_REPOBROWSE_SHOWREVPROP, IDI_PROPERTIES); // "Show Revision Properties"
\r
1057 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1062 if (GetSelectedCount() == 1)
\r
1064 popup.AppendMenuIcon(ID_COPYHASH, _T("Copy Commit Hash"));
\r
1066 if (GetSelectedCount() != 0)
\r
1068 popup.AppendMenuIcon(ID_COPYCLIPBOARD, IDS_LOG_POPUP_COPYTOCLIPBOARD);
\r
1070 popup.AppendMenuIcon(ID_FINDENTRY, IDS_LOG_POPUP_FIND);
\r
1072 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
1073 // DialogEnableWindow(IDOK, FALSE);
\r
1074 // SetPromptApp(&theApp);
\r
1076 this->ContextMenuAction(cmd, FirstSelect, LastSelect);
\r
1078 // EnableOKButton();
\r
1079 } // if (popup.CreatePopupMenu())
\r
1083 bool CGitLogListBase::IsSelectionContinuous()
\r
1085 if ( GetSelectedCount()==1 )
\r
1087 // if only one revision is selected, the selection is of course
\r
1092 POSITION pos = GetFirstSelectedItemPosition();
\r
1093 bool bContinuous = (m_arShownList.GetCount() == (INT_PTR)m_logEntries.size());
\r
1096 int itemindex = GetNextSelectedItem(pos);
\r
1099 int nextindex = GetNextSelectedItem(pos);
\r
1100 if (nextindex - itemindex > 1)
\r
1102 bContinuous = false;
\r
1105 itemindex = nextindex;
\r
1108 return bContinuous;
\r
1111 void CGitLogListBase::CopySelectionToClipBoard(bool HashOnly)
\r
1114 CString sClipdata;
\r
1115 POSITION pos = GetFirstSelectedItemPosition();
\r
1119 sRev.LoadString(IDS_LOG_REVISION);
\r
1121 sAuthor.LoadString(IDS_LOG_AUTHOR);
\r
1123 sDate.LoadString(IDS_LOG_DATE);
\r
1125 sMessage.LoadString(IDS_LOG_MESSAGE);
\r
1128 CString sLogCopyText;
\r
1130 GitRev * pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1134 //pLogEntry->m_Files
\r
1135 //LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1137 for (int cpPathIndex = 0; cpPathIndex<pLogEntry->m_Files.GetCount(); ++cpPathIndex)
\r
1139 sPaths += ((CTGitPath&)pLogEntry->m_Files[cpPathIndex]).GetActionName() + _T(" : ") + pLogEntry->m_Files[cpPathIndex].GetGitPathString();
\r
1140 sPaths += _T("\r\n");
\r
1143 sLogCopyText.Format(_T("%s: %s\r\n%s: %s\r\n%s: %s\r\n%s:\r\n%s\r\n----\r\n%s\r\n\r\n"),
\r
1144 (LPCTSTR)sRev, pLogEntry->m_CommitHash,
\r
1145 (LPCTSTR)sAuthor, (LPCTSTR)pLogEntry->m_AuthorName,
\r
1146 (LPCTSTR)sDate, (LPCTSTR)CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat ),
\r
1147 (LPCTSTR)sMessage, pLogEntry->m_Subject+_T("\r\n")+pLogEntry->m_Body,
\r
1149 sClipdata += sLogCopyText;
\r
1152 sClipdata += pLogEntry->m_CommitHash;
\r
1157 CStringUtils::WriteAsciiStringToClipboard(sClipdata, GetSafeHwnd());
\r
1162 void CGitLogListBase::DiffSelectedRevWithPrevious()
\r
1165 if (m_bThreadRunning)
\r
1167 UpdateLogInfoLabel();
\r
1168 int selIndex = m_LogList.GetSelectionMark();
\r
1171 int selCount = m_LogList.GetSelectedCount();
\r
1172 if (selCount != 1)
\r
1175 // Find selected entry in the log list
\r
1176 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1177 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1178 long rev1 = pLogEntry->Rev;
\r
1179 long rev2 = rev1-1;
\r
1180 CTGitPath path = m_path;
\r
1182 // See how many files under the relative root were changed in selected revision
\r
1184 LogChangedPath * changed = NULL;
\r
1185 for (INT_PTR c = 0; c < pLogEntry->pArChangedPaths->GetCount(); ++c)
\r
1187 LogChangedPath * cpath = pLogEntry->pArChangedPaths->GetAt(c);
\r
1188 if (cpath && cpath -> sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
1195 if (m_path.IsDirectory() && nChanged == 1)
\r
1197 // We're looking at the log for a directory and only one file under dir was changed in the revision
\r
1198 // Do diff on that file instead of whole directory
\r
1199 path.AppendPathString(changed->sPath.Mid(m_sRelativeRoot.GetLength()));
\r
1202 m_bCancelled = FALSE;
\r
1203 DialogEnableWindow(IDOK, FALSE);
\r
1204 SetPromptApp(&theApp);
\r
1205 theApp.DoWaitCursor(1);
\r
1207 if (PromptShown())
\r
1209 GitDiff diff(this, m_hWnd, true);
\r
1210 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1211 diff.SetHEADPeg(m_LogRevision);
\r
1212 diff.ShowCompare(path, rev2, path, rev1);
\r
1216 CAppUtils::StartShowCompare(m_hWnd, path, rev2, path, rev1, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1219 theApp.DoWaitCursor(-1);
\r
1224 void CGitLogListBase::OnLvnOdfinditemLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
1226 LPNMLVFINDITEM pFindInfo = reinterpret_cast<LPNMLVFINDITEM>(pNMHDR);
\r
1229 if (pFindInfo->lvfi.flags & LVFI_PARAM)
\r
1231 if ((pFindInfo->iStart < 0)||(pFindInfo->iStart >= m_arShownList.GetCount()))
\r
1233 if (pFindInfo->lvfi.psz == 0)
\r
1236 CString sCmp = pFindInfo->lvfi.psz;
\r
1238 for (int i=pFindInfo->iStart; i<m_arShownList.GetCount(); ++i)
\r
1240 GitRev * pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(i));
\r
1241 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1242 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1244 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1252 if (sCmp.Compare(sRev)==0)
\r
1259 if (pFindInfo->lvfi.flags & LVFI_WRAP)
\r
1261 for (int i=0; i<pFindInfo->iStart; ++i)
\r
1263 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1264 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1265 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1267 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1275 if (sCmp.Compare(sRev)==0)
\r
1287 int CGitLogListBase::FillGitLog(CTGitPath *path,int info)
\r
1291 this->m_logEntries.ClearAll();
\r
1292 this->m_logEntries.ParserFromLog(path,-1,info);
\r
1294 //this->m_logEntries.ParserFromLog();
\r
1295 SetItemCountEx(this->m_logEntries.size());
\r
1297 this->m_arShownList.RemoveAll();
\r
1299 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1301 m_logEntries[i].m_IsFull=TRUE;
\r
1302 this->m_arShownList.Add(&m_logEntries[i]);
\r
1311 int CGitLogListBase::FillGitShortLog()
\r
1315 this->m_logEntries.ClearAll();
\r
1317 m_LogCache.FetchCacheIndex(g_Git.m_CurrentDir);
\r
1320 if(this->m_Path.IsEmpty())
\r
1323 path=&this->m_Path;
\r
1327 mask = CGit::LOG_INFO_ONLY_HASH | CGit::LOG_INFO_BOUNDARY;
\r
1328 if(this->m_bAllBranch)
\r
1329 mask |= CGit::LOG_INFO_ALL_BRANCH;
\r
1331 this->m_logEntries.ParserShortLog(path,hash,-1,mask);
\r
1334 //this->m_logEntries.ParserFromLog();
\r
1335 SetItemCountEx(this->m_logEntries.size());
\r
1337 this->m_arShownList.RemoveAll();
\r
1339 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1340 this->m_arShownList.Add(&m_logEntries[i]);
\r
1345 BOOL CGitLogListBase::PreTranslateMessage(MSG* pMsg)
\r
1347 // Skip Ctrl-C when copying text out of the log message or search filter
\r
1348 BOOL bSkipAccelerator = ( pMsg->message == WM_KEYDOWN && pMsg->wParam=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT) ) && GetKeyState(VK_CONTROL)&0x8000 );
\r
1349 if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')
\r
1351 //if (GetFocus()==GetDlgItem(IDC_LOGLIST))
\r
1353 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1355 DiffSelectedRevWithPrevious();
\r
1360 if (GetFocus()==GetDlgItem(IDC_LOGMSG))
\r
1362 DiffSelectedFile();
\r
1369 if (m_hAccel && !bSkipAccelerator)
\r
1371 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
\r
1377 //m_tooltips.RelayEvent(pMsg);
\r
1378 return __super::PreTranslateMessage(pMsg);
\r
1381 void CGitLogListBase::OnNMDblclkLoglist(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
1383 // a double click on an entry in the revision list has happened
\r
1386 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1387 DiffSelectedRevWithPrevious();
\r
1390 int CGitLogListBase::FetchLogAsync(CALLBACK_PROCESS *proc,void * data)
\r
1392 m_ProcCallBack=proc;
\r
1394 m_bExitThread=FALSE;
\r
1395 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1396 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1397 m_LoadingThread = AfxBeginThread(LogThreadEntry, this);
\r
1398 if (m_LoadingThread ==NULL)
\r
1400 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1401 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1402 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
1408 //this is the thread function which calls the subversion function
\r
1409 UINT CGitLogListBase::LogThreadEntry(LPVOID pVoid)
\r
1411 return ((CGitLogListBase*)pVoid)->LogThread();
\r
1414 void CGitLogListBase::GetTimeRange(CTime &oldest, CTime &latest)
\r
1417 oldest=CTime::GetCurrentTime();
\r
1418 latest=CTime(1971,1,2,0,0,0);
\r
1419 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1421 if(m_logEntries[i].m_AuthorDate.GetTime() < oldest.GetTime())
\r
1422 oldest = m_logEntries[i].m_AuthorDate.GetTime();
\r
1424 if(m_logEntries[i].m_AuthorDate.GetTime() > latest.GetTime())
\r
1425 latest = m_logEntries[i].m_AuthorDate.GetTime();
\r
1430 UINT CGitLogListBase::LogThread()
\r
1433 if(m_ProcCallBack)
\r
1434 m_ProcCallBack(m_ProcData,GITLOG_START);
\r
1436 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1437 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1439 //does the user force the cache to refresh (shift or control key down)?
\r
1440 bool refresh = (GetKeyState (VK_CONTROL) < 0)
\r
1441 || (GetKeyState (VK_SHIFT) < 0);
\r
1443 //disable the "Get All" button while we're receiving
\r
1447 temp.LoadString(IDS_PROGRESSWAIT);
\r
1448 ShowText(temp, true);
\r
1450 FillGitShortLog();
\r
1452 if(this->m_bExitThread)
\r
1455 RedrawItems(0, m_arShownList.GetCount());
\r
1456 // SetRedraw(false);
\r
1457 // ResizeAllListCtrlCols();
\r
1458 // SetRedraw(true);
\r
1460 if ( m_pStoreSelection )
\r
1462 // Deleting the instance will restore the
\r
1463 // selection of the CLogDlg.
\r
1464 delete m_pStoreSelection;
\r
1465 m_pStoreSelection = NULL;
\r
1469 // If no selection has been set then this must be the first time
\r
1470 // the revisions are shown. Let's preselect the topmost revision.
\r
1471 if ( GetItemCount()>0 )
\r
1473 SetSelectionMark(0);
\r
1474 SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
\r
1477 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1480 unsigned int updated=0;
\r
1485 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1487 if(m_LogCache.GetCacheData(m_logEntries[i]))
\r
1489 if(!m_logEntries.FetchFullInfo(i))
\r
1492 this->GetItemRect(i,&rect,LVIR_BOUNDS);
\r
1493 this->InvalidateRect(rect);
\r
1495 m_LogCache.AddCacheEntry(m_logEntries[i]);
\r
1500 InterlockedExchange(&m_logEntries[i].m_IsUpdateing,FALSE);
\r
1501 InterlockedExchange(&m_logEntries[i].m_IsFull,TRUE);
\r
1503 this->GetItemRect(i,&rect,LVIR_BOUNDS);
\r
1504 this->InvalidateRect(rect);
\r
1510 percent=updated*98/m_logEntries.size() + GITLOG_START+1;
\r
1511 if(percent == GITLOG_END)
\r
1512 percent = GITLOG_END -1;
\r
1514 if(m_ProcCallBack)
\r
1515 m_ProcCallBack(m_ProcData,percent);
\r
1519 if(updated==m_logEntries.size())
\r
1523 //RefreshCursor();
\r
1524 // make sure the filter is applied (if any) now, after we refreshed/fetched
\r
1525 // the log messages
\r
1529 if(m_ProcCallBack)
\r
1530 m_ProcCallBack(m_ProcData,GITLOG_END);
\r
1532 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1537 void CGitLogListBase::Refresh()
\r
1539 if(!m_bThreadRunning)
\r
1541 this->SetItemCountEx(0);
\r
1542 m_logEntries.clear();
\r
1543 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1544 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1545 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
1547 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1548 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1549 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
1551 m_sFilterText.Empty();
\r
1552 m_From=CTime(1970,1,2,0,0,0);
\r
1553 m_To=CTime::GetCurrentTime();
\r
1556 bool CGitLogListBase::ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase /* = false */)
\r
1560 tr1::regex_constants::syntax_option_type type = tr1::regex_constants::ECMAScript;
\r
1562 type |= tr1::regex_constants::icase;
\r
1563 pat = tr1::wregex(regexp_str, type);
\r
1566 catch (exception) {}
\r
1570 void CGitLogListBase::RecalculateShownList(CPtrArray * pShownlist)
\r
1573 pShownlist->RemoveAll();
\r
1574 tr1::wregex pat;//(_T("Remove"), tr1::regex_constants::icase);
\r
1575 bool bRegex = false;
\r
1576 if (m_bFilterWithRegex)
\r
1577 bRegex = ValidateRegexp(m_sFilterText, pat, false);
\r
1579 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_any;
\r
1581 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
1583 if ((bRegex)&&(m_bFilterWithRegex))
\r
1586 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
1588 ATLTRACE(_T("bugID = \"%s\"\n"), (LPCTSTR)m_logEntries[i]->sBugIDs);
\r
1589 if (regex_search(wstring((LPCTSTR)m_logEntries[i]->sBugIDs), pat, flags)&&IsEntryInDateRange(i))
\r
1591 pShownlist->Add(m_logEntries[i]);
\r
1596 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
1598 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries[i].m_Subject);
\r
1599 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_Subject), pat, flags)&&IsEntryInDateRange(i))
\r
1601 pShownlist->Add(&m_logEntries[i]);
\r
1605 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries[i].m_Body);
\r
1606 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_Body), pat, flags)&&IsEntryInDateRange(i))
\r
1608 pShownlist->Add(&m_logEntries[i]);
\r
1613 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
1615 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
1617 bool bGoing = true;
\r
1618 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
1620 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1621 if (regex_search(wstring((LPCTSTR)cpath->sCopyFromPath), pat, flags)&&IsEntryInDateRange(i))
\r
1623 pShownlist->Add(m_logEntries[i]);
\r
1627 if (regex_search(wstring((LPCTSTR)cpath->sPath), pat, flags)&&IsEntryInDateRange(i))
\r
1629 pShownlist->Add(m_logEntries[i]);
\r
1633 if (regex_search(wstring((LPCTSTR)cpath->GetAction()), pat, flags)&&IsEntryInDateRange(i))
\r
1635 pShownlist->Add(m_logEntries[i]);
\r
1644 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
1646 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_AuthorName), pat, flags)&&IsEntryInDateRange(i))
\r
1648 pShownlist->Add(&m_logEntries[i]);
\r
1652 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
1654 sRev.Format(_T("%ld"), m_logEntries[i].m_CommitHash);
\r
1655 if (regex_search(wstring((LPCTSTR)sRev), pat, flags)&&IsEntryInDateRange(i))
\r
1657 pShownlist->Add(&m_logEntries[i]);
\r
1664 CString find = m_sFilterText;
\r
1667 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
1669 CString sBugIDs = m_logEntries[i]->sBugIDs;
\r
1671 sBugIDs = sBugIDs.MakeLower();
\r
1672 if ((sBugIDs.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
1674 pShownlist->Add(m_logEntries[i]);
\r
1679 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
1681 CString msg = m_logEntries[i].m_Subject;
\r
1683 msg = msg.MakeLower();
\r
1684 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
1686 pShownlist->Add(&m_logEntries[i]);
\r
1689 msg = m_logEntries[i].m_Body;
\r
1691 msg = msg.MakeLower();
\r
1692 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
1694 pShownlist->Add(&m_logEntries[i]);
\r
1699 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
1701 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
1703 bool bGoing = true;
\r
1704 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
1706 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1707 CString path = cpath->sCopyFromPath;
\r
1709 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
1711 pShownlist->Add(m_logEntries[i]);
\r
1715 path = cpath->sPath;
\r
1717 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
1719 pShownlist->Add(m_logEntries[i]);
\r
1723 path = cpath->GetAction();
\r
1725 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
1727 pShownlist->Add(m_logEntries[i]);
\r
1734 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
1736 CString msg = m_logEntries[i].m_AuthorName;
\r
1737 msg = msg.MakeLower();
\r
1738 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
1740 pShownlist->Add(&m_logEntries[i]);
\r
1744 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
1746 sRev.Format(_T("%ld"), m_logEntries[i].m_CommitHash);
\r
1747 if ((sRev.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
1749 pShownlist->Add(&m_logEntries[i]);
\r
1753 } // else (from if (bRegex))
\r
1754 } // for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
1758 BOOL CGitLogListBase::IsEntryInDateRange(int i)
\r
1760 __time64_t time = m_logEntries[i].m_AuthorDate.GetTime();
\r
1761 if ((time >= m_From.GetTime())&&(time <= m_To.GetTime()))
\r
1768 void CGitLogListBase::StartFilter()
\r
1770 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1771 RecalculateShownList(&m_arShownList);
\r
1772 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1776 SetItemCountEx(ShownCountWithStopped());
\r
1777 RedrawItems(0, ShownCountWithStopped());
\r
1779 //ResizeAllListCtrlCols();
\r
1784 void CGitLogListBase::RemoveFilter()
\r
1787 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1789 m_arShownList.RemoveAll();
\r
1791 // reset the time filter too
\r
1793 m_timFrom = (__time64_t(m_tFrom));
\r
1794 m_timTo = (__time64_t(m_tTo));
\r
1795 m_DateFrom.SetTime(&m_timFrom);
\r
1796 m_DateTo.SetTime(&m_timTo);
\r
1797 m_DateFrom.SetRange(&m_timFrom, &m_timTo);
\r
1798 m_DateTo.SetRange(&m_timFrom, &m_timTo);
\r
1801 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
1803 m_arShownList.Add(&m_logEntries[i]);
\r
1805 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1807 SetItemCountEx(ShownCountWithStopped());
\r
1808 RedrawItems(0, ShownCountWithStopped());
\r
1809 // SetRedraw(false);
\r
1810 // ResizeAllListCtrlCols();
\r
1811 // SetRedraw(true);
\r
1813 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1816 void CGitLogListBase::Clear()
\r
1818 m_arShownList.RemoveAll();
\r
1819 m_logEntries.clear();
\r
1820 m_logEntries.m_HashMap.clear();
\r
1822 m_logEntries.m_Lns.clear();
\r
1824 m_logEntries.m_FirstFreeLane=0;
\r
1825 m_logEntries.m_Lns.clear();
\r
1829 void CGitLogListBase::OnDestroy()
\r
1831 // save the column widths to the registry
\r
1832 SaveColumnWidths();
\r
1833 while(m_LogCache.SaveCache())
\r
1835 if(CMessageBox::Show(NULL,_T("Cannot Save Log Cache to Disk,click yes for retry, click no for give up"),_T("TortoiseGit"),
\r
1836 MB_YESNO) == IDNO)
\r
1839 CHintListCtrl::OnDestroy();
\r
1843 * Save column widths to the registry
\r
1845 void CGitLogListBase::SaveColumnWidths()
\r
1847 CHeaderCtrl* pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0));
\r
1850 int numcols = pHdrCtrl->GetItemCount();
\r
1851 for (int col = 0; col < numcols; col++)
\r
1853 int width = GetColumnWidth( col );
\r
1855 regentry.Format( _T("Software\\TortoiseGit\\log\\ColWidth%d"), col);
\r
1856 CRegDWORD regwidth(regentry, 0);
\r
1857 regwidth = width; // this writes it to reg
\r