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
51 IMPLEMENT_DYNAMIC(CGitLogListBase, CHintListCtrl)
\r
53 CGitLogListBase::CGitLogListBase():CHintListCtrl()
\r
54 ,m_regMaxBugIDColWidth(_T("Software\\TortoiseGit\\MaxBugIDColWidth"), 200)
\r
56 ,m_bNoDispUpdates(FALSE)
\r
57 , m_bThreadRunning(FALSE)
\r
58 , m_bStrictStopped(false)
\r
59 , m_pStoreSelection(NULL)
\r
60 , m_nSelectedFilter(LOGFILTER_ALL)
\r
62 // use the default GUI font, create a copy of it and
\r
63 // change the copy to BOLD (leave the rest of the font
\r
65 HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
\r
67 GetObject(hFont, sizeof(LOGFONT), &lf);
\r
68 lf.lfWeight = FW_BOLD;
\r
69 m_boldFont = CreateFontIndirect(&lf);
\r
71 m_bShowBugtraqColumn=0;
\r
73 m_IsIDReplaceAction=FALSE;
\r
75 m_wcRev.m_CommitHash=GIT_REV_ZERO;
\r
76 m_wcRev.m_Subject=_T("Working Copy");
\r
78 m_hModifiedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONMODIFIED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
79 m_hReplacedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONREPLACED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
80 m_hAddedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONADDED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
81 m_hDeletedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONDELETED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
83 m_bFilterWithRegex = !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE);
\r
85 g_Git.GetMapHashToFriendName(m_HashMap);
\r
87 m_From=CTime(1970,1,2,0,0,0);
\r
88 m_To=CTime::GetCurrentTime();
\r
91 CGitLogListBase::~CGitLogListBase()
\r
93 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
95 DestroyIcon(m_hModifiedIcon);
\r
96 DestroyIcon(m_hReplacedIcon);
\r
97 DestroyIcon(m_hAddedIcon);
\r
98 DestroyIcon(m_hDeletedIcon);
\r
99 m_logEntries.ClearAll();
\r
102 DeleteObject(m_boldFont);
\r
104 if ( m_pStoreSelection )
\r
106 delete m_pStoreSelection;
\r
107 m_pStoreSelection = NULL;
\r
112 BEGIN_MESSAGE_MAP(CGitLogListBase, CHintListCtrl)
\r
113 ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnNMCustomdrawLoglist)
\r
114 ON_NOTIFY_REFLECT(LVN_GETDISPINFO, OnLvnGetdispinfoLoglist)
\r
115 ON_WM_CONTEXTMENU()
\r
116 ON_NOTIFY_REFLECT(NM_DBLCLK, OnNMDblclkLoglist)
\r
117 ON_NOTIFY_REFLECT(LVN_ODFINDITEM,OnLvnOdfinditemLoglist)
\r
121 int CGitLogListBase:: OnCreate(LPCREATESTRUCT lpCreateStruct)
\r
123 PreSubclassWindow();
\r
124 return CHintListCtrl::OnCreate(lpCreateStruct);
\r
127 void CGitLogListBase::PreSubclassWindow()
\r
129 SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES);
\r
130 // load the icons for the action columns
\r
131 m_Theme.SetWindowTheme(GetSafeHwnd(), L"Explorer", NULL);
\r
132 CHintListCtrl::PreSubclassWindow();
\r
135 void CGitLogListBase::InsertGitColumn()
\r
139 int c = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;
\r
143 temp.LoadString(IDS_LOG_GRAPH);
\r
145 InsertColumn(this->LOGLIST_GRAPH, temp);
\r
148 // make the revision column right aligned
\r
150 Column.mask = LVCF_FMT;
\r
151 Column.fmt = LVCFMT_RIGHT;
\r
152 SetColumn(0, &Column);
\r
155 // g_Git.GetLog(log);
\r
157 if(m_IsIDReplaceAction)
\r
159 temp.LoadString(IDS_LOG_ID);
\r
160 InsertColumn(this->LOGLIST_ACTION, temp);
\r
164 temp.LoadString(IDS_LOG_ACTIONS);
\r
165 InsertColumn(this->LOGLIST_ACTION, temp);
\r
167 temp.LoadString(IDS_LOG_MESSAGE);
\r
168 InsertColumn(this->LOGLIST_MESSAGE, temp);
\r
170 temp.LoadString(IDS_LOG_AUTHOR);
\r
171 InsertColumn(this->LOGLIST_AUTHOR, temp);
\r
173 temp.LoadString(IDS_LOG_DATE);
\r
174 InsertColumn(this->LOGLIST_DATE, temp);
\r
177 if (m_bShowBugtraqColumn)
\r
179 // temp = m_ProjectProperties.sLabel;
\r
180 if (temp.IsEmpty())
\r
181 temp.LoadString(IDS_LOG_BUGIDS);
\r
182 InsertColumn(this->LOGLIST_BUG, temp);
\r
187 ResizeAllListCtrlCols();
\r
192 void CGitLogListBase::ResizeAllListCtrlCols()
\r
195 const int nMinimumWidth = ICONITEMBORDER+16*4;
\r
196 int maxcol = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;
\r
197 int nItemCount = GetItemCount();
\r
198 TCHAR textbuf[MAX_PATH];
\r
199 CHeaderCtrl * pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0));
\r
202 for (int col = 0; col <= maxcol; col++)
\r
205 hdi.mask = HDI_TEXT;
\r
206 hdi.pszText = textbuf;
\r
207 hdi.cchTextMax = sizeof(textbuf);
\r
208 pHdrCtrl->GetItem(col, &hdi);
\r
209 int cx = GetStringWidth(hdi.pszText)+20; // 20 pixels for col separator and margin
\r
210 for (int index = 0; index<nItemCount; ++index)
\r
212 // get the width of the string and add 14 pixels for the column separator and margins
\r
213 int linewidth = GetStringWidth(GetItemText(index, col)) + 14;
\r
214 if (index < m_arShownList.GetCount())
\r
216 GitRev * pCurLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(index));
\r
217 if ((pCurLogEntry)&&(pCurLogEntry->m_CommitHash == m_wcRev.m_CommitHash))
\r
219 // set the bold font and ask for the string width again
\r
220 SendMessage(WM_SETFONT, (WPARAM)m_boldFont, NULL);
\r
221 linewidth = GetStringWidth(GetItemText(index, col)) + 14;
\r
222 // restore the system font
\r
223 SendMessage(WM_SETFONT, NULL, NULL);
\r
228 // add the image size
\r
229 CImageList * pImgList = GetImageList(LVSIL_SMALL);
\r
230 if ((pImgList)&&(pImgList->GetImageCount()))
\r
233 pImgList->GetImageInfo(0, &imginfo);
\r
234 linewidth += (imginfo.rcImage.right - imginfo.rcImage.left);
\r
235 linewidth += 3; // 3 pixels between icon and text
\r
238 if (cx < linewidth)
\r
241 // Adjust columns "Actions" containing icons
\r
242 if (col == this->LOGLIST_ACTION)
\r
244 if (cx < nMinimumWidth)
\r
246 cx = nMinimumWidth;
\r
250 if (col == this->LOGLIST_MESSAGE)
\r
252 if (cx > LOGLIST_MESSAGE_MAX)
\r
254 cx = LOGLIST_MESSAGE_MAX;
\r
256 if (cx < LOGLIST_MESSAGE_MIN)
\r
258 cx = LOGLIST_MESSAGE_MIN;
\r
262 // keep the bug id column small
\r
263 if ((col == 4)&&(m_bShowBugtraqColumn))
\r
265 if (cx > (int)(DWORD)m_regMaxBugIDColWidth)
\r
267 cx = (int)(DWORD)m_regMaxBugIDColWidth;
\r
271 SetColumnWidth(col, cx);
\r
278 BOOL CGitLogListBase::GetShortName(CString ref, CString &shortname,CString prefix)
\r
280 TRACE(_T("%s %s\r\n"),ref,prefix);
\r
281 if(ref.Left(prefix.GetLength()) == prefix)
\r
283 shortname = ref.Right(ref.GetLength()-prefix.GetLength());
\r
284 if(shortname.Right(3)==_T("^{}"))
\r
285 shortname=shortname.Left(shortname.GetLength()-3);
\r
290 void CGitLogListBase::FillBackGround(HDC hdc, int Index,CRect &rect)
\r
294 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
295 rItem.mask = LVIF_STATE;
\r
296 rItem.iItem = Index;
\r
297 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
300 if (m_Theme.IsAppThemed() && m_bVista)
\r
302 m_Theme.Open(m_hWnd, L"Explorer");
\r
303 int state = LISS_NORMAL;
\r
304 if (rItem.state & LVIS_SELECTED)
\r
306 if (::GetFocus() == m_hWnd)
\r
307 state |= LISS_SELECTED;
\r
309 state |= LISS_SELECTEDNOTFOCUS;
\r
314 if (pLogEntry->bCopiedSelf)
\r
316 // unfortunately, the pLVCD->nmcd.uItemState does not contain valid
\r
317 // information at this drawing stage. But we can check the whether the
\r
318 // previous stage changed the background color of the item
\r
319 if (pLVCD->clrTextBk == GetSysColor(COLOR_MENU))
\r
322 brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
325 ::FillRect(pLVCD->nmcd.hdc, &rect, brush);
\r
326 ::DeleteObject(brush);
\r
333 if (m_Theme.IsBackgroundPartiallyTransparent(LVP_LISTDETAIL, state))
\r
334 m_Theme.DrawParentBackground(m_hWnd, hdc, &rect);
\r
336 m_Theme.DrawBackground(hdc, LVP_LISTDETAIL, state, &rect, NULL);
\r
341 if (rItem.state & LVIS_SELECTED)
\r
343 if (::GetFocus() == m_hWnd)
\r
344 brush = ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));
\r
346 brush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));
\r
350 //if (pLogEntry->bCopiedSelf)
\r
351 // brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
353 brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW));
\r
358 ::FillRect(hdc, &rect, brush);
\r
359 ::DeleteObject(brush);
\r
364 void CGitLogListBase::DrawTagBranch(HDC hdc,CRect &rect,INT_PTR index)
\r
366 GitRev* data = (GitRev*)m_arShownList.GetAt(index);
\r
369 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
370 rItem.mask = LVIF_STATE;
\r
371 rItem.iItem = index;
\r
372 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
375 for(int i=0;i<m_HashMap[data->m_CommitHash].size();i++)
\r
378 str=m_HashMap[data->m_CommitHash][i];
\r
383 if(GetShortName(str,shortname,_T("refs/heads/")))
\r
385 brush = ::CreateSolidBrush(RGB(0xff, 0, 0));
\r
386 }else if(GetShortName(str,shortname,_T("refs/remotes/")))
\r
388 brush = ::CreateSolidBrush(RGB(0xff, 0xff, 0));
\r
390 else if(GetShortName(str,shortname,_T("refs/tags/")))
\r
392 brush = ::CreateSolidBrush(RGB(0, 0, 0xff));
\r
395 if(!shortname.IsEmpty())
\r
398 memset(&size,0,sizeof(SIZE));
\r
399 GetTextExtentPoint32(hdc, shortname,shortname.GetLength(),&size);
\r
401 rt.SetRect(rt.left,rt.top,rt.left+size.cx,rt.bottom);
\r
403 ::FillRect(hdc, &rt, brush);
\r
404 if (rItem.state & LVIS_SELECTED)
\r
406 COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT));
\r
407 ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER);
\r
408 ::SetTextColor(hdc,clrOld);
\r
411 ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER);
\r
415 ::MoveToEx(hdc,rt.left,rt.top,NULL);
\r
416 ::LineTo(hdc,rt.right,rt.top);
\r
417 ::LineTo(hdc,rt.right,rt.bottom);
\r
418 ::LineTo(hdc,rt.left,rt.bottom);
\r
419 ::LineTo(hdc,rt.left,rt.top);
\r
421 rt.left=rt.right+3;
\r
424 ::DeleteObject(brush);
\r
426 rt.right=rect.right;
\r
428 if (rItem.state & LVIS_SELECTED)
\r
430 COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT));
\r
431 ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT);
\r
432 ::SetTextColor(hdc,clrOld);
\r
435 ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT);
\r
440 void CGitLogListBase::paintGraphLane(HDC hdc, int laneHeight,int type, int x1, int x2,
\r
441 const COLORREF& col,int top
\r
444 int h = laneHeight / 2;
\r
445 int m = (x1 + x2) / 2;
\r
446 int r = (x2 - x1) / 3;
\r
449 #define P_CENTER m , h+top
\r
450 #define P_0 x2, h+top
\r
451 #define P_90 m , 0+top
\r
452 #define P_180 x1, h+top
\r
453 #define P_270 m , 2 * h+top
\r
454 #define R_CENTER m - r, h - r+top, m - r+d, h - r+top+d
\r
456 //static QPen myPen(Qt::black, 2); // fast path here
\r
458 pen.CreatePen(PS_SOLID,2,col);
\r
459 //myPen.setColor(col);
\r
460 HPEN oldpen=(HPEN)::SelectObject(hdc,(HPEN)pen);
\r
462 //p->setPen(myPen);
\r
466 case Lanes::ACTIVE:
\r
467 case Lanes::NOT_ACTIVE:
\r
468 case Lanes::MERGE_FORK:
\r
469 case Lanes::MERGE_FORK_R:
\r
470 case Lanes::MERGE_FORK_L:
\r
472 case Lanes::JOIN_R:
\r
473 case Lanes::JOIN_L:
\r
474 DrawLine(hdc,P_90,P_270);
\r
475 //p->drawLine(P_90, P_270);
\r
478 case Lanes::HEAD_R:
\r
479 case Lanes::HEAD_L:
\r
480 case Lanes::BRANCH:
\r
481 DrawLine(hdc,P_CENTER,P_270);
\r
482 //p->drawLine(P_CENTER, P_270);
\r
485 case Lanes::TAIL_R:
\r
486 case Lanes::TAIL_L:
\r
487 case Lanes::INITIAL:
\r
488 case Lanes::BOUNDARY:
\r
489 case Lanes::BOUNDARY_C:
\r
490 case Lanes::BOUNDARY_R:
\r
491 case Lanes::BOUNDARY_L:
\r
492 DrawLine(hdc,P_90, P_CENTER);
\r
493 //p->drawLine(P_90, P_CENTER);
\r
501 case Lanes::MERGE_FORK:
\r
506 case Lanes::CROSS_EMPTY:
\r
507 case Lanes::BOUNDARY_C:
\r
508 DrawLine(hdc,P_180,P_0);
\r
509 //p->drawLine(P_180, P_0);
\r
511 case Lanes::MERGE_FORK_R:
\r
512 case Lanes::JOIN_R:
\r
513 case Lanes::HEAD_R:
\r
514 case Lanes::TAIL_R:
\r
515 case Lanes::BOUNDARY_R:
\r
516 DrawLine(hdc,P_180,P_CENTER);
\r
517 //p->drawLine(P_180, P_CENTER);
\r
519 case Lanes::MERGE_FORK_L:
\r
520 case Lanes::JOIN_L:
\r
521 case Lanes::HEAD_L:
\r
522 case Lanes::TAIL_L:
\r
523 case Lanes::BOUNDARY_L:
\r
524 DrawLine(hdc,P_CENTER,P_0);
\r
525 //p->drawLine(P_CENTER, P_0);
\r
532 brush.CreateSolidBrush(col);
\r
533 HBRUSH oldbrush=(HBRUSH)::SelectObject(hdc,(HBRUSH)brush);
\r
534 // center symbol, e.g. rect or ellipse
\r
536 case Lanes::ACTIVE:
\r
537 case Lanes::INITIAL:
\r
538 case Lanes::BRANCH:
\r
540 //p->setPen(Qt::NoPen);
\r
541 //p->setBrush(col);
\r
542 ::Ellipse(hdc, R_CENTER);
\r
543 //p->drawEllipse(R_CENTER);
\r
545 case Lanes::MERGE_FORK:
\r
546 case Lanes::MERGE_FORK_R:
\r
547 case Lanes::MERGE_FORK_L:
\r
548 //p->setPen(Qt::NoPen);
\r
549 //p->setBrush(col);
\r
550 //p->drawRect(R_CENTER);
\r
551 Rectangle(hdc,R_CENTER);
\r
553 case Lanes::UNAPPLIED:
\r
555 //p->setPen(Qt::NoPen);
\r
556 //p->setBrush(Qt::red);
\r
557 //p->drawRect(m - r, h - 1, d, 2);
\r
558 ::Rectangle(hdc,m-r,h-1,d,2);
\r
560 case Lanes::APPLIED:
\r
562 //p->setPen(Qt::NoPen);
\r
563 //p->setBrush(DARK_GREEN);
\r
564 //p->drawRect(m - r, h - 1, d, 2);
\r
565 //p->drawRect(m - 1, h - r, 2, d);
\r
566 ::Rectangle(hdc,m-r,h-1,d,2);
\r
567 ::Rectangle(hdc,m-1,h-r,2,d);
\r
569 case Lanes::BOUNDARY:
\r
570 //p->setBrush(back);
\r
571 //p->drawEllipse(R_CENTER);
\r
572 ::Ellipse(hdc, R_CENTER);
\r
574 case Lanes::BOUNDARY_C:
\r
575 case Lanes::BOUNDARY_R:
\r
576 case Lanes::BOUNDARY_L:
\r
577 //p->setBrush(back);
\r
578 //p->drawRect(R_CENTER);
\r
579 ::Rectangle(hdc,R_CENTER);
\r
585 ::SelectObject(hdc,oldpen);
\r
586 ::SelectObject(hdc,oldbrush);
\r
595 void CGitLogListBase::DrawGraph(HDC hdc,CRect &rect,INT_PTR index)
\r
599 GitRev* data = (GitRev*)m_arShownList.GetAt(index);
\r
602 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
603 rItem.mask = LVIF_STATE;
\r
604 rItem.iItem = index;
\r
605 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
608 static const COLORREF colors[Lanes::COLORS_NUM] = { RGB(0,0,0), RGB(0xFF,0,0), RGB(0,0xFF,0),
\r
609 RGB(0,0,0xFF), RGB(128,128,128), RGB(128,128,0),
\r
610 RGB(0,128,128), RGB(128,0,128) };
\r
613 // p->translate(QPoint(opt.rect.left(), opt.rect.top()));
\r
617 if (data->m_Lanes.size() == 0)
\r
618 m_logEntries.setLane(data->m_CommitHash);
\r
620 std::vector<int>& lanes=data->m_Lanes;
\r
621 UINT laneNum = lanes.size();
\r
622 UINT mergeLane = 0;
\r
623 for (UINT i = 0; i < laneNum; i++)
\r
624 if (Lanes::isMerge(lanes[i])) {
\r
629 int x1 = 0, x2 = 0;
\r
630 int maxWidth = rect.Width();
\r
631 int lw = 3 * rect.Height() / 4; //laneWidth()
\r
632 for (UINT i = 0; i < laneNum && x2 < maxWidth; i++) {
\r
638 if (ln == Lanes::EMPTY)
\r
641 UINT col = ( Lanes:: isHead(ln) ||Lanes:: isTail(ln) || Lanes::isJoin(ln)
\r
642 || ln ==Lanes:: CROSS_EMPTY) ? mergeLane : i;
\r
644 if (ln == Lanes::CROSS) {
\r
645 paintGraphLane(hdc, rect.Height(),Lanes::NOT_ACTIVE, x1, x2, colors[col % Lanes::COLORS_NUM],rect.top);
\r
646 paintGraphLane(hdc, rect.Height(),Lanes::CROSS, x1, x2, colors[mergeLane % Lanes::COLORS_NUM],rect.top);
\r
648 paintGraphLane(hdc, rect.Height(),ln, x1, x2, colors[col % Lanes::COLORS_NUM],rect.top);
\r
651 TRACE(_T("index %d %d\r\n"),index,data->m_Lanes.size());
\r
654 void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
657 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
\r
658 // Take the default processing unless we set this to something else below.
\r
659 *pResult = CDRF_DODEFAULT;
\r
661 if (m_bNoDispUpdates)
\r
666 switch (pLVCD->nmcd.dwDrawStage)
\r
668 case CDDS_PREPAINT:
\r
670 *pResult = CDRF_NOTIFYITEMDRAW;
\r
674 case CDDS_ITEMPREPAINT:
\r
676 // This is the prepaint stage for an item. Here's where we set the
\r
677 // item's text color.
\r
679 // Tell Windows to send draw notifications for each subitem.
\r
680 *pResult = CDRF_NOTIFYSUBITEMDRAW;
\r
682 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
\r
684 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
686 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
690 if (data->bCopiedSelf)
\r
692 // only change the background color if the item is not 'hot' (on vista with m_Themes enabled)
\r
693 if (!m_Theme.IsAppm_Themed() || !m_bVista || ((pLVCD->nmcd.uItemState & CDIS_HOT)==0))
\r
694 pLVCD->clrTextBk = GetSysColor(COLOR_MENU);
\r
698 crText = m_Colors.GetColor(CColors::Modified);
\r
700 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
\r
701 // crText = GetSysColor(COLOR_GRAYTEXT);
\r
702 // if (data->Rev == m_wcRev)
\r
704 // SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
705 // We changed the font, so we're returning CDRF_NEWFONT. This
\r
706 // tells the control to recalculate the extent of the text.
\r
707 // *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
711 if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
713 if (m_bStrictStopped)
\r
714 crText = GetSysColor(COLOR_GRAYTEXT);
\r
716 // Store the color back in the NMLVCUSTOMDRAW struct.
\r
717 pLVCD->clrText = crText;
\r
721 case CDDS_ITEMPREPAINT|CDDS_ITEM|CDDS_SUBITEM:
\r
723 if ((m_bStrictStopped)&&(m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec))
\r
725 pLVCD->nmcd.uItemState &= ~(CDIS_SELECTED|CDIS_FOCUS);
\r
728 if (pLVCD->iSubItem == LOGLIST_GRAPH)
\r
730 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
733 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
735 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
736 DrawGraph(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
\r
738 *pResult = CDRF_SKIPDEFAULT;
\r
744 if (pLVCD->iSubItem == LOGLIST_MESSAGE)
\r
746 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
748 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
749 if(!data->m_IsFull)
\r
751 if(data->SafeFetchFullInfo(&g_Git))
\r
752 this->Invalidate();
\r
753 TRACE(_T("Update ... %d\r\n"),pLVCD->nmcd.dwItemSpec);
\r
756 if(m_HashMap[data->m_CommitHash].size()!=0)
\r
760 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
762 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
763 DrawTagBranch(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
\r
765 *pResult = CDRF_SKIPDEFAULT;
\r
772 if (pLVCD->iSubItem == 1)
\r
774 if(this->m_IsIDReplaceAction)
\r
776 *pResult = CDRF_DODEFAULT;
\r
779 *pResult = CDRF_DODEFAULT;
\r
781 if (m_arShownList.GetCount() <= (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
785 int iconwidth = ::GetSystemMetrics(SM_CXSMICON);
\r
786 int iconheight = ::GetSystemMetrics(SM_CYSMICON);
\r
788 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec));
\r
790 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
791 // Get the selected state of the
\r
792 // item being drawn.
\r
794 // Fill the background
\r
795 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
797 // Draw the icon(s) into the compatible DC
\r
798 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_MODIFIED)
\r
799 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left + ICONITEMBORDER, rect.top, m_hModifiedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
802 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_ADDED)
\r
803 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hAddedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
806 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_DELETED)
\r
807 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hDeletedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
810 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_REPLACED)
\r
811 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hReplacedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
813 *pResult = CDRF_SKIPDEFAULT;
\r
819 *pResult = CDRF_DODEFAULT;
\r
823 // CGitLogListBase message handlers
\r
825 void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
827 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
\r
829 // Create a pointer to the item
\r
830 LV_ITEM* pItem = &(pDispInfo)->item;
\r
832 // Do the list need text information?
\r
833 if (!(pItem->mask & LVIF_TEXT))
\r
836 // By default, clear text buffer.
\r
837 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
839 bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();
\r
842 if (m_bNoDispUpdates || bOutOfRange)
\r
845 // Which item number?
\r
846 int itemid = pItem->iItem;
\r
847 GitRev * pLogEntry = NULL;
\r
848 if (itemid < m_arShownList.GetCount())
\r
849 pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(pItem->iItem));
\r
852 temp.Format(_T("%d"),m_arShownList.GetCount()-pItem->iItem);
\r
855 switch (pItem->iSubItem)
\r
857 case this->LOGLIST_GRAPH: //Graphic
\r
862 case this->LOGLIST_ACTION: //action -- no text in the column
\r
863 if(this->m_IsIDReplaceAction)
\r
864 lstrcpyn(pItem->pszText, temp, pItem->cchTextMax);
\r
866 case this->LOGLIST_MESSAGE: //Message
\r
868 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_Subject, pItem->cchTextMax);
\r
870 case this->LOGLIST_AUTHOR: //Author
\r
872 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorName, pItem->cchTextMax);
\r
874 case this->LOGLIST_DATE: //Date
\r
876 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorDate.Format(_T("%Y-%m-%d %H:%M")), pItem->cchTextMax);
\r
887 void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point)
\r
890 int selIndex = GetSelectionMark();
\r
892 return; // nothing selected, nothing to do with a context menu
\r
894 // if the user selected the info text telling about not all revisions shown due to
\r
895 // the "stop on copy/rename" option, we also don't show the context menu
\r
896 if ((m_bStrictStopped)&&(selIndex == m_arShownList.GetCount()))
\r
899 // if the context menu is invoked through the keyboard, we have to use
\r
900 // a calculated position on where to anchor the menu on
\r
901 if ((point.x == -1) && (point.y == -1))
\r
904 GetItemRect(selIndex, &rect, LVIR_LABEL);
\r
905 ClientToScreen(&rect);
\r
906 point = rect.CenterPoint();
\r
908 m_nSearchIndex = selIndex;
\r
909 m_bCancelled = FALSE;
\r
911 // calculate some information the context menu commands can use
\r
912 // CString pathURL = GetURLFromPath(m_path);
\r
914 POSITION pos = GetFirstSelectedItemPosition();
\r
915 int indexNext = GetNextSelectedItem(pos);
\r
919 GitRev* pSelLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(indexNext));
\r
921 GitRev revSelected = pSelLogEntry->Rev;
\r
922 GitRev revPrevious = git_revnum_t(revSelected)-1;
\r
923 if ((pSelLogEntry->pArChangedPaths)&&(pSelLogEntry->pArChangedPaths->GetCount() <= 2))
\r
925 for (int i=0; i<pSelLogEntry->pArChangedPaths->GetCount(); ++i)
\r
927 LogChangedPath * changedpath = (LogChangedPath *)pSelLogEntry->pArChangedPaths->GetAt(i);
\r
928 if (changedpath->lCopyFromRev)
\r
929 revPrevious = changedpath->lCopyFromRev;
\r
932 GitRev revSelected2;
\r
935 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
936 revSelected2 = pLogEntry->Rev;
\r
938 bool bAllFromTheSameAuthor = true;
\r
939 CString firstAuthor;
\r
940 CLogDataVector selEntries;
\r
941 GitRev revLowest, revHighest;
\r
942 GitRevRangeArray revisionRanges;
\r
944 POSITION pos = GetFirstSelectedItemPosition();
\r
945 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
946 revisionRanges.AddRevision(pLogEntry->Rev);
\r
947 selEntries.push_back(pLogEntry);
\r
948 firstAuthor = pLogEntry->sAuthor;
\r
949 revLowest = pLogEntry->Rev;
\r
950 revHighest = pLogEntry->Rev;
\r
953 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
954 revisionRanges.AddRevision(pLogEntry->Rev);
\r
955 selEntries.push_back(pLogEntry);
\r
956 if (firstAuthor.Compare(pLogEntry->sAuthor))
\r
957 bAllFromTheSameAuthor = false;
\r
958 revLowest = (git_revnum_t(pLogEntry->Rev) > git_revnum_t(revLowest) ? revLowest : pLogEntry->Rev);
\r
959 revHighest = (git_revnum_t(pLogEntry->Rev) < git_revnum_t(revHighest) ? revHighest : pLogEntry->Rev);
\r
965 int FirstSelect=-1, LastSelect=-1;
\r
966 pos = GetFirstSelectedItemPosition();
\r
967 FirstSelect = GetNextSelectedItem(pos);
\r
970 LastSelect = GetNextSelectedItem(pos);
\r
972 //entry is selected, now show the popup menu
\r
974 if (popup.CreatePopupMenu())
\r
976 if (GetSelectedCount() == 1)
\r
979 if (!m_path.IsDirectory())
\r
983 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
984 popup.AppendMenuIcon(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.AppendMenu(MF_SEPARATOR, NULL);
\r
989 popup.AppendMenuIcon(ID_SAVEAS, IDS_LOG_POPUP_SAVE, IDI_SAVEAS);
\r
990 popup.AppendMenuIcon(ID_OPEN, IDS_LOG_POPUP_OPEN, IDI_OPEN);
\r
991 popup.AppendMenuIcon(ID_OPENWITH, IDS_LOG_POPUP_OPENWITH, IDI_OPEN);
\r
992 popup.AppendMenuIcon(ID_BLAME, IDS_LOG_POPUP_BLAME, IDI_BLAME);
\r
993 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1000 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
1002 // TortoiseMerge could be improved to take a /blame switch
\r
1003 // and then not 'cat' the files from a unified diff but
\r
1005 // But until that's implemented, the context menu entry for
\r
1006 // this feature is commented out.
\r
1007 //popup.AppendMenu(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
1009 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
1010 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
1011 //popup.AppendMenuIcon(ID_BLAMEWITHPREVIOUS, IDS_LOG_POPUP_BLAMEWITHPREVIOUS, IDI_BLAME);
\r
1012 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1015 // if (!m_ProjectProperties.sWebViewerRev.IsEmpty())
\r
1017 // popup.AppendMenuIcon(ID_VIEWREV, IDS_LOG_POPUP_VIEWREV);
\r
1019 // if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
\r
1021 // popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
\r
1023 // if ((!m_ProjectProperties.sWebViewerPathRev.IsEmpty())||
\r
1024 // (!m_ProjectProperties.sWebViewerRev.IsEmpty()))
\r
1026 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1030 // popup.AppendMenuIcon(ID_REVERTTOREV, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT);
\r
1032 // popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT);
\r
1034 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREV, IDI_MERGE);
\r
1036 popup.AppendMenuIcon(ID_SWITCHTOREV, _T("Switch/Checkout to this") , IDI_SWITCH);
\r
1037 popup.AppendMenuIcon(ID_CREATE_BRANCH, _T("Create Branch at this version") , IDI_COPY);
\r
1038 popup.AppendMenuIcon(ID_CREATE_TAG, _T("Create Tag at this version"), IDI_COPY);
\r
1039 popup.AppendMenuIcon(ID_CHERRY_PICK, _T("Cherry Pick this version"), IDI_EXPORT);
\r
1040 popup.AppendMenuIcon(ID_EXPORT, _T("Export this version"), IDI_EXPORT);
\r
1043 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1045 else if (GetSelectedCount() >= 2)
\r
1047 bool bAddSeparator = false;
\r
1048 if (IsSelectionContinuous() || (GetSelectedCount() == 2))
\r
1050 popup.AppendMenuIcon(ID_COMPARETWO, IDS_LOG_POPUP_COMPARETWO, IDI_DIFF);
\r
1052 if (GetSelectedCount() == 2)
\r
1054 //popup.AppendMenuIcon(ID_BLAMETWO, IDS_LOG_POPUP_BLAMEREVS, IDI_BLAME);
\r
1055 popup.AppendMenuIcon(ID_GNUDIFF2, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);
\r
1056 bAddSeparator = true;
\r
1060 //popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREVS, IDI_REVERT);
\r
1062 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREVS, IDI_MERGE);
\r
1063 bAddSeparator = true;
\r
1065 if (bAddSeparator)
\r
1066 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1069 // if ((selEntries.size() > 0)&&(bAllFromTheSameAuthor))
\r
1071 // popup.AppendMenuIcon(ID_EDITAUTHOR, IDS_LOG_POPUP_EDITAUTHOR);
\r
1073 // if (GetSelectedCount() == 1)
\r
1075 // popup.AppendMenuIcon(ID_EDITLOG, IDS_LOG_POPUP_EDITLOG);
\r
1076 // popup.AppendMenuIcon(ID_REVPROPS, IDS_REPOBROWSE_SHOWREVPROP, IDI_PROPERTIES); // "Show Revision Properties"
\r
1077 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1082 if (GetSelectedCount() == 1)
\r
1084 popup.AppendMenuIcon(ID_COPYHASH, _T("Copy Commit Hash"));
\r
1086 if (GetSelectedCount() != 0)
\r
1088 popup.AppendMenuIcon(ID_COPYCLIPBOARD, IDS_LOG_POPUP_COPYTOCLIPBOARD);
\r
1090 popup.AppendMenuIcon(ID_FINDENTRY, IDS_LOG_POPUP_FIND);
\r
1092 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
1093 // DialogEnableWindow(IDOK, FALSE);
\r
1094 // SetPromptApp(&theApp);
\r
1096 this->ContextMenuAction(cmd, FirstSelect, LastSelect);
\r
1098 // EnableOKButton();
\r
1099 } // if (popup.CreatePopupMenu())
\r
1103 bool CGitLogListBase::IsSelectionContinuous()
\r
1105 if ( GetSelectedCount()==1 )
\r
1107 // if only one revision is selected, the selection is of course
\r
1112 POSITION pos = GetFirstSelectedItemPosition();
\r
1113 bool bContinuous = (m_arShownList.GetCount() == (INT_PTR)m_logEntries.size());
\r
1116 int itemindex = GetNextSelectedItem(pos);
\r
1119 int nextindex = GetNextSelectedItem(pos);
\r
1120 if (nextindex - itemindex > 1)
\r
1122 bContinuous = false;
\r
1125 itemindex = nextindex;
\r
1128 return bContinuous;
\r
1131 void CGitLogListBase::CopySelectionToClipBoard(bool HashOnly)
\r
1134 CString sClipdata;
\r
1135 POSITION pos = GetFirstSelectedItemPosition();
\r
1139 sRev.LoadString(IDS_LOG_REVISION);
\r
1141 sAuthor.LoadString(IDS_LOG_AUTHOR);
\r
1143 sDate.LoadString(IDS_LOG_DATE);
\r
1145 sMessage.LoadString(IDS_LOG_MESSAGE);
\r
1148 CString sLogCopyText;
\r
1150 GitRev * pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1154 //pLogEntry->m_Files
\r
1155 //LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1157 for (int cpPathIndex = 0; cpPathIndex<pLogEntry->m_Files.GetCount(); ++cpPathIndex)
\r
1159 sPaths += ((CTGitPath&)pLogEntry->m_Files[cpPathIndex]).GetActionName() + _T(" : ") + pLogEntry->m_Files[cpPathIndex].GetGitPathString();
\r
1160 sPaths += _T("\r\n");
\r
1163 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
1164 (LPCTSTR)sRev, pLogEntry->m_CommitHash,
\r
1165 (LPCTSTR)sAuthor, (LPCTSTR)pLogEntry->m_AuthorName,
\r
1166 (LPCTSTR)sDate, (LPCTSTR)pLogEntry->m_AuthorDate.Format(_T("%Y-%m-%d %H:%M")),
\r
1167 (LPCTSTR)sMessage, pLogEntry->m_Subject+_T("\r\n")+pLogEntry->m_Body,
\r
1169 sClipdata += sLogCopyText;
\r
1172 sClipdata += pLogEntry->m_CommitHash;
\r
1177 CStringUtils::WriteAsciiStringToClipboard(sClipdata, GetSafeHwnd());
\r
1182 void CGitLogListBase::DiffSelectedRevWithPrevious()
\r
1185 if (m_bThreadRunning)
\r
1187 UpdateLogInfoLabel();
\r
1188 int selIndex = m_LogList.GetSelectionMark();
\r
1191 int selCount = m_LogList.GetSelectedCount();
\r
1192 if (selCount != 1)
\r
1195 // Find selected entry in the log list
\r
1196 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1197 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1198 long rev1 = pLogEntry->Rev;
\r
1199 long rev2 = rev1-1;
\r
1200 CTGitPath path = m_path;
\r
1202 // See how many files under the relative root were changed in selected revision
\r
1204 LogChangedPath * changed = NULL;
\r
1205 for (INT_PTR c = 0; c < pLogEntry->pArChangedPaths->GetCount(); ++c)
\r
1207 LogChangedPath * cpath = pLogEntry->pArChangedPaths->GetAt(c);
\r
1208 if (cpath && cpath -> sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
1215 if (m_path.IsDirectory() && nChanged == 1)
\r
1217 // We're looking at the log for a directory and only one file under dir was changed in the revision
\r
1218 // Do diff on that file instead of whole directory
\r
1219 path.AppendPathString(changed->sPath.Mid(m_sRelativeRoot.GetLength()));
\r
1222 m_bCancelled = FALSE;
\r
1223 DialogEnableWindow(IDOK, FALSE);
\r
1224 SetPromptApp(&theApp);
\r
1225 theApp.DoWaitCursor(1);
\r
1227 if (PromptShown())
\r
1229 GitDiff diff(this, m_hWnd, true);
\r
1230 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1231 diff.SetHEADPeg(m_LogRevision);
\r
1232 diff.ShowCompare(path, rev2, path, rev1);
\r
1236 CAppUtils::StartShowCompare(m_hWnd, path, rev2, path, rev1, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1239 theApp.DoWaitCursor(-1);
\r
1244 void CGitLogListBase::OnLvnOdfinditemLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
1246 LPNMLVFINDITEM pFindInfo = reinterpret_cast<LPNMLVFINDITEM>(pNMHDR);
\r
1249 if (pFindInfo->lvfi.flags & LVFI_PARAM)
\r
1251 if ((pFindInfo->iStart < 0)||(pFindInfo->iStart >= m_arShownList.GetCount()))
\r
1253 if (pFindInfo->lvfi.psz == 0)
\r
1256 CString sCmp = pFindInfo->lvfi.psz;
\r
1258 for (int i=pFindInfo->iStart; i<m_arShownList.GetCount(); ++i)
\r
1260 GitRev * pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(i));
\r
1261 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1262 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1264 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1272 if (sCmp.Compare(sRev)==0)
\r
1279 if (pFindInfo->lvfi.flags & LVFI_WRAP)
\r
1281 for (int i=0; i<pFindInfo->iStart; ++i)
\r
1283 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1284 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1285 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1287 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1295 if (sCmp.Compare(sRev)==0)
\r
1307 int CGitLogListBase::FillGitLog(CTGitPath *path,int info)
\r
1311 this->m_logEntries.ClearAll();
\r
1312 this->m_logEntries.ParserFromLog(path,-1,info);
\r
1314 //this->m_logEntries.ParserFromLog();
\r
1315 SetItemCountEx(this->m_logEntries.size());
\r
1317 this->m_arShownList.RemoveAll();
\r
1319 for(int i=0;i<m_logEntries.size();i++)
\r
1321 m_logEntries[i].m_IsFull=TRUE;
\r
1322 this->m_arShownList.Add(&m_logEntries[i]);
\r
1328 int CGitLogListBase::FillGitShortLog()
\r
1332 this->m_logEntries.ClearAll();
\r
1333 this->m_logEntries.ParserShortLog();
\r
1335 //this->m_logEntries.ParserFromLog();
\r
1336 SetItemCountEx(this->m_logEntries.size());
\r
1338 this->m_arShownList.RemoveAll();
\r
1340 for(int i=0;i<m_logEntries.size();i++)
\r
1341 this->m_arShownList.Add(&m_logEntries[i]);
\r
1346 BOOL CGitLogListBase::PreTranslateMessage(MSG* pMsg)
\r
1348 // Skip Ctrl-C when copying text out of the log message or search filter
\r
1349 BOOL bSkipAccelerator = ( pMsg->message == WM_KEYDOWN && pMsg->wParam=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT) ) && GetKeyState(VK_CONTROL)&0x8000 );
\r
1350 if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')
\r
1352 //if (GetFocus()==GetDlgItem(IDC_LOGLIST))
\r
1354 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1356 DiffSelectedRevWithPrevious();
\r
1361 if (GetFocus()==GetDlgItem(IDC_LOGMSG))
\r
1363 DiffSelectedFile();
\r
1370 if (m_hAccel && !bSkipAccelerator)
\r
1372 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
\r
1378 //m_tooltips.RelayEvent(pMsg);
\r
1379 return __super::PreTranslateMessage(pMsg);
\r
1382 void CGitLogListBase::OnNMDblclkLoglist(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
1384 // a double click on an entry in the revision list has happened
\r
1387 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1388 DiffSelectedRevWithPrevious();
\r
1391 int CGitLogListBase::FetchLogAsync(CALLBACK_PROCESS *proc,void * data)
\r
1393 m_ProcCallBack=proc;
\r
1396 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1397 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1398 if (AfxBeginThread(LogThreadEntry, this)==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(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
1454 RedrawItems(0, m_arShownList.GetCount());
\r
1456 ResizeAllListCtrlCols();
\r
1459 if ( m_pStoreSelection )
\r
1461 // Deleting the instance will restore the
\r
1462 // selection of the CLogDlg.
\r
1463 delete m_pStoreSelection;
\r
1464 m_pStoreSelection = NULL;
\r
1468 // If no selection has been set then this must be the first time
\r
1469 // the revisions are shown. Let's preselect the topmost revision.
\r
1470 if ( GetItemCount()>0 )
\r
1472 SetSelectionMark(0);
\r
1473 SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
\r
1476 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1483 for(int i=0;i<m_logEntries.size();i++)
\r
1485 if(!m_logEntries.FetchFullInfo(i))
\r
1490 percent=updated*98/m_logEntries.size() + GITLOG_START+1;
\r
1491 if(percent == GITLOG_END)
\r
1492 percent == GITLOG_END -1;
\r
1494 if(m_ProcCallBack)
\r
1495 m_ProcCallBack(m_ProcData,percent);
\r
1497 if(updated==m_logEntries.size())
\r
1501 //RefreshCursor();
\r
1502 // make sure the filter is applied (if any) now, after we refreshed/fetched
\r
1503 // the log messages
\r
1507 if(m_ProcCallBack)
\r
1508 m_ProcCallBack(m_ProcData,GITLOG_END);
\r
1510 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1515 void CGitLogListBase::Refresh()
\r
1517 if(!m_bThreadRunning)
\r
1519 this->SetItemCountEx(0);
\r
1520 m_logEntries.clear();
\r
1521 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1522 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1523 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
1525 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1526 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1527 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
1529 m_sFilterText.Empty();
\r
1530 m_From=CTime(1970,1,2,0,0,0);
\r
1531 m_To=CTime::GetCurrentTime();
\r
1534 bool CGitLogListBase::ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase /* = false */)
\r
1538 tr1::regex_constants::syntax_option_type type = tr1::regex_constants::ECMAScript;
\r
1540 type |= tr1::regex_constants::icase;
\r
1541 pat = tr1::wregex(regexp_str, type);
\r
1544 catch (exception) {}
\r
1548 void CGitLogListBase::RecalculateShownList(CPtrArray * pShownlist)
\r
1551 pShownlist->RemoveAll();
\r
1552 tr1::wregex pat;//(_T("Remove"), tr1::regex_constants::icase);
\r
1553 bool bRegex = false;
\r
1554 if (m_bFilterWithRegex)
\r
1555 bRegex = ValidateRegexp(m_sFilterText, pat, false);
\r
1557 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_any;
\r
1559 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
1561 if ((bRegex)&&(m_bFilterWithRegex))
\r
1564 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
1566 ATLTRACE(_T("bugID = \"%s\"\n"), (LPCTSTR)m_logEntries[i]->sBugIDs);
\r
1567 if (regex_search(wstring((LPCTSTR)m_logEntries[i]->sBugIDs), pat, flags)&&IsEntryInDateRange(i))
\r
1569 pShownlist->Add(m_logEntries[i]);
\r
1574 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
1576 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries[i].m_Subject);
\r
1577 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_Subject), pat, flags)&&IsEntryInDateRange(i))
\r
1579 pShownlist->Add(&m_logEntries[i]);
\r
1583 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries[i].m_Body);
\r
1584 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_Body), pat, flags)&&IsEntryInDateRange(i))
\r
1586 pShownlist->Add(&m_logEntries[i]);
\r
1591 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
1593 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
1595 bool bGoing = true;
\r
1596 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
1598 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1599 if (regex_search(wstring((LPCTSTR)cpath->sCopyFromPath), pat, flags)&&IsEntryInDateRange(i))
\r
1601 pShownlist->Add(m_logEntries[i]);
\r
1605 if (regex_search(wstring((LPCTSTR)cpath->sPath), pat, flags)&&IsEntryInDateRange(i))
\r
1607 pShownlist->Add(m_logEntries[i]);
\r
1611 if (regex_search(wstring((LPCTSTR)cpath->GetAction()), pat, flags)&&IsEntryInDateRange(i))
\r
1613 pShownlist->Add(m_logEntries[i]);
\r
1622 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
1624 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_AuthorName), pat, flags)&&IsEntryInDateRange(i))
\r
1626 pShownlist->Add(&m_logEntries[i]);
\r
1630 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
1632 sRev.Format(_T("%ld"), m_logEntries[i].m_CommitHash);
\r
1633 if (regex_search(wstring((LPCTSTR)sRev), pat, flags)&&IsEntryInDateRange(i))
\r
1635 pShownlist->Add(&m_logEntries[i]);
\r
1642 CString find = m_sFilterText;
\r
1645 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
1647 CString sBugIDs = m_logEntries[i]->sBugIDs;
\r
1649 sBugIDs = sBugIDs.MakeLower();
\r
1650 if ((sBugIDs.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
1652 pShownlist->Add(m_logEntries[i]);
\r
1657 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
1659 CString msg = m_logEntries[i].m_Subject;
\r
1661 msg = msg.MakeLower();
\r
1662 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
1664 pShownlist->Add(&m_logEntries[i]);
\r
1667 msg = m_logEntries[i].m_Body;
\r
1669 msg = msg.MakeLower();
\r
1670 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
1672 pShownlist->Add(&m_logEntries[i]);
\r
1677 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
1679 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
1681 bool bGoing = true;
\r
1682 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
1684 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1685 CString path = cpath->sCopyFromPath;
\r
1687 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
1689 pShownlist->Add(m_logEntries[i]);
\r
1693 path = cpath->sPath;
\r
1695 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
1697 pShownlist->Add(m_logEntries[i]);
\r
1701 path = cpath->GetAction();
\r
1703 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
1705 pShownlist->Add(m_logEntries[i]);
\r
1712 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
1714 CString msg = m_logEntries[i].m_AuthorName;
\r
1715 msg = msg.MakeLower();
\r
1716 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
1718 pShownlist->Add(&m_logEntries[i]);
\r
1722 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
1724 sRev.Format(_T("%ld"), m_logEntries[i].m_CommitHash);
\r
1725 if ((sRev.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
1727 pShownlist->Add(&m_logEntries[i]);
\r
1731 } // else (from if (bRegex))
\r
1732 } // for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
1736 BOOL CGitLogListBase::IsEntryInDateRange(int i)
\r
1738 __time64_t time = m_logEntries[i].m_AuthorDate.GetTime();
\r
1739 if ((time >= m_From.GetTime())&&(time <= m_To.GetTime()))
\r
1746 void CGitLogListBase::StartFilter()
\r
1748 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1749 RecalculateShownList(&m_arShownList);
\r
1750 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1754 SetItemCountEx(ShownCountWithStopped());
\r
1755 RedrawItems(0, ShownCountWithStopped());
\r
1757 //ResizeAllListCtrlCols();
\r
1761 void CGitLogListBase::RemoveFilter()
\r
1764 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1766 m_arShownList.RemoveAll();
\r
1768 // reset the time filter too
\r
1770 m_timFrom = (__time64_t(m_tFrom));
\r
1771 m_timTo = (__time64_t(m_tTo));
\r
1772 m_DateFrom.SetTime(&m_timFrom);
\r
1773 m_DateTo.SetTime(&m_timTo);
\r
1774 m_DateFrom.SetRange(&m_timFrom, &m_timTo);
\r
1775 m_DateTo.SetRange(&m_timFrom, &m_timTo);
\r
1778 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
1780 m_arShownList.Add(&m_logEntries[i]);
\r
1782 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1784 SetItemCountEx(ShownCountWithStopped());
\r
1785 RedrawItems(0, ShownCountWithStopped());
\r
1787 ResizeAllListCtrlCols();
\r
1790 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1793 void CGitLogListBase::Clear()
\r
1795 m_arShownList.RemoveAll();
\r
1796 m_logEntries.clear();
\r
1797 m_logEntries.m_HashMap.clear();
\r
1799 m_logEntries.m_Lns.clear();
\r
1801 m_logEntries.m_FirstFreeLane=0;
\r
1802 m_logEntries.m_Lns.clear();
\r