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
86 m_CurrentBranch=g_Git.GetCurrentBranch();
\r
88 m_From=CTime(1970,1,2,0,0,0);
\r
89 m_To=CTime::GetCurrentTime();
\r
90 m_bAllBranch = FALSE;
\r
91 m_LoadingThread = NULL;
\r
93 m_bExitThread=FALSE;
\r
95 for(int i=0;i<Lanes::COLORS_NUM;i++)
\r
97 m_LineColors[i] = m_Colors.GetColor((CColors::Colors)(CColors::BranchLine1+i));
\r
101 CGitLogListBase::~CGitLogListBase()
\r
103 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
105 DestroyIcon(m_hModifiedIcon);
\r
106 DestroyIcon(m_hReplacedIcon);
\r
107 DestroyIcon(m_hAddedIcon);
\r
108 DestroyIcon(m_hDeletedIcon);
\r
109 m_logEntries.ClearAll();
\r
112 DeleteObject(m_boldFont);
\r
114 if ( m_pStoreSelection )
\r
116 delete m_pStoreSelection;
\r
117 m_pStoreSelection = NULL;
\r
122 BEGIN_MESSAGE_MAP(CGitLogListBase, CHintListCtrl)
\r
123 ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnNMCustomdrawLoglist)
\r
124 ON_NOTIFY_REFLECT(LVN_GETDISPINFO, OnLvnGetdispinfoLoglist)
\r
125 ON_WM_CONTEXTMENU()
\r
126 ON_NOTIFY_REFLECT(NM_DBLCLK, OnNMDblclkLoglist)
\r
127 ON_NOTIFY_REFLECT(LVN_ODFINDITEM,OnLvnOdfinditemLoglist)
\r
131 int CGitLogListBase:: OnCreate(LPCREATESTRUCT lpCreateStruct)
\r
133 PreSubclassWindow();
\r
134 return CHintListCtrl::OnCreate(lpCreateStruct);
\r
137 void CGitLogListBase::PreSubclassWindow()
\r
139 SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES);
\r
140 // load the icons for the action columns
\r
141 m_Theme.SetWindowTheme(GetSafeHwnd(), L"Explorer", NULL);
\r
142 CHintListCtrl::PreSubclassWindow();
\r
145 void CGitLogListBase::InsertGitColumn()
\r
149 int c = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;
\r
153 temp.LoadString(IDS_LOG_GRAPH);
\r
155 InsertColumn(this->LOGLIST_GRAPH, temp);
\r
158 // make the revision column right aligned
\r
160 Column.mask = LVCF_FMT;
\r
161 Column.fmt = LVCFMT_RIGHT;
\r
162 SetColumn(0, &Column);
\r
165 // g_Git.GetLog(log);
\r
167 if(m_IsIDReplaceAction)
\r
169 temp.LoadString(IDS_LOG_ID);
\r
170 InsertColumn(this->LOGLIST_ACTION, temp);
\r
174 temp.LoadString(IDS_LOG_ACTIONS);
\r
175 InsertColumn(this->LOGLIST_ACTION, temp);
\r
177 temp.LoadString(IDS_LOG_MESSAGE);
\r
178 InsertColumn(this->LOGLIST_MESSAGE, temp);
\r
180 temp.LoadString(IDS_LOG_AUTHOR);
\r
181 InsertColumn(this->LOGLIST_AUTHOR, temp);
\r
183 temp.LoadString(IDS_LOG_DATE);
\r
184 InsertColumn(this->LOGLIST_DATE, temp);
\r
187 if (m_bShowBugtraqColumn)
\r
189 // temp = m_ProjectProperties.sLabel;
\r
190 if (temp.IsEmpty())
\r
191 temp.LoadString(IDS_LOG_BUGIDS);
\r
192 InsertColumn(this->LOGLIST_BUG, temp);
\r
197 ResizeAllListCtrlCols();
\r
202 void CGitLogListBase::ResizeAllListCtrlCols()
\r
205 const int nMinimumWidth = ICONITEMBORDER+16*4;
\r
206 int maxcol = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;
\r
207 int nItemCount = GetItemCount();
\r
208 TCHAR textbuf[MAX_PATH];
\r
209 CHeaderCtrl * pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0));
\r
212 for (int col = 0; col <= maxcol; col++)
\r
215 hdi.mask = HDI_TEXT;
\r
216 hdi.pszText = textbuf;
\r
217 hdi.cchTextMax = sizeof(textbuf);
\r
218 pHdrCtrl->GetItem(col, &hdi);
\r
219 int cx = GetStringWidth(hdi.pszText)+20; // 20 pixels for col separator and margin
\r
220 for (int index = 0; index<nItemCount; ++index)
\r
222 // get the width of the string and add 14 pixels for the column separator and margins
\r
223 int linewidth = GetStringWidth(GetItemText(index, col)) + 14;
\r
224 if (index < m_arShownList.GetCount())
\r
226 GitRev * pCurLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(index));
\r
227 if ((pCurLogEntry)&&(pCurLogEntry->m_CommitHash == m_wcRev.m_CommitHash))
\r
229 // set the bold font and ask for the string width again
\r
230 SendMessage(WM_SETFONT, (WPARAM)m_boldFont, NULL);
\r
231 linewidth = GetStringWidth(GetItemText(index, col)) + 14;
\r
232 // restore the system font
\r
233 SendMessage(WM_SETFONT, NULL, NULL);
\r
238 // add the image size
\r
239 CImageList * pImgList = GetImageList(LVSIL_SMALL);
\r
240 if ((pImgList)&&(pImgList->GetImageCount()))
\r
243 pImgList->GetImageInfo(0, &imginfo);
\r
244 linewidth += (imginfo.rcImage.right - imginfo.rcImage.left);
\r
245 linewidth += 3; // 3 pixels between icon and text
\r
248 if (cx < linewidth)
\r
251 // Adjust columns "Actions" containing icons
\r
252 if (col == this->LOGLIST_ACTION)
\r
254 if (cx < nMinimumWidth)
\r
256 cx = nMinimumWidth;
\r
260 if (col == this->LOGLIST_MESSAGE)
\r
262 if (cx > LOGLIST_MESSAGE_MAX)
\r
264 cx = LOGLIST_MESSAGE_MAX;
\r
266 if (cx < LOGLIST_MESSAGE_MIN)
\r
268 cx = LOGLIST_MESSAGE_MIN;
\r
272 // keep the bug id column small
\r
273 if ((col == 4)&&(m_bShowBugtraqColumn))
\r
275 if (cx > (int)(DWORD)m_regMaxBugIDColWidth)
\r
277 cx = (int)(DWORD)m_regMaxBugIDColWidth;
\r
281 SetColumnWidth(col, cx);
\r
288 BOOL CGitLogListBase::GetShortName(CString ref, CString &shortname,CString prefix)
\r
290 TRACE(_T("%s %s\r\n"),ref,prefix);
\r
291 if(ref.Left(prefix.GetLength()) == prefix)
\r
293 shortname = ref.Right(ref.GetLength()-prefix.GetLength());
\r
294 if(shortname.Right(3)==_T("^{}"))
\r
295 shortname=shortname.Left(shortname.GetLength()-3);
\r
300 void CGitLogListBase::FillBackGround(HDC hdc, int Index,CRect &rect)
\r
304 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
305 rItem.mask = LVIF_STATE;
\r
306 rItem.iItem = Index;
\r
307 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
310 if (m_Theme.IsAppThemed() && m_bVista)
\r
312 m_Theme.Open(m_hWnd, L"Explorer");
\r
313 int state = LISS_NORMAL;
\r
314 if (rItem.state & LVIS_SELECTED)
\r
316 if (::GetFocus() == m_hWnd)
\r
317 state |= LISS_SELECTED;
\r
319 state |= LISS_SELECTEDNOTFOCUS;
\r
324 if (pLogEntry->bCopiedSelf)
\r
326 // unfortunately, the pLVCD->nmcd.uItemState does not contain valid
\r
327 // information at this drawing stage. But we can check the whether the
\r
328 // previous stage changed the background color of the item
\r
329 if (pLVCD->clrTextBk == GetSysColor(COLOR_MENU))
\r
332 brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
335 ::FillRect(pLVCD->nmcd.hdc, &rect, brush);
\r
336 ::DeleteObject(brush);
\r
343 if (m_Theme.IsBackgroundPartiallyTransparent(LVP_LISTDETAIL, state))
\r
344 m_Theme.DrawParentBackground(m_hWnd, hdc, &rect);
\r
346 m_Theme.DrawBackground(hdc, LVP_LISTDETAIL, state, &rect, NULL);
\r
351 if (rItem.state & LVIS_SELECTED)
\r
353 if (::GetFocus() == m_hWnd)
\r
354 brush = ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));
\r
356 brush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));
\r
360 //if (pLogEntry->bCopiedSelf)
\r
361 // brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
363 brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW));
\r
368 ::FillRect(hdc, &rect, brush);
\r
369 ::DeleteObject(brush);
\r
374 void CGitLogListBase::DrawTagBranch(HDC hdc,CRect &rect,INT_PTR index)
\r
376 GitRev* data = (GitRev*)m_arShownList.GetAt(index);
\r
379 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
380 rItem.mask = LVIF_STATE;
\r
381 rItem.iItem = index;
\r
382 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
385 for(unsigned int i=0;i<m_HashMap[data->m_CommitHash].size();i++)
\r
388 str=m_HashMap[data->m_CommitHash][i];
\r
393 if(GetShortName(str,shortname,_T("refs/heads/")))
\r
395 if( shortname == m_CurrentBranch )
\r
396 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::CurrentBranch));
\r
398 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::LocalBranch));
\r
400 }else if(GetShortName(str,shortname,_T("refs/remotes/")))
\r
402 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::RemoteBranch));
\r
404 else if(GetShortName(str,shortname,_T("refs/tags/")))
\r
406 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::Tag));
\r
409 if(!shortname.IsEmpty())
\r
412 memset(&size,0,sizeof(SIZE));
\r
413 GetTextExtentPoint32(hdc, shortname,shortname.GetLength(),&size);
\r
415 rt.SetRect(rt.left,rt.top,rt.left+size.cx,rt.bottom);
\r
417 ::FillRect(hdc, &rt, brush);
\r
418 if (rItem.state & LVIS_SELECTED)
\r
420 COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT));
\r
421 ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER);
\r
422 ::SetTextColor(hdc,clrOld);
\r
425 ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER);
\r
429 ::MoveToEx(hdc,rt.left,rt.top,NULL);
\r
430 ::LineTo(hdc,rt.right,rt.top);
\r
431 ::LineTo(hdc,rt.right,rt.bottom);
\r
432 ::LineTo(hdc,rt.left,rt.bottom);
\r
433 ::LineTo(hdc,rt.left,rt.top);
\r
435 rt.left=rt.right+3;
\r
438 ::DeleteObject(brush);
\r
440 rt.right=rect.right;
\r
442 if (rItem.state & LVIS_SELECTED)
\r
444 COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT));
\r
445 ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT);
\r
446 ::SetTextColor(hdc,clrOld);
\r
449 ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT);
\r
454 void CGitLogListBase::paintGraphLane(HDC hdc, int laneHeight,int type, int x1, int x2,
\r
455 const COLORREF& col,int top
\r
458 int h = laneHeight / 2;
\r
459 int m = (x1 + x2) / 2;
\r
460 int r = (x2 - x1) / 3;
\r
463 #define P_CENTER m , h+top
\r
464 #define P_0 x2, h+top
\r
465 #define P_90 m , 0+top
\r
466 #define P_180 x1, h+top
\r
467 #define P_270 m , 2 * h+top
\r
468 #define R_CENTER m - r, h - r+top, m - r+d, h - r+top+d
\r
470 //static QPen myPen(Qt::black, 2); // fast path here
\r
472 pen.CreatePen(PS_SOLID,2,col);
\r
473 //myPen.setColor(col);
\r
474 HPEN oldpen=(HPEN)::SelectObject(hdc,(HPEN)pen);
\r
476 //p->setPen(myPen);
\r
480 case Lanes::ACTIVE:
\r
481 case Lanes::NOT_ACTIVE:
\r
482 case Lanes::MERGE_FORK:
\r
483 case Lanes::MERGE_FORK_R:
\r
484 case Lanes::MERGE_FORK_L:
\r
486 case Lanes::JOIN_R:
\r
487 case Lanes::JOIN_L:
\r
488 DrawLine(hdc,P_90,P_270);
\r
489 //p->drawLine(P_90, P_270);
\r
492 case Lanes::HEAD_R:
\r
493 case Lanes::HEAD_L:
\r
494 case Lanes::BRANCH:
\r
495 DrawLine(hdc,P_CENTER,P_270);
\r
496 //p->drawLine(P_CENTER, P_270);
\r
499 case Lanes::TAIL_R:
\r
500 case Lanes::TAIL_L:
\r
501 case Lanes::INITIAL:
\r
502 case Lanes::BOUNDARY:
\r
503 case Lanes::BOUNDARY_C:
\r
504 case Lanes::BOUNDARY_R:
\r
505 case Lanes::BOUNDARY_L:
\r
506 DrawLine(hdc,P_90, P_CENTER);
\r
507 //p->drawLine(P_90, P_CENTER);
\r
515 case Lanes::MERGE_FORK:
\r
520 case Lanes::CROSS_EMPTY:
\r
521 case Lanes::BOUNDARY_C:
\r
522 DrawLine(hdc,P_180,P_0);
\r
523 //p->drawLine(P_180, P_0);
\r
525 case Lanes::MERGE_FORK_R:
\r
526 case Lanes::JOIN_R:
\r
527 case Lanes::HEAD_R:
\r
528 case Lanes::TAIL_R:
\r
529 case Lanes::BOUNDARY_R:
\r
530 DrawLine(hdc,P_180,P_CENTER);
\r
531 //p->drawLine(P_180, P_CENTER);
\r
533 case Lanes::MERGE_FORK_L:
\r
534 case Lanes::JOIN_L:
\r
535 case Lanes::HEAD_L:
\r
536 case Lanes::TAIL_L:
\r
537 case Lanes::BOUNDARY_L:
\r
538 DrawLine(hdc,P_CENTER,P_0);
\r
539 //p->drawLine(P_CENTER, P_0);
\r
546 brush.CreateSolidBrush(col);
\r
547 HBRUSH oldbrush=(HBRUSH)::SelectObject(hdc,(HBRUSH)brush);
\r
548 // center symbol, e.g. rect or ellipse
\r
550 case Lanes::ACTIVE:
\r
551 case Lanes::INITIAL:
\r
552 case Lanes::BRANCH:
\r
554 //p->setPen(Qt::NoPen);
\r
555 //p->setBrush(col);
\r
556 ::Ellipse(hdc, R_CENTER);
\r
557 //p->drawEllipse(R_CENTER);
\r
559 case Lanes::MERGE_FORK:
\r
560 case Lanes::MERGE_FORK_R:
\r
561 case Lanes::MERGE_FORK_L:
\r
562 //p->setPen(Qt::NoPen);
\r
563 //p->setBrush(col);
\r
564 //p->drawRect(R_CENTER);
\r
565 Rectangle(hdc,R_CENTER);
\r
567 case Lanes::UNAPPLIED:
\r
569 //p->setPen(Qt::NoPen);
\r
570 //p->setBrush(Qt::red);
\r
571 //p->drawRect(m - r, h - 1, d, 2);
\r
572 ::Rectangle(hdc,m-r,h-1,d,2);
\r
574 case Lanes::APPLIED:
\r
576 //p->setPen(Qt::NoPen);
\r
577 //p->setBrush(DARK_GREEN);
\r
578 //p->drawRect(m - r, h - 1, d, 2);
\r
579 //p->drawRect(m - 1, h - r, 2, d);
\r
580 ::Rectangle(hdc,m-r,h-1,d,2);
\r
581 ::Rectangle(hdc,m-1,h-r,2,d);
\r
583 case Lanes::BOUNDARY:
\r
584 //p->setBrush(back);
\r
585 //p->drawEllipse(R_CENTER);
\r
586 ::Ellipse(hdc, R_CENTER);
\r
588 case Lanes::BOUNDARY_C:
\r
589 case Lanes::BOUNDARY_R:
\r
590 case Lanes::BOUNDARY_L:
\r
591 //p->setBrush(back);
\r
592 //p->drawRect(R_CENTER);
\r
593 ::Rectangle(hdc,R_CENTER);
\r
599 ::SelectObject(hdc,oldpen);
\r
600 ::SelectObject(hdc,oldbrush);
\r
609 void CGitLogListBase::DrawGraph(HDC hdc,CRect &rect,INT_PTR index)
\r
613 GitRev* data = (GitRev*)m_arShownList.GetAt(index);
\r
616 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
617 rItem.mask = LVIF_STATE;
\r
618 rItem.iItem = index;
\r
619 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
623 // p->translate(QPoint(opt.rect.left(), opt.rect.top()));
\r
627 if (data->m_Lanes.size() == 0)
\r
628 m_logEntries.setLane(data->m_CommitHash);
\r
630 std::vector<int>& lanes=data->m_Lanes;
\r
631 UINT laneNum = lanes.size();
\r
632 UINT mergeLane = 0;
\r
633 for (UINT i = 0; i < laneNum; i++)
\r
634 if (Lanes::isMerge(lanes[i])) {
\r
639 int x1 = 0, x2 = 0;
\r
640 int maxWidth = rect.Width();
\r
641 int lw = 3 * rect.Height() / 4; //laneWidth()
\r
642 for (UINT i = 0; i < laneNum && x2 < maxWidth; i++) {
\r
648 if (ln == Lanes::EMPTY)
\r
651 UINT col = ( Lanes:: isHead(ln) ||Lanes:: isTail(ln) || Lanes::isJoin(ln)
\r
652 || ln ==Lanes:: CROSS_EMPTY) ? mergeLane : i;
\r
654 if (ln == Lanes::CROSS) {
\r
655 paintGraphLane(hdc, rect.Height(),Lanes::NOT_ACTIVE, x1, x2, m_LineColors[col % Lanes::COLORS_NUM],rect.top);
\r
656 paintGraphLane(hdc, rect.Height(),Lanes::CROSS, x1, x2, m_LineColors[mergeLane % Lanes::COLORS_NUM],rect.top);
\r
658 paintGraphLane(hdc, rect.Height(),ln, x1, x2, m_LineColors[col % Lanes::COLORS_NUM],rect.top);
\r
661 TRACE(_T("index %d %d\r\n"),index,data->m_Lanes.size());
\r
664 void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
667 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
\r
668 // Take the default processing unless we set this to something else below.
\r
669 *pResult = CDRF_DODEFAULT;
\r
671 if (m_bNoDispUpdates)
\r
676 switch (pLVCD->nmcd.dwDrawStage)
\r
678 case CDDS_PREPAINT:
\r
680 *pResult = CDRF_NOTIFYITEMDRAW;
\r
684 case CDDS_ITEMPREPAINT:
\r
686 // This is the prepaint stage for an item. Here's where we set the
\r
687 // item's text color.
\r
689 // Tell Windows to send draw notifications for each subitem.
\r
690 *pResult = CDRF_NOTIFYSUBITEMDRAW;
\r
692 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
\r
694 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
696 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
700 if (data->bCopiedSelf)
\r
702 // only change the background color if the item is not 'hot' (on vista with m_Themes enabled)
\r
703 if (!m_Theme.IsAppm_Themed() || !m_bVista || ((pLVCD->nmcd.uItemState & CDIS_HOT)==0))
\r
704 pLVCD->clrTextBk = GetSysColor(COLOR_MENU);
\r
708 crText = m_Colors.GetColor(CColors::Modified);
\r
710 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
\r
711 // crText = GetSysColor(COLOR_GRAYTEXT);
\r
712 // if (data->Rev == m_wcRev)
\r
714 // SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
715 // We changed the font, so we're returning CDRF_NEWFONT. This
\r
716 // tells the control to recalculate the extent of the text.
\r
717 // *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
721 if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
723 if (m_bStrictStopped)
\r
724 crText = GetSysColor(COLOR_GRAYTEXT);
\r
726 // Store the color back in the NMLVCUSTOMDRAW struct.
\r
727 pLVCD->clrText = crText;
\r
731 case CDDS_ITEMPREPAINT|CDDS_ITEM|CDDS_SUBITEM:
\r
733 if ((m_bStrictStopped)&&(m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec))
\r
735 pLVCD->nmcd.uItemState &= ~(CDIS_SELECTED|CDIS_FOCUS);
\r
738 if (pLVCD->iSubItem == LOGLIST_GRAPH)
\r
740 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
743 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
745 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
746 DrawGraph(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
\r
748 *pResult = CDRF_SKIPDEFAULT;
\r
754 if (pLVCD->iSubItem == LOGLIST_MESSAGE)
\r
756 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
758 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
759 if(!data->m_IsFull)
\r
761 if(data->SafeFetchFullInfo(&g_Git))
\r
762 this->Invalidate();
\r
763 TRACE(_T("Update ... %d\r\n"),pLVCD->nmcd.dwItemSpec);
\r
766 if(m_HashMap[data->m_CommitHash].size()!=0)
\r
770 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
772 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
773 DrawTagBranch(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
\r
775 *pResult = CDRF_SKIPDEFAULT;
\r
782 if (pLVCD->iSubItem == 1)
\r
784 if(this->m_IsIDReplaceAction)
\r
786 *pResult = CDRF_DODEFAULT;
\r
789 *pResult = CDRF_DODEFAULT;
\r
791 if (m_arShownList.GetCount() <= (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
795 int iconwidth = ::GetSystemMetrics(SM_CXSMICON);
\r
796 int iconheight = ::GetSystemMetrics(SM_CYSMICON);
\r
798 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec));
\r
800 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
801 // Get the selected state of the
\r
802 // item being drawn.
\r
804 // Fill the background
\r
805 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
807 // Draw the icon(s) into the compatible DC
\r
808 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_MODIFIED)
\r
809 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left + ICONITEMBORDER, rect.top, m_hModifiedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
812 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_ADDED)
\r
813 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hAddedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
816 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_DELETED)
\r
817 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hDeletedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
820 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_REPLACED)
\r
821 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hReplacedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
823 *pResult = CDRF_SKIPDEFAULT;
\r
829 *pResult = CDRF_DODEFAULT;
\r
833 // CGitLogListBase message handlers
\r
835 void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
837 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
\r
839 // Create a pointer to the item
\r
840 LV_ITEM* pItem = &(pDispInfo)->item;
\r
842 // Do the list need text information?
\r
843 if (!(pItem->mask & LVIF_TEXT))
\r
846 // By default, clear text buffer.
\r
847 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
849 bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();
\r
852 if (m_bNoDispUpdates || bOutOfRange)
\r
855 // Which item number?
\r
856 int itemid = pItem->iItem;
\r
857 GitRev * pLogEntry = NULL;
\r
858 if (itemid < m_arShownList.GetCount())
\r
859 pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(pItem->iItem));
\r
862 temp.Format(_T("%d"),m_arShownList.GetCount()-pItem->iItem);
\r
865 switch (pItem->iSubItem)
\r
867 case this->LOGLIST_GRAPH: //Graphic
\r
872 case this->LOGLIST_ACTION: //action -- no text in the column
\r
873 if(this->m_IsIDReplaceAction)
\r
874 lstrcpyn(pItem->pszText, temp, pItem->cchTextMax);
\r
876 case this->LOGLIST_MESSAGE: //Message
\r
878 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_Subject, pItem->cchTextMax);
\r
880 case this->LOGLIST_AUTHOR: //Author
\r
882 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorName, pItem->cchTextMax);
\r
884 case this->LOGLIST_DATE: //Date
\r
886 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorDate.Format(_T("%Y-%m-%d %H:%M")), pItem->cchTextMax);
\r
897 void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point)
\r
900 int selIndex = GetSelectionMark();
\r
902 return; // nothing selected, nothing to do with a context menu
\r
904 // if the user selected the info text telling about not all revisions shown due to
\r
905 // the "stop on copy/rename" option, we also don't show the context menu
\r
906 if ((m_bStrictStopped)&&(selIndex == m_arShownList.GetCount()))
\r
909 // if the context menu is invoked through the keyboard, we have to use
\r
910 // a calculated position on where to anchor the menu on
\r
911 if ((point.x == -1) && (point.y == -1))
\r
914 GetItemRect(selIndex, &rect, LVIR_LABEL);
\r
915 ClientToScreen(&rect);
\r
916 point = rect.CenterPoint();
\r
918 m_nSearchIndex = selIndex;
\r
919 m_bCancelled = FALSE;
\r
921 // calculate some information the context menu commands can use
\r
922 // CString pathURL = GetURLFromPath(m_path);
\r
924 POSITION pos = GetFirstSelectedItemPosition();
\r
925 int indexNext = GetNextSelectedItem(pos);
\r
929 GitRev* pSelLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(indexNext));
\r
931 GitRev revSelected = pSelLogEntry->Rev;
\r
932 GitRev revPrevious = git_revnum_t(revSelected)-1;
\r
933 if ((pSelLogEntry->pArChangedPaths)&&(pSelLogEntry->pArChangedPaths->GetCount() <= 2))
\r
935 for (int i=0; i<pSelLogEntry->pArChangedPaths->GetCount(); ++i)
\r
937 LogChangedPath * changedpath = (LogChangedPath *)pSelLogEntry->pArChangedPaths->GetAt(i);
\r
938 if (changedpath->lCopyFromRev)
\r
939 revPrevious = changedpath->lCopyFromRev;
\r
942 GitRev revSelected2;
\r
945 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
946 revSelected2 = pLogEntry->Rev;
\r
948 bool bAllFromTheSameAuthor = true;
\r
949 CString firstAuthor;
\r
950 CLogDataVector selEntries;
\r
951 GitRev revLowest, revHighest;
\r
952 GitRevRangeArray revisionRanges;
\r
954 POSITION pos = GetFirstSelectedItemPosition();
\r
955 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
956 revisionRanges.AddRevision(pLogEntry->Rev);
\r
957 selEntries.push_back(pLogEntry);
\r
958 firstAuthor = pLogEntry->sAuthor;
\r
959 revLowest = pLogEntry->Rev;
\r
960 revHighest = pLogEntry->Rev;
\r
963 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
964 revisionRanges.AddRevision(pLogEntry->Rev);
\r
965 selEntries.push_back(pLogEntry);
\r
966 if (firstAuthor.Compare(pLogEntry->sAuthor))
\r
967 bAllFromTheSameAuthor = false;
\r
968 revLowest = (git_revnum_t(pLogEntry->Rev) > git_revnum_t(revLowest) ? revLowest : pLogEntry->Rev);
\r
969 revHighest = (git_revnum_t(pLogEntry->Rev) < git_revnum_t(revHighest) ? revHighest : pLogEntry->Rev);
\r
975 int FirstSelect=-1, LastSelect=-1;
\r
976 pos = GetFirstSelectedItemPosition();
\r
977 FirstSelect = GetNextSelectedItem(pos);
\r
980 LastSelect = GetNextSelectedItem(pos);
\r
982 //entry is selected, now show the popup menu
\r
984 if (popup.CreatePopupMenu())
\r
986 if (GetSelectedCount() == 1)
\r
989 if (!m_path.IsDirectory())
\r
993 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
994 popup.AppendMenuIcon(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
996 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
997 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
998 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
999 popup.AppendMenuIcon(ID_SAVEAS, IDS_LOG_POPUP_SAVE, IDI_SAVEAS);
\r
1000 popup.AppendMenuIcon(ID_OPEN, IDS_LOG_POPUP_OPEN, IDI_OPEN);
\r
1001 popup.AppendMenuIcon(ID_OPENWITH, IDS_LOG_POPUP_OPENWITH, IDI_OPEN);
\r
1002 popup.AppendMenuIcon(ID_BLAME, IDS_LOG_POPUP_BLAME, IDI_BLAME);
\r
1003 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1010 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
1012 // TortoiseMerge could be improved to take a /blame switch
\r
1013 // and then not 'cat' the files from a unified diff but
\r
1015 // But until that's implemented, the context menu entry for
\r
1016 // this feature is commented out.
\r
1017 //popup.AppendMenu(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
1019 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
1020 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
1021 //popup.AppendMenuIcon(ID_BLAMEWITHPREVIOUS, IDS_LOG_POPUP_BLAMEWITHPREVIOUS, IDI_BLAME);
\r
1022 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1025 // if (!m_ProjectProperties.sWebViewerRev.IsEmpty())
\r
1027 // popup.AppendMenuIcon(ID_VIEWREV, IDS_LOG_POPUP_VIEWREV);
\r
1029 // if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
\r
1031 // popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
\r
1033 // if ((!m_ProjectProperties.sWebViewerPathRev.IsEmpty())||
\r
1034 // (!m_ProjectProperties.sWebViewerRev.IsEmpty()))
\r
1036 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1040 // popup.AppendMenuIcon(ID_REVERTTOREV, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT);
\r
1042 // popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT);
\r
1044 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREV, IDI_MERGE);
\r
1047 str.Format(_T("Reset %s to this"),g_Git.GetCurrentBranch());
\r
1048 popup.AppendMenuIcon(ID_RESET,str,IDI_REVERT);
\r
1049 popup.AppendMenuIcon(ID_SWITCHTOREV, _T("Switch/Checkout to this") , IDI_SWITCH);
\r
1050 popup.AppendMenuIcon(ID_CREATE_BRANCH, _T("Create Branch at this version") , IDI_COPY);
\r
1051 popup.AppendMenuIcon(ID_CREATE_TAG, _T("Create Tag at this version"), IDI_COPY);
\r
1052 popup.AppendMenuIcon(ID_CHERRY_PICK, _T("Cherry Pick this version"), IDI_EXPORT);
\r
1053 popup.AppendMenuIcon(ID_EXPORT, _T("Export this version"), IDI_EXPORT);
\r
1056 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1058 else if (GetSelectedCount() >= 2)
\r
1060 bool bAddSeparator = false;
\r
1061 if (IsSelectionContinuous() || (GetSelectedCount() == 2))
\r
1063 popup.AppendMenuIcon(ID_COMPARETWO, IDS_LOG_POPUP_COMPARETWO, IDI_DIFF);
\r
1065 if (GetSelectedCount() == 2)
\r
1067 //popup.AppendMenuIcon(ID_BLAMETWO, IDS_LOG_POPUP_BLAMEREVS, IDI_BLAME);
\r
1068 popup.AppendMenuIcon(ID_GNUDIFF2, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);
\r
1069 bAddSeparator = true;
\r
1073 //popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREVS, IDI_REVERT);
\r
1075 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREVS, IDI_MERGE);
\r
1076 bAddSeparator = true;
\r
1078 if (bAddSeparator)
\r
1079 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1082 // if ((selEntries.size() > 0)&&(bAllFromTheSameAuthor))
\r
1084 // popup.AppendMenuIcon(ID_EDITAUTHOR, IDS_LOG_POPUP_EDITAUTHOR);
\r
1086 // if (GetSelectedCount() == 1)
\r
1088 // popup.AppendMenuIcon(ID_EDITLOG, IDS_LOG_POPUP_EDITLOG);
\r
1089 // popup.AppendMenuIcon(ID_REVPROPS, IDS_REPOBROWSE_SHOWREVPROP, IDI_PROPERTIES); // "Show Revision Properties"
\r
1090 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1095 if (GetSelectedCount() == 1)
\r
1097 popup.AppendMenuIcon(ID_COPYHASH, _T("Copy Commit Hash"));
\r
1099 if (GetSelectedCount() != 0)
\r
1101 popup.AppendMenuIcon(ID_COPYCLIPBOARD, IDS_LOG_POPUP_COPYTOCLIPBOARD);
\r
1103 popup.AppendMenuIcon(ID_FINDENTRY, IDS_LOG_POPUP_FIND);
\r
1105 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
1106 // DialogEnableWindow(IDOK, FALSE);
\r
1107 // SetPromptApp(&theApp);
\r
1109 this->ContextMenuAction(cmd, FirstSelect, LastSelect);
\r
1111 // EnableOKButton();
\r
1112 } // if (popup.CreatePopupMenu())
\r
1116 bool CGitLogListBase::IsSelectionContinuous()
\r
1118 if ( GetSelectedCount()==1 )
\r
1120 // if only one revision is selected, the selection is of course
\r
1125 POSITION pos = GetFirstSelectedItemPosition();
\r
1126 bool bContinuous = (m_arShownList.GetCount() == (INT_PTR)m_logEntries.size());
\r
1129 int itemindex = GetNextSelectedItem(pos);
\r
1132 int nextindex = GetNextSelectedItem(pos);
\r
1133 if (nextindex - itemindex > 1)
\r
1135 bContinuous = false;
\r
1138 itemindex = nextindex;
\r
1141 return bContinuous;
\r
1144 void CGitLogListBase::CopySelectionToClipBoard(bool HashOnly)
\r
1147 CString sClipdata;
\r
1148 POSITION pos = GetFirstSelectedItemPosition();
\r
1152 sRev.LoadString(IDS_LOG_REVISION);
\r
1154 sAuthor.LoadString(IDS_LOG_AUTHOR);
\r
1156 sDate.LoadString(IDS_LOG_DATE);
\r
1158 sMessage.LoadString(IDS_LOG_MESSAGE);
\r
1161 CString sLogCopyText;
\r
1163 GitRev * pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1167 //pLogEntry->m_Files
\r
1168 //LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1170 for (int cpPathIndex = 0; cpPathIndex<pLogEntry->m_Files.GetCount(); ++cpPathIndex)
\r
1172 sPaths += ((CTGitPath&)pLogEntry->m_Files[cpPathIndex]).GetActionName() + _T(" : ") + pLogEntry->m_Files[cpPathIndex].GetGitPathString();
\r
1173 sPaths += _T("\r\n");
\r
1176 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
1177 (LPCTSTR)sRev, pLogEntry->m_CommitHash,
\r
1178 (LPCTSTR)sAuthor, (LPCTSTR)pLogEntry->m_AuthorName,
\r
1179 (LPCTSTR)sDate, (LPCTSTR)pLogEntry->m_AuthorDate.Format(_T("%Y-%m-%d %H:%M")),
\r
1180 (LPCTSTR)sMessage, pLogEntry->m_Subject+_T("\r\n")+pLogEntry->m_Body,
\r
1182 sClipdata += sLogCopyText;
\r
1185 sClipdata += pLogEntry->m_CommitHash;
\r
1190 CStringUtils::WriteAsciiStringToClipboard(sClipdata, GetSafeHwnd());
\r
1195 void CGitLogListBase::DiffSelectedRevWithPrevious()
\r
1198 if (m_bThreadRunning)
\r
1200 UpdateLogInfoLabel();
\r
1201 int selIndex = m_LogList.GetSelectionMark();
\r
1204 int selCount = m_LogList.GetSelectedCount();
\r
1205 if (selCount != 1)
\r
1208 // Find selected entry in the log list
\r
1209 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1210 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1211 long rev1 = pLogEntry->Rev;
\r
1212 long rev2 = rev1-1;
\r
1213 CTGitPath path = m_path;
\r
1215 // See how many files under the relative root were changed in selected revision
\r
1217 LogChangedPath * changed = NULL;
\r
1218 for (INT_PTR c = 0; c < pLogEntry->pArChangedPaths->GetCount(); ++c)
\r
1220 LogChangedPath * cpath = pLogEntry->pArChangedPaths->GetAt(c);
\r
1221 if (cpath && cpath -> sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
1228 if (m_path.IsDirectory() && nChanged == 1)
\r
1230 // We're looking at the log for a directory and only one file under dir was changed in the revision
\r
1231 // Do diff on that file instead of whole directory
\r
1232 path.AppendPathString(changed->sPath.Mid(m_sRelativeRoot.GetLength()));
\r
1235 m_bCancelled = FALSE;
\r
1236 DialogEnableWindow(IDOK, FALSE);
\r
1237 SetPromptApp(&theApp);
\r
1238 theApp.DoWaitCursor(1);
\r
1240 if (PromptShown())
\r
1242 GitDiff diff(this, m_hWnd, true);
\r
1243 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1244 diff.SetHEADPeg(m_LogRevision);
\r
1245 diff.ShowCompare(path, rev2, path, rev1);
\r
1249 CAppUtils::StartShowCompare(m_hWnd, path, rev2, path, rev1, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1252 theApp.DoWaitCursor(-1);
\r
1257 void CGitLogListBase::OnLvnOdfinditemLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
1259 LPNMLVFINDITEM pFindInfo = reinterpret_cast<LPNMLVFINDITEM>(pNMHDR);
\r
1262 if (pFindInfo->lvfi.flags & LVFI_PARAM)
\r
1264 if ((pFindInfo->iStart < 0)||(pFindInfo->iStart >= m_arShownList.GetCount()))
\r
1266 if (pFindInfo->lvfi.psz == 0)
\r
1269 CString sCmp = pFindInfo->lvfi.psz;
\r
1271 for (int i=pFindInfo->iStart; i<m_arShownList.GetCount(); ++i)
\r
1273 GitRev * pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(i));
\r
1274 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1275 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1277 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1285 if (sCmp.Compare(sRev)==0)
\r
1292 if (pFindInfo->lvfi.flags & LVFI_WRAP)
\r
1294 for (int i=0; i<pFindInfo->iStart; ++i)
\r
1296 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1297 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1298 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1300 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1308 if (sCmp.Compare(sRev)==0)
\r
1320 int CGitLogListBase::FillGitLog(CTGitPath *path,int info)
\r
1324 this->m_logEntries.ClearAll();
\r
1325 this->m_logEntries.ParserFromLog(path,-1,info);
\r
1327 //this->m_logEntries.ParserFromLog();
\r
1328 SetItemCountEx(this->m_logEntries.size());
\r
1330 this->m_arShownList.RemoveAll();
\r
1332 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1334 m_logEntries[i].m_IsFull=TRUE;
\r
1335 this->m_arShownList.Add(&m_logEntries[i]);
\r
1344 int CGitLogListBase::FillGitShortLog()
\r
1348 this->m_logEntries.ClearAll();
\r
1350 if(this->m_Path.IsEmpty())
\r
1353 path=&this->m_Path;
\r
1357 mask = CGit::LOG_INFO_ONLY_HASH | CGit::LOG_INFO_BOUNDARY;
\r
1358 if(this->m_bAllBranch)
\r
1359 mask |= CGit::LOG_INFO_ALL_BRANCH;
\r
1361 this->m_logEntries.ParserShortLog(path,hash,-1,mask);
\r
1364 //this->m_logEntries.ParserFromLog();
\r
1365 SetItemCountEx(this->m_logEntries.size());
\r
1367 this->m_arShownList.RemoveAll();
\r
1369 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1370 this->m_arShownList.Add(&m_logEntries[i]);
\r
1375 BOOL CGitLogListBase::PreTranslateMessage(MSG* pMsg)
\r
1377 // Skip Ctrl-C when copying text out of the log message or search filter
\r
1378 BOOL bSkipAccelerator = ( pMsg->message == WM_KEYDOWN && pMsg->wParam=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT) ) && GetKeyState(VK_CONTROL)&0x8000 );
\r
1379 if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')
\r
1381 //if (GetFocus()==GetDlgItem(IDC_LOGLIST))
\r
1383 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1385 DiffSelectedRevWithPrevious();
\r
1390 if (GetFocus()==GetDlgItem(IDC_LOGMSG))
\r
1392 DiffSelectedFile();
\r
1399 if (m_hAccel && !bSkipAccelerator)
\r
1401 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
\r
1407 //m_tooltips.RelayEvent(pMsg);
\r
1408 return __super::PreTranslateMessage(pMsg);
\r
1411 void CGitLogListBase::OnNMDblclkLoglist(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
1413 // a double click on an entry in the revision list has happened
\r
1416 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1417 DiffSelectedRevWithPrevious();
\r
1420 int CGitLogListBase::FetchLogAsync(CALLBACK_PROCESS *proc,void * data)
\r
1422 m_ProcCallBack=proc;
\r
1424 m_bExitThread=FALSE;
\r
1425 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1426 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1427 m_LoadingThread = AfxBeginThread(LogThreadEntry, this);
\r
1428 if (m_LoadingThread ==NULL)
\r
1430 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1431 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1432 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
1438 //this is the thread function which calls the subversion function
\r
1439 UINT CGitLogListBase::LogThreadEntry(LPVOID pVoid)
\r
1441 return ((CGitLogListBase*)pVoid)->LogThread();
\r
1444 void CGitLogListBase::GetTimeRange(CTime &oldest, CTime &latest)
\r
1447 oldest=CTime::GetCurrentTime();
\r
1448 latest=CTime(1971,1,2,0,0,0);
\r
1449 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1451 if(m_logEntries[i].m_AuthorDate.GetTime() < oldest.GetTime())
\r
1452 oldest = m_logEntries[i].m_AuthorDate.GetTime();
\r
1454 if(m_logEntries[i].m_AuthorDate.GetTime() > latest.GetTime())
\r
1455 latest = m_logEntries[i].m_AuthorDate.GetTime();
\r
1460 UINT CGitLogListBase::LogThread()
\r
1463 if(m_ProcCallBack)
\r
1464 m_ProcCallBack(m_ProcData,GITLOG_START);
\r
1466 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1467 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1469 //does the user force the cache to refresh (shift or control key down)?
\r
1470 bool refresh = (GetKeyState (VK_CONTROL) < 0)
\r
1471 || (GetKeyState (VK_SHIFT) < 0);
\r
1473 //disable the "Get All" button while we're receiving
\r
1477 temp.LoadString(IDS_PROGRESSWAIT);
\r
1478 ShowText(temp, true);
\r
1480 FillGitShortLog();
\r
1484 RedrawItems(0, m_arShownList.GetCount());
\r
1486 ResizeAllListCtrlCols();
\r
1489 if ( m_pStoreSelection )
\r
1491 // Deleting the instance will restore the
\r
1492 // selection of the CLogDlg.
\r
1493 delete m_pStoreSelection;
\r
1494 m_pStoreSelection = NULL;
\r
1498 // If no selection has been set then this must be the first time
\r
1499 // the revisions are shown. Let's preselect the topmost revision.
\r
1500 if ( GetItemCount()>0 )
\r
1502 SetSelectionMark(0);
\r
1503 SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
\r
1506 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1509 unsigned int updated=0;
\r
1513 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1515 if(!m_logEntries.FetchFullInfo(i))
\r
1520 percent=updated*98/m_logEntries.size() + GITLOG_START+1;
\r
1521 if(percent == GITLOG_END)
\r
1522 percent = GITLOG_END -1;
\r
1524 if(m_ProcCallBack)
\r
1525 m_ProcCallBack(m_ProcData,percent);
\r
1530 if(updated==m_logEntries.size())
\r
1534 //RefreshCursor();
\r
1535 // make sure the filter is applied (if any) now, after we refreshed/fetched
\r
1536 // the log messages
\r
1540 if(m_ProcCallBack)
\r
1541 m_ProcCallBack(m_ProcData,GITLOG_END);
\r
1543 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1548 void CGitLogListBase::Refresh()
\r
1550 if(!m_bThreadRunning)
\r
1552 this->SetItemCountEx(0);
\r
1553 m_logEntries.clear();
\r
1554 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1555 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1556 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
1558 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1559 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1560 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
1562 m_sFilterText.Empty();
\r
1563 m_From=CTime(1970,1,2,0,0,0);
\r
1564 m_To=CTime::GetCurrentTime();
\r
1567 bool CGitLogListBase::ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase /* = false */)
\r
1571 tr1::regex_constants::syntax_option_type type = tr1::regex_constants::ECMAScript;
\r
1573 type |= tr1::regex_constants::icase;
\r
1574 pat = tr1::wregex(regexp_str, type);
\r
1577 catch (exception) {}
\r
1581 void CGitLogListBase::RecalculateShownList(CPtrArray * pShownlist)
\r
1584 pShownlist->RemoveAll();
\r
1585 tr1::wregex pat;//(_T("Remove"), tr1::regex_constants::icase);
\r
1586 bool bRegex = false;
\r
1587 if (m_bFilterWithRegex)
\r
1588 bRegex = ValidateRegexp(m_sFilterText, pat, false);
\r
1590 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_any;
\r
1592 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
1594 if ((bRegex)&&(m_bFilterWithRegex))
\r
1597 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
1599 ATLTRACE(_T("bugID = \"%s\"\n"), (LPCTSTR)m_logEntries[i]->sBugIDs);
\r
1600 if (regex_search(wstring((LPCTSTR)m_logEntries[i]->sBugIDs), pat, flags)&&IsEntryInDateRange(i))
\r
1602 pShownlist->Add(m_logEntries[i]);
\r
1607 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
1609 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries[i].m_Subject);
\r
1610 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_Subject), pat, flags)&&IsEntryInDateRange(i))
\r
1612 pShownlist->Add(&m_logEntries[i]);
\r
1616 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries[i].m_Body);
\r
1617 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_Body), pat, flags)&&IsEntryInDateRange(i))
\r
1619 pShownlist->Add(&m_logEntries[i]);
\r
1624 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
1626 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
1628 bool bGoing = true;
\r
1629 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
1631 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1632 if (regex_search(wstring((LPCTSTR)cpath->sCopyFromPath), pat, flags)&&IsEntryInDateRange(i))
\r
1634 pShownlist->Add(m_logEntries[i]);
\r
1638 if (regex_search(wstring((LPCTSTR)cpath->sPath), pat, flags)&&IsEntryInDateRange(i))
\r
1640 pShownlist->Add(m_logEntries[i]);
\r
1644 if (regex_search(wstring((LPCTSTR)cpath->GetAction()), pat, flags)&&IsEntryInDateRange(i))
\r
1646 pShownlist->Add(m_logEntries[i]);
\r
1655 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
1657 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_AuthorName), pat, flags)&&IsEntryInDateRange(i))
\r
1659 pShownlist->Add(&m_logEntries[i]);
\r
1663 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
1665 sRev.Format(_T("%ld"), m_logEntries[i].m_CommitHash);
\r
1666 if (regex_search(wstring((LPCTSTR)sRev), pat, flags)&&IsEntryInDateRange(i))
\r
1668 pShownlist->Add(&m_logEntries[i]);
\r
1675 CString find = m_sFilterText;
\r
1678 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
1680 CString sBugIDs = m_logEntries[i]->sBugIDs;
\r
1682 sBugIDs = sBugIDs.MakeLower();
\r
1683 if ((sBugIDs.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
1685 pShownlist->Add(m_logEntries[i]);
\r
1690 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
1692 CString msg = m_logEntries[i].m_Subject;
\r
1694 msg = msg.MakeLower();
\r
1695 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
1697 pShownlist->Add(&m_logEntries[i]);
\r
1700 msg = m_logEntries[i].m_Body;
\r
1702 msg = msg.MakeLower();
\r
1703 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
1705 pShownlist->Add(&m_logEntries[i]);
\r
1710 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
1712 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
1714 bool bGoing = true;
\r
1715 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
1717 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1718 CString path = cpath->sCopyFromPath;
\r
1720 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
1722 pShownlist->Add(m_logEntries[i]);
\r
1726 path = cpath->sPath;
\r
1728 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
1730 pShownlist->Add(m_logEntries[i]);
\r
1734 path = cpath->GetAction();
\r
1736 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
1738 pShownlist->Add(m_logEntries[i]);
\r
1745 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
1747 CString msg = m_logEntries[i].m_AuthorName;
\r
1748 msg = msg.MakeLower();
\r
1749 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
1751 pShownlist->Add(&m_logEntries[i]);
\r
1755 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
1757 sRev.Format(_T("%ld"), m_logEntries[i].m_CommitHash);
\r
1758 if ((sRev.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
1760 pShownlist->Add(&m_logEntries[i]);
\r
1764 } // else (from if (bRegex))
\r
1765 } // for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
1769 BOOL CGitLogListBase::IsEntryInDateRange(int i)
\r
1771 __time64_t time = m_logEntries[i].m_AuthorDate.GetTime();
\r
1772 if ((time >= m_From.GetTime())&&(time <= m_To.GetTime()))
\r
1779 void CGitLogListBase::StartFilter()
\r
1781 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1782 RecalculateShownList(&m_arShownList);
\r
1783 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1787 SetItemCountEx(ShownCountWithStopped());
\r
1788 RedrawItems(0, ShownCountWithStopped());
\r
1790 //ResizeAllListCtrlCols();
\r
1794 void CGitLogListBase::RemoveFilter()
\r
1797 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1799 m_arShownList.RemoveAll();
\r
1801 // reset the time filter too
\r
1803 m_timFrom = (__time64_t(m_tFrom));
\r
1804 m_timTo = (__time64_t(m_tTo));
\r
1805 m_DateFrom.SetTime(&m_timFrom);
\r
1806 m_DateTo.SetTime(&m_timTo);
\r
1807 m_DateFrom.SetRange(&m_timFrom, &m_timTo);
\r
1808 m_DateTo.SetRange(&m_timFrom, &m_timTo);
\r
1811 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
1813 m_arShownList.Add(&m_logEntries[i]);
\r
1815 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1817 SetItemCountEx(ShownCountWithStopped());
\r
1818 RedrawItems(0, ShownCountWithStopped());
\r
1820 ResizeAllListCtrlCols();
\r
1823 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1826 void CGitLogListBase::Clear()
\r
1828 m_arShownList.RemoveAll();
\r
1829 m_logEntries.clear();
\r
1830 m_logEntries.m_HashMap.clear();
\r
1832 m_logEntries.m_Lns.clear();
\r
1834 m_logEntries.m_FirstFreeLane=0;
\r
1835 m_logEntries.m_Lns.clear();
\r