1 // GitLogList.cpp : implementation file
\r
4 Description: qgit revision list view
\r
6 Author: Marco Costalba (C) 2005-2007
\r
8 Copyright: See COPYING file that comes with this distribution
\r
12 #include "GitLogListBase.h"
\r
14 //#include "VssStyle.h"
\r
15 #include "IconMenu.h"
\r
18 #include "InputDlg.h"
\r
19 #include "PropDlg.h"
\r
20 #include "SVNProgressDlg.h"
\r
21 #include "ProgressDlg.h"
\r
22 //#include "RepositoryBrowser.h"
\r
23 //#include "CopyDlg.h"
\r
24 //#include "StatGraphDlg.h"
\r
26 #include "MessageBox.h"
\r
27 #include "Registry.h"
\r
28 #include "AppUtils.h"
\r
29 #include "PathUtils.h"
\r
30 #include "StringUtils.h"
\r
31 #include "UnicodeUtils.h"
\r
32 #include "TempFile.h"
\r
33 //#include "GitInfo.h"
\r
34 //#include "GitDiff.h"
\r
35 #include "IconMenu.h"
\r
36 //#include "RevisionRangeDlg.h"
\r
37 //#include "BrowseFolder.h"
\r
38 //#include "BlameDlg.h"
\r
39 //#include "Blame.h"
\r
40 //#include "GitHelpers.h"
\r
41 #include "GitStatus.h"
\r
42 //#include "LogDlgHelper.h"
\r
43 //#include "CachedLogInfo.h"
\r
44 //#include "RepositoryInfo.h"
\r
45 //#include "EditPropertiesDlg.h"
\r
46 #include "FileDiffDlg.h"
\r
47 #include "..\\TortoiseShell\\Resource.h"
\r
50 IMPLEMENT_DYNAMIC(CGitLogListBase, CHintListCtrl)
\r
52 CGitLogListBase::CGitLogListBase():CHintListCtrl()
\r
53 ,m_regMaxBugIDColWidth(_T("Software\\TortoiseGit\\MaxBugIDColWidth"), 200)
\r
55 ,m_bNoDispUpdates(FALSE)
\r
56 , m_bThreadRunning(FALSE)
\r
57 , m_bStrictStopped(false)
\r
58 , m_pStoreSelection(NULL)
\r
59 , m_nSelectedFilter(LOGFILTER_ALL)
\r
61 // use the default GUI font, create a copy of it and
\r
62 // change the copy to BOLD (leave the rest of the font
\r
64 HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
\r
66 GetObject(hFont, sizeof(LOGFONT), &lf);
\r
67 lf.lfWeight = FW_BOLD;
\r
68 m_boldFont = CreateFontIndirect(&lf);
\r
70 m_bShowBugtraqColumn=0;
\r
72 m_IsIDReplaceAction=FALSE;
\r
74 m_wcRev.m_CommitHash=GIT_REV_ZERO;
\r
75 m_wcRev.m_Subject=_T("Working Copy");
\r
77 m_hModifiedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONMODIFIED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
78 m_hReplacedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONREPLACED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
79 m_hAddedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONADDED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
80 m_hDeletedIcon = (HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ACTIONDELETED), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
\r
82 m_bFilterWithRegex = !!CRegDWORD(_T("Software\\TortoiseGit\\UseRegexFilter"), TRUE);
\r
84 g_Git.GetMapHashToFriendName(m_HashMap);
\r
85 m_CurrentBranch=g_Git.GetCurrentBranch();
\r
87 m_From=CTime(1970,1,2,0,0,0);
\r
88 m_To=CTime::GetCurrentTime();
\r
90 m_LoadingThread = NULL;
\r
92 m_bExitThread=FALSE;
\r
93 m_IsOldFirst = FALSE;
\r
94 m_IsRebaseReplaceGraph = FALSE;
\r
97 for(int i=0;i<Lanes::COLORS_NUM;i++)
\r
99 m_LineColors[i] = m_Colors.GetColor((CColors::Colors)(CColors::BranchLine1+i));
\r
101 // get short/long datetime setting from registry
\r
102 DWORD RegUseShortDateFormat = CRegDWORD(_T("Software\\TortoiseGit\\LogDateFormat"), TRUE);
\r
103 if ( RegUseShortDateFormat )
\r
105 m_DateFormat = DATE_SHORTDATE;
\r
109 m_DateFormat = DATE_LONGDATE;
\r
111 // get relative time display setting from registry
\r
112 DWORD regRelativeTimes = CRegDWORD(_T("Software\\TortoiseGit\\RelativeTimes"), FALSE);
\r
113 m_bRelativeTimes = (regRelativeTimes != 0);
\r
114 m_ContextMenuMask = 0xFFFFFFFFFFFFFFFF;
\r
116 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_PICK);
\r
117 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_SQUASH);
\r
118 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_EDIT);
\r
119 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_SKIP);
\r
122 CGitLogListBase::~CGitLogListBase()
\r
124 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
126 DestroyIcon(m_hModifiedIcon);
\r
127 DestroyIcon(m_hReplacedIcon);
\r
128 DestroyIcon(m_hAddedIcon);
\r
129 DestroyIcon(m_hDeletedIcon);
\r
130 m_logEntries.ClearAll();
\r
133 DeleteObject(m_boldFont);
\r
135 if ( m_pStoreSelection )
\r
137 delete m_pStoreSelection;
\r
138 m_pStoreSelection = NULL;
\r
141 if(this->m_bThreadRunning)
\r
143 m_bExitThread=true;
\r
144 WaitForSingleObject(m_LoadingThread->m_hThread,1000);
\r
150 BEGIN_MESSAGE_MAP(CGitLogListBase, CHintListCtrl)
\r
151 ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnNMCustomdrawLoglist)
\r
152 ON_NOTIFY_REFLECT(LVN_GETDISPINFO, OnLvnGetdispinfoLoglist)
\r
153 ON_WM_CONTEXTMENU()
\r
154 ON_NOTIFY_REFLECT(NM_DBLCLK, OnNMDblclkLoglist)
\r
155 ON_NOTIFY_REFLECT(LVN_ODFINDITEM,OnLvnOdfinditemLoglist)
\r
158 ON_MESSAGE(MSG_LOADED,OnLoad)
\r
161 int CGitLogListBase:: OnCreate(LPCREATESTRUCT lpCreateStruct)
\r
163 PreSubclassWindow();
\r
164 return CHintListCtrl::OnCreate(lpCreateStruct);
\r
167 void CGitLogListBase::PreSubclassWindow()
\r
169 SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES);
\r
170 // load the icons for the action columns
\r
171 m_Theme.SetWindowTheme(GetSafeHwnd(), L"Explorer", NULL);
\r
172 CHintListCtrl::PreSubclassWindow();
\r
175 void CGitLogListBase::InsertGitColumn()
\r
179 int c = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;
\r
183 temp.LoadString(IDS_LOG_GRAPH);
\r
185 if(m_IsRebaseReplaceGraph)
\r
191 temp.LoadString(IDS_LOG_GRAPH);
\r
193 InsertColumn(this->LOGLIST_GRAPH, temp);
\r
196 // make the revision column right aligned
\r
198 Column.mask = LVCF_FMT;
\r
199 Column.fmt = LVCFMT_RIGHT;
\r
200 SetColumn(0, &Column);
\r
203 // g_Git.GetLog(log);
\r
205 if(m_IsIDReplaceAction)
\r
207 temp.LoadString(IDS_LOG_ID);
\r
208 InsertColumn(this->LOGLIST_ACTION, temp);
\r
212 temp.LoadString(IDS_LOG_ACTIONS);
\r
213 InsertColumn(this->LOGLIST_ACTION, temp);
\r
215 temp.LoadString(IDS_LOG_MESSAGE);
\r
216 InsertColumn(this->LOGLIST_MESSAGE, temp);
\r
218 temp.LoadString(IDS_LOG_AUTHOR);
\r
219 InsertColumn(this->LOGLIST_AUTHOR, temp);
\r
221 temp.LoadString(IDS_LOG_DATE);
\r
222 InsertColumn(this->LOGLIST_DATE, temp);
\r
225 if (m_bShowBugtraqColumn)
\r
227 // temp = m_ProjectProperties.sLabel;
\r
228 if (temp.IsEmpty())
\r
229 temp.LoadString(IDS_LOG_BUGIDS);
\r
230 InsertColumn(this->LOGLIST_BUG, temp);
\r
235 ResizeAllListCtrlCols();
\r
241 * Resizes all columns in a list control to values in registry.
\r
243 void CGitLogListBase::ResizeAllListCtrlCols()
\r
245 // column max and min widths to allow
\r
246 static const int nMinimumWidth = 10;
\r
247 static const int nMaximumWidth = 1000;
\r
248 CHeaderCtrl* pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0));
\r
251 int numcols = pHdrCtrl->GetItemCount();
\r
252 for (int col = 0; col < numcols; col++)
\r
254 // get width for this col last time from registry
\r
256 regentry.Format( _T("Software\\TortoiseGit\\log\\ColWidth%d"), col);
\r
257 CRegDWORD regwidth(regentry, 0);
\r
261 // no saved value, setup sensible defaults
\r
262 if (col == this->LOGLIST_MESSAGE)
\r
264 cx = LOGLIST_MESSAGE_MIN;
\r
268 cx = ICONITEMBORDER+16*4;
\r
271 if (cx < nMinimumWidth)
\r
273 cx = nMinimumWidth;
\r
274 } else if (cx > nMaximumWidth)
\r
276 cx = nMaximumWidth;
\r
279 SetColumnWidth(col, cx);
\r
286 BOOL CGitLogListBase::GetShortName(CString ref, CString &shortname,CString prefix)
\r
288 TRACE(_T("%s %s\r\n"),ref,prefix);
\r
289 if(ref.Left(prefix.GetLength()) == prefix)
\r
291 shortname = ref.Right(ref.GetLength()-prefix.GetLength());
\r
292 if(shortname.Right(3)==_T("^{}"))
\r
293 shortname=shortname.Left(shortname.GetLength()-3);
\r
298 void CGitLogListBase::FillBackGround(HDC hdc, int Index,CRect &rect)
\r
302 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
303 rItem.mask = LVIF_STATE;
\r
304 rItem.iItem = Index;
\r
305 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
308 GitRev* pLogEntry = (GitRev*)m_arShownList.GetAt(Index);
\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 if(pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_SQUASH)
\r
364 brush = ::CreateSolidBrush(RGB(156,156,156));
\r
365 else if(pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT)
\r
366 brush = ::CreateSolidBrush(RGB(200,200,128));
\r
368 brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW));
\r
373 ::FillRect(hdc, &rect, brush);
\r
374 ::DeleteObject(brush);
\r
379 void CGitLogListBase::DrawTagBranch(HDC hdc,CRect &rect,INT_PTR index)
\r
381 GitRev* data = (GitRev*)m_arShownList.GetAt(index);
\r
384 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
385 rItem.mask = LVIF_STATE;
\r
386 rItem.iItem = index;
\r
387 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
390 for(unsigned int i=0;i<m_HashMap[data->m_CommitHash].size();i++)
\r
393 str=m_HashMap[data->m_CommitHash][i];
\r
398 if(GetShortName(str,shortname,_T("refs/heads/")))
\r
400 if( shortname == m_CurrentBranch )
\r
401 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::CurrentBranch));
\r
403 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::LocalBranch));
\r
405 }else if(GetShortName(str,shortname,_T("refs/remotes/")))
\r
407 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::RemoteBranch));
\r
409 else if(GetShortName(str,shortname,_T("refs/tags/")))
\r
411 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::Tag));
\r
414 if(!shortname.IsEmpty())
\r
417 memset(&size,0,sizeof(SIZE));
\r
418 GetTextExtentPoint32(hdc, shortname,shortname.GetLength(),&size);
\r
420 rt.SetRect(rt.left,rt.top,rt.left+size.cx,rt.bottom);
\r
422 ::FillRect(hdc, &rt, brush);
\r
423 if (rItem.state & LVIS_SELECTED)
\r
425 COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT));
\r
426 ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER);
\r
427 ::SetTextColor(hdc,clrOld);
\r
430 ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER);
\r
434 ::MoveToEx(hdc,rt.left,rt.top,NULL);
\r
435 ::LineTo(hdc,rt.right,rt.top);
\r
436 ::LineTo(hdc,rt.right,rt.bottom);
\r
437 ::LineTo(hdc,rt.left,rt.bottom);
\r
438 ::LineTo(hdc,rt.left,rt.top);
\r
440 rt.left=rt.right+3;
\r
443 ::DeleteObject(brush);
\r
445 rt.right=rect.right;
\r
447 if (rItem.state & LVIS_SELECTED)
\r
449 COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT));
\r
450 ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT);
\r
451 ::SetTextColor(hdc,clrOld);
\r
454 ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT);
\r
459 void CGitLogListBase::paintGraphLane(HDC hdc, int laneHeight,int type, int x1, int x2,
\r
460 const COLORREF& col,int top
\r
463 int h = laneHeight / 2;
\r
464 int m = (x1 + x2) / 2;
\r
465 int r = (x2 - x1) / 3;
\r
468 #define P_CENTER m , h+top
\r
469 #define P_0 x2, h+top
\r
470 #define P_90 m , 0+top
\r
471 #define P_180 x1, h+top
\r
472 #define P_270 m , 2 * h+top
\r
473 #define R_CENTER m - r, h - r+top, m - r+d, h - r+top+d
\r
475 //static QPen myPen(Qt::black, 2); // fast path here
\r
477 pen.CreatePen(PS_SOLID,2,col);
\r
478 //myPen.setColor(col);
\r
479 HPEN oldpen=(HPEN)::SelectObject(hdc,(HPEN)pen);
\r
481 //p->setPen(myPen);
\r
485 case Lanes::ACTIVE:
\r
486 case Lanes::NOT_ACTIVE:
\r
487 case Lanes::MERGE_FORK:
\r
488 case Lanes::MERGE_FORK_R:
\r
489 case Lanes::MERGE_FORK_L:
\r
491 case Lanes::JOIN_R:
\r
492 case Lanes::JOIN_L:
\r
493 DrawLine(hdc,P_90,P_270);
\r
494 //p->drawLine(P_90, P_270);
\r
497 case Lanes::HEAD_R:
\r
498 case Lanes::HEAD_L:
\r
499 case Lanes::BRANCH:
\r
500 DrawLine(hdc,P_CENTER,P_270);
\r
501 //p->drawLine(P_CENTER, P_270);
\r
504 case Lanes::TAIL_R:
\r
505 case Lanes::TAIL_L:
\r
506 case Lanes::INITIAL:
\r
507 case Lanes::BOUNDARY:
\r
508 case Lanes::BOUNDARY_C:
\r
509 case Lanes::BOUNDARY_R:
\r
510 case Lanes::BOUNDARY_L:
\r
511 DrawLine(hdc,P_90, P_CENTER);
\r
512 //p->drawLine(P_90, P_CENTER);
\r
520 case Lanes::MERGE_FORK:
\r
525 case Lanes::CROSS_EMPTY:
\r
526 case Lanes::BOUNDARY_C:
\r
527 DrawLine(hdc,P_180,P_0);
\r
528 //p->drawLine(P_180, P_0);
\r
530 case Lanes::MERGE_FORK_R:
\r
531 case Lanes::JOIN_R:
\r
532 case Lanes::HEAD_R:
\r
533 case Lanes::TAIL_R:
\r
534 case Lanes::BOUNDARY_R:
\r
535 DrawLine(hdc,P_180,P_CENTER);
\r
536 //p->drawLine(P_180, P_CENTER);
\r
538 case Lanes::MERGE_FORK_L:
\r
539 case Lanes::JOIN_L:
\r
540 case Lanes::HEAD_L:
\r
541 case Lanes::TAIL_L:
\r
542 case Lanes::BOUNDARY_L:
\r
543 DrawLine(hdc,P_CENTER,P_0);
\r
544 //p->drawLine(P_CENTER, P_0);
\r
551 brush.CreateSolidBrush(col);
\r
552 HBRUSH oldbrush=(HBRUSH)::SelectObject(hdc,(HBRUSH)brush);
\r
553 // center symbol, e.g. rect or ellipse
\r
555 case Lanes::ACTIVE:
\r
556 case Lanes::INITIAL:
\r
557 case Lanes::BRANCH:
\r
559 //p->setPen(Qt::NoPen);
\r
560 //p->setBrush(col);
\r
561 ::Ellipse(hdc, R_CENTER);
\r
562 //p->drawEllipse(R_CENTER);
\r
564 case Lanes::MERGE_FORK:
\r
565 case Lanes::MERGE_FORK_R:
\r
566 case Lanes::MERGE_FORK_L:
\r
567 //p->setPen(Qt::NoPen);
\r
568 //p->setBrush(col);
\r
569 //p->drawRect(R_CENTER);
\r
570 Rectangle(hdc,R_CENTER);
\r
572 case Lanes::UNAPPLIED:
\r
574 //p->setPen(Qt::NoPen);
\r
575 //p->setBrush(Qt::red);
\r
576 //p->drawRect(m - r, h - 1, d, 2);
\r
577 ::Rectangle(hdc,m-r,h-1,d,2);
\r
579 case Lanes::APPLIED:
\r
581 //p->setPen(Qt::NoPen);
\r
582 //p->setBrush(DARK_GREEN);
\r
583 //p->drawRect(m - r, h - 1, d, 2);
\r
584 //p->drawRect(m - 1, h - r, 2, d);
\r
585 ::Rectangle(hdc,m-r,h-1,d,2);
\r
586 ::Rectangle(hdc,m-1,h-r,2,d);
\r
588 case Lanes::BOUNDARY:
\r
589 //p->setBrush(back);
\r
590 //p->drawEllipse(R_CENTER);
\r
591 ::Ellipse(hdc, R_CENTER);
\r
593 case Lanes::BOUNDARY_C:
\r
594 case Lanes::BOUNDARY_R:
\r
595 case Lanes::BOUNDARY_L:
\r
596 //p->setBrush(back);
\r
597 //p->drawRect(R_CENTER);
\r
598 ::Rectangle(hdc,R_CENTER);
\r
604 ::SelectObject(hdc,oldpen);
\r
605 ::SelectObject(hdc,oldbrush);
\r
614 void CGitLogListBase::DrawGraph(HDC hdc,CRect &rect,INT_PTR index)
\r
618 GitRev* data = (GitRev*)m_arShownList.GetAt(index);
\r
621 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
622 rItem.mask = LVIF_STATE;
\r
623 rItem.iItem = index;
\r
624 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
628 // p->translate(QPoint(opt.rect.left(), opt.rect.top()));
\r
632 if (data->m_Lanes.size() == 0)
\r
633 m_logEntries.setLane(data->m_CommitHash);
\r
635 std::vector<int>& lanes=data->m_Lanes;
\r
636 UINT laneNum = lanes.size();
\r
637 UINT mergeLane = 0;
\r
638 for (UINT i = 0; i < laneNum; i++)
\r
639 if (Lanes::isMerge(lanes[i])) {
\r
644 int x1 = 0, x2 = 0;
\r
645 int maxWidth = rect.Width();
\r
646 int lw = 3 * rect.Height() / 4; //laneWidth()
\r
647 for (UINT i = 0; i < laneNum && x2 < maxWidth; i++) {
\r
653 if (ln == Lanes::EMPTY)
\r
656 UINT col = ( Lanes:: isHead(ln) ||Lanes:: isTail(ln) || Lanes::isJoin(ln)
\r
657 || ln ==Lanes:: CROSS_EMPTY) ? mergeLane : i;
\r
659 if (ln == Lanes::CROSS) {
\r
660 paintGraphLane(hdc, rect.Height(),Lanes::NOT_ACTIVE, x1, x2, m_LineColors[col % Lanes::COLORS_NUM],rect.top);
\r
661 paintGraphLane(hdc, rect.Height(),Lanes::CROSS, x1, x2, m_LineColors[mergeLane % Lanes::COLORS_NUM],rect.top);
\r
663 paintGraphLane(hdc, rect.Height(),ln, x1, x2, m_LineColors[col % Lanes::COLORS_NUM],rect.top);
\r
666 TRACE(_T("index %d %d\r\n"),index,data->m_Lanes.size());
\r
669 void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
672 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
\r
673 // Take the default processing unless we set this to something else below.
\r
674 *pResult = CDRF_DODEFAULT;
\r
676 if (m_bNoDispUpdates)
\r
681 switch (pLVCD->nmcd.dwDrawStage)
\r
683 case CDDS_PREPAINT:
\r
685 *pResult = CDRF_NOTIFYITEMDRAW;
\r
689 case CDDS_ITEMPREPAINT:
\r
691 // This is the prepaint stage for an item. Here's where we set the
\r
692 // item's text color.
\r
694 // Tell Windows to send draw notifications for each subitem.
\r
695 *pResult = CDRF_NOTIFYSUBITEMDRAW;
\r
697 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
\r
699 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
701 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
705 if (data->bCopiedSelf)
\r
707 // only change the background color if the item is not 'hot' (on vista with m_Themes enabled)
\r
708 if (!m_Theme.IsAppm_Themed() || !m_bVista || ((pLVCD->nmcd.uItemState & CDIS_HOT)==0))
\r
709 pLVCD->clrTextBk = GetSysColor(COLOR_MENU);
\r
713 crText = m_Colors.GetColor(CColors::Modified);
\r
715 if (data->m_Action& (CTGitPath::LOGACTIONS_REBASE_DONE| CTGitPath::LOGACTIONS_REBASE_SKIP) )
\r
716 crText = RGB(128,128,128);
\r
718 if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_SQUASH)
\r
719 pLVCD->clrTextBk = RGB(156,156,156);
\r
720 else if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT)
\r
721 pLVCD->clrTextBk = RGB(200,200,128);
\r
723 pLVCD->clrTextBk = ::GetSysColor(COLOR_WINDOW);
\r
725 if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_CURRENT)
\r
727 SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
728 *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
731 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
\r
732 // crText = GetSysColor(COLOR_GRAYTEXT);
\r
733 // if (data->Rev == m_wcRev)
\r
735 // SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
736 // We changed the font, so we're returning CDRF_NEWFONT. This
\r
737 // tells the control to recalculate the extent of the text.
\r
738 // *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
742 if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
744 if (m_bStrictStopped)
\r
745 crText = GetSysColor(COLOR_GRAYTEXT);
\r
747 // Store the color back in the NMLVCUSTOMDRAW struct.
\r
748 pLVCD->clrText = crText;
\r
752 case CDDS_ITEMPREPAINT|CDDS_ITEM|CDDS_SUBITEM:
\r
754 if ((m_bStrictStopped)&&(m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec))
\r
756 pLVCD->nmcd.uItemState &= ~(CDIS_SELECTED|CDIS_FOCUS);
\r
759 if (pLVCD->iSubItem == LOGLIST_GRAPH)
\r
761 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec && (!this->m_IsRebaseReplaceGraph) )
\r
764 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
766 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
767 DrawGraph(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
\r
769 *pResult = CDRF_SKIPDEFAULT;
\r
775 if (pLVCD->iSubItem == LOGLIST_MESSAGE)
\r
777 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
779 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
780 //if(!data->m_IsFull)
\r
782 //if(data->SafeFetchFullInfo(&g_Git))
\r
783 // this->Invalidate();
\r
784 //TRACE(_T("Update ... %d\r\n"),pLVCD->nmcd.dwItemSpec);
\r
787 if(m_HashMap[data->m_CommitHash].size()!=0)
\r
791 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
793 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
794 DrawTagBranch(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
\r
796 *pResult = CDRF_SKIPDEFAULT;
\r
803 if (pLVCD->iSubItem == 1)
\r
805 if(this->m_IsIDReplaceAction)
\r
807 *pResult = CDRF_DODEFAULT;
\r
810 *pResult = CDRF_DODEFAULT;
\r
812 if (m_arShownList.GetCount() <= (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
816 int iconwidth = ::GetSystemMetrics(SM_CXSMICON);
\r
817 int iconheight = ::GetSystemMetrics(SM_CYSMICON);
\r
819 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec));
\r
821 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
822 // Get the selected state of the
\r
823 // item being drawn.
\r
825 // Fill the background
\r
826 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
828 // Draw the icon(s) into the compatible DC
\r
829 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_MODIFIED)
\r
830 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left + ICONITEMBORDER, rect.top, m_hModifiedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
833 if (pLogEntry->m_Action & (CTGitPath::LOGACTIONS_ADDED|CTGitPath::LOGACTIONS_COPY) )
\r
834 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hAddedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
837 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_DELETED)
\r
838 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hDeletedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
841 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_REPLACED)
\r
842 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hReplacedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
844 *pResult = CDRF_SKIPDEFAULT;
\r
850 *pResult = CDRF_DODEFAULT;
\r
854 // CGitLogListBase message handlers
\r
856 void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
858 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
\r
860 // Create a pointer to the item
\r
861 LV_ITEM* pItem = &(pDispInfo)->item;
\r
863 // Do the list need text information?
\r
864 if (!(pItem->mask & LVIF_TEXT))
\r
867 // By default, clear text buffer.
\r
868 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
870 bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();
\r
873 if (m_bNoDispUpdates || bOutOfRange)
\r
876 // Which item number?
\r
877 int itemid = pItem->iItem;
\r
878 GitRev * pLogEntry = NULL;
\r
879 if (itemid < m_arShownList.GetCount())
\r
880 pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(pItem->iItem));
\r
885 temp.Format(_T("%d"),pItem->iItem+1);
\r
889 temp.Format(_T("%d"),m_arShownList.GetCount()-pItem->iItem);
\r
893 switch (pItem->iSubItem)
\r
895 case this->LOGLIST_GRAPH: //Graphic
\r
898 if(this->m_IsRebaseReplaceGraph)
\r
901 path.m_Action=pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_MODE_MASK;
\r
903 lstrcpyn(pItem->pszText,path.GetActionName(), pItem->cchTextMax);
\r
907 case this->LOGLIST_ACTION: //action -- no text in the column
\r
908 if(this->m_IsIDReplaceAction)
\r
909 lstrcpyn(pItem->pszText, temp, pItem->cchTextMax);
\r
911 case this->LOGLIST_MESSAGE: //Message
\r
913 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_Subject, pItem->cchTextMax);
\r
915 case this->LOGLIST_AUTHOR: //Author
\r
917 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorName, pItem->cchTextMax);
\r
919 case this->LOGLIST_DATE: //Date
\r
921 lstrcpyn(pItem->pszText,
\r
922 CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat, true, m_bRelativeTimes ),
\r
923 pItem->cchTextMax);
\r
934 void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point)
\r
937 int selIndex = GetSelectionMark();
\r
939 return; // nothing selected, nothing to do with a context menu
\r
941 // if the user selected the info text telling about not all revisions shown due to
\r
942 // the "stop on copy/rename" option, we also don't show the context menu
\r
943 if ((m_bStrictStopped)&&(selIndex == m_arShownList.GetCount()))
\r
946 // if the context menu is invoked through the keyboard, we have to use
\r
947 // a calculated position on where to anchor the menu on
\r
948 if ((point.x == -1) && (point.y == -1))
\r
951 GetItemRect(selIndex, &rect, LVIR_LABEL);
\r
952 ClientToScreen(&rect);
\r
953 point = rect.CenterPoint();
\r
955 m_nSearchIndex = selIndex;
\r
956 m_bCancelled = FALSE;
\r
958 // calculate some information the context menu commands can use
\r
959 // CString pathURL = GetURLFromPath(m_path);
\r
961 POSITION pos = GetFirstSelectedItemPosition();
\r
962 int indexNext = GetNextSelectedItem(pos);
\r
966 GitRev* pSelLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(indexNext));
\r
968 GitRev revSelected = pSelLogEntry->Rev;
\r
969 GitRev revPrevious = git_revnum_t(revSelected)-1;
\r
970 if ((pSelLogEntry->pArChangedPaths)&&(pSelLogEntry->pArChangedPaths->GetCount() <= 2))
\r
972 for (int i=0; i<pSelLogEntry->pArChangedPaths->GetCount(); ++i)
\r
974 LogChangedPath * changedpath = (LogChangedPath *)pSelLogEntry->pArChangedPaths->GetAt(i);
\r
975 if (changedpath->lCopyFromRev)
\r
976 revPrevious = changedpath->lCopyFromRev;
\r
979 GitRev revSelected2;
\r
982 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
983 revSelected2 = pLogEntry->Rev;
\r
985 bool bAllFromTheSameAuthor = true;
\r
986 CString firstAuthor;
\r
987 CLogDataVector selEntries;
\r
988 GitRev revLowest, revHighest;
\r
989 GitRevRangeArray revisionRanges;
\r
991 POSITION pos = GetFirstSelectedItemPosition();
\r
992 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
993 revisionRanges.AddRevision(pLogEntry->Rev);
\r
994 selEntries.push_back(pLogEntry);
\r
995 firstAuthor = pLogEntry->sAuthor;
\r
996 revLowest = pLogEntry->Rev;
\r
997 revHighest = pLogEntry->Rev;
\r
1000 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1001 revisionRanges.AddRevision(pLogEntry->Rev);
\r
1002 selEntries.push_back(pLogEntry);
\r
1003 if (firstAuthor.Compare(pLogEntry->sAuthor))
\r
1004 bAllFromTheSameAuthor = false;
\r
1005 revLowest = (git_revnum_t(pLogEntry->Rev) > git_revnum_t(revLowest) ? revLowest : pLogEntry->Rev);
\r
1006 revHighest = (git_revnum_t(pLogEntry->Rev) < git_revnum_t(revHighest) ? revHighest : pLogEntry->Rev);
\r
1012 int FirstSelect=-1, LastSelect=-1;
\r
1013 pos = GetFirstSelectedItemPosition();
\r
1014 FirstSelect = GetNextSelectedItem(pos);
\r
1017 LastSelect = GetNextSelectedItem(pos);
\r
1019 //entry is selected, now show the popup menu
\r
1021 if (popup.CreatePopupMenu())
\r
1024 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_PICK))
\r
1025 popup.AppendMenuIcon(ID_REBASE_PICK, _T("Pick"), IDI_OPEN);
\r
1027 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_SQUASH))
\r
1028 popup.AppendMenuIcon(ID_REBASE_SQUASH, _T("Squash"), IDI_OPEN);
\r
1030 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_EDIT))
\r
1031 popup.AppendMenuIcon(ID_REBASE_EDIT, _T("Edit"), IDI_OPEN);
\r
1033 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_SKIP))
\r
1034 popup.AppendMenuIcon(ID_REBASE_SKIP, _T("SKIP"), IDI_OPEN);
\r
1036 if(m_ContextMenuMask&(GetContextMenuBit(ID_REBASE_SKIP)|GetContextMenuBit(ID_REBASE_EDIT)|
\r
1037 GetContextMenuBit(ID_REBASE_SQUASH)|GetContextMenuBit(ID_REBASE_PICK)))
\r
1038 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1040 if (GetSelectedCount() == 1)
\r
1043 if (!m_path.IsDirectory())
\r
1047 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
1048 popup.AppendMenuIcon(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
1050 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
1051 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
1052 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1053 popup.AppendMenuIcon(ID_SAVEAS, IDS_LOG_POPUP_SAVE, IDI_SAVEAS);
\r
1054 popup.AppendMenuIcon(ID_OPEN, IDS_LOG_POPUP_OPEN, IDI_OPEN);
\r
1055 popup.AppendMenuIcon(ID_OPENWITH, IDS_LOG_POPUP_OPENWITH, IDI_OPEN);
\r
1056 popup.AppendMenuIcon(ID_BLAME, IDS_LOG_POPUP_BLAME, IDI_BLAME);
\r
1057 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1064 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPARE))
\r
1065 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
1067 // TortoiseMerge could be improved to take a /blame switch
\r
1068 // and then not 'cat' the files from a unified diff but
\r
1070 // But until that's implemented, the context menu entry for
\r
1071 // this feature is commented out.
\r
1072 //popup.AppendMenu(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
1074 if(m_ContextMenuMask&GetContextMenuBit(ID_GNUDIFF1))
\r
1075 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
1077 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPAREWITHPREVIOUS))
\r
1078 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
1079 //popup.AppendMenuIcon(ID_BLAMEWITHPREVIOUS, IDS_LOG_POPUP_BLAMEWITHPREVIOUS, IDI_BLAME);
\r
1080 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1083 // if (!m_ProjectProperties.sWebViewerRev.IsEmpty())
\r
1085 // popup.AppendMenuIcon(ID_VIEWREV, IDS_LOG_POPUP_VIEWREV);
\r
1087 // if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
\r
1089 // popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
\r
1091 // if ((!m_ProjectProperties.sWebViewerPathRev.IsEmpty())||
\r
1092 // (!m_ProjectProperties.sWebViewerRev.IsEmpty()))
\r
1094 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1098 // popup.AppendMenuIcon(ID_REVERTTOREV, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT);
\r
1100 // popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT);
\r
1102 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREV, IDI_MERGE);
\r
1105 str.Format(_T("Reset %s to this"),g_Git.GetCurrentBranch());
\r
1107 if(m_ContextMenuMask&GetContextMenuBit(ID_RESET))
\r
1108 popup.AppendMenuIcon(ID_RESET,str,IDI_REVERT);
\r
1110 if(m_ContextMenuMask&GetContextMenuBit(ID_SWITCHTOREV))
\r
1111 popup.AppendMenuIcon(ID_SWITCHTOREV, _T("Switch/Checkout to this") , IDI_SWITCH);
\r
1113 if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_BRANCH))
\r
1114 popup.AppendMenuIcon(ID_CREATE_BRANCH, _T("Create Branch at this version") , IDI_COPY);
\r
1116 if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_TAG))
\r
1117 popup.AppendMenuIcon(ID_CREATE_TAG, _T("Create Tag at this version"), IDI_COPY);
\r
1119 if(m_ContextMenuMask&GetContextMenuBit(ID_CHERRY_PICK))
\r
1120 popup.AppendMenuIcon(ID_CHERRY_PICK, _T("Cherry Pick this version"), IDI_EXPORT);
\r
1122 if(m_ContextMenuMask&GetContextMenuBit(ID_EXPORT))
\r
1123 popup.AppendMenuIcon(ID_EXPORT, _T("Export this version"), IDI_EXPORT);
\r
1126 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1128 else if (GetSelectedCount() >= 2)
\r
1130 bool bAddSeparator = false;
\r
1131 if (IsSelectionContinuous() || (GetSelectedCount() == 2))
\r
1133 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPARETWO))
\r
1134 popup.AppendMenuIcon(ID_COMPARETWO, IDS_LOG_POPUP_COMPARETWO, IDI_DIFF);
\r
1137 if (GetSelectedCount() == 2)
\r
1139 //popup.AppendMenuIcon(ID_BLAMETWO, IDS_LOG_POPUP_BLAMEREVS, IDI_BLAME);
\r
1140 if(m_ContextMenuMask&GetContextMenuBit(ID_GNUDIFF2))
\r
1141 popup.AppendMenuIcon(ID_GNUDIFF2, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);
\r
1142 bAddSeparator = true;
\r
1145 if ( IsSelectionContinuous() )
\r
1147 if(m_ContextMenuMask&GetContextMenuBit(ID_COMBINE_COMMIT))
\r
1150 head.Format(_T("HEAD~%d"),LastSelect);
\r
1151 CString hash=g_Git.GetHash(head);
\r
1152 hash=hash.Left(40);
\r
1153 GitRev* pLastEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(LastSelect));
\r
1154 if(pLastEntry->m_CommitHash == hash)
\r
1155 popup.AppendMenuIcon(ID_COMBINE_COMMIT,_T("Combine to one commit"),IDI_MERGE);
\r
1160 //popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREVS, IDI_REVERT);
\r
1162 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREVS, IDI_MERGE);
\r
1163 bAddSeparator = true;
\r
1165 if (bAddSeparator)
\r
1166 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1169 // if ((selEntries.size() > 0)&&(bAllFromTheSameAuthor))
\r
1171 // popup.AppendMenuIcon(ID_EDITAUTHOR, IDS_LOG_POPUP_EDITAUTHOR);
\r
1173 // if (GetSelectedCount() == 1)
\r
1175 // popup.AppendMenuIcon(ID_EDITLOG, IDS_LOG_POPUP_EDITLOG);
\r
1176 // popup.AppendMenuIcon(ID_REVPROPS, IDS_REPOBROWSE_SHOWREVPROP, IDI_PROPERTIES); // "Show Revision Properties"
\r
1177 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1182 if (GetSelectedCount() == 1)
\r
1184 if(m_ContextMenuMask&GetContextMenuBit(ID_COPYHASH))
\r
1185 popup.AppendMenuIcon(ID_COPYHASH, _T("Copy Commit Hash"));
\r
1187 if (GetSelectedCount() != 0)
\r
1189 if(m_ContextMenuMask&GetContextMenuBit(ID_COPYCLIPBOARD))
\r
1190 popup.AppendMenuIcon(ID_COPYCLIPBOARD, IDS_LOG_POPUP_COPYTOCLIPBOARD);
\r
1193 if(m_ContextMenuMask&GetContextMenuBit(ID_FINDENTRY))
\r
1194 popup.AppendMenuIcon(ID_FINDENTRY, IDS_LOG_POPUP_FIND);
\r
1196 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
1197 // DialogEnableWindow(IDOK, FALSE);
\r
1198 // SetPromptApp(&theApp);
\r
1200 this->ContextMenuAction(cmd, FirstSelect, LastSelect);
\r
1202 // EnableOKButton();
\r
1203 } // if (popup.CreatePopupMenu())
\r
1207 bool CGitLogListBase::IsSelectionContinuous()
\r
1209 if ( GetSelectedCount()==1 )
\r
1211 // if only one revision is selected, the selection is of course
\r
1216 POSITION pos = GetFirstSelectedItemPosition();
\r
1217 bool bContinuous = (m_arShownList.GetCount() == (INT_PTR)m_logEntries.size());
\r
1220 int itemindex = GetNextSelectedItem(pos);
\r
1223 int nextindex = GetNextSelectedItem(pos);
\r
1224 if (nextindex - itemindex > 1)
\r
1226 bContinuous = false;
\r
1229 itemindex = nextindex;
\r
1232 return bContinuous;
\r
1235 void CGitLogListBase::CopySelectionToClipBoard(bool HashOnly)
\r
1238 CString sClipdata;
\r
1239 POSITION pos = GetFirstSelectedItemPosition();
\r
1243 sRev.LoadString(IDS_LOG_REVISION);
\r
1245 sAuthor.LoadString(IDS_LOG_AUTHOR);
\r
1247 sDate.LoadString(IDS_LOG_DATE);
\r
1249 sMessage.LoadString(IDS_LOG_MESSAGE);
\r
1252 CString sLogCopyText;
\r
1254 GitRev * pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1258 //pLogEntry->m_Files
\r
1259 //LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1261 for (int cpPathIndex = 0; cpPathIndex<pLogEntry->m_Files.GetCount(); ++cpPathIndex)
\r
1263 sPaths += ((CTGitPath&)pLogEntry->m_Files[cpPathIndex]).GetActionName() + _T(" : ") + pLogEntry->m_Files[cpPathIndex].GetGitPathString();
\r
1264 sPaths += _T("\r\n");
\r
1267 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
1268 (LPCTSTR)sRev, pLogEntry->m_CommitHash,
\r
1269 (LPCTSTR)sAuthor, (LPCTSTR)pLogEntry->m_AuthorName,
\r
1271 (LPCTSTR)CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat, true, m_bRelativeTimes ),
\r
1272 (LPCTSTR)sMessage, pLogEntry->m_Subject+_T("\r\n")+pLogEntry->m_Body,
\r
1274 sClipdata += sLogCopyText;
\r
1277 sClipdata += pLogEntry->m_CommitHash;
\r
1282 CStringUtils::WriteAsciiStringToClipboard(sClipdata, GetSafeHwnd());
\r
1287 void CGitLogListBase::DiffSelectedRevWithPrevious()
\r
1290 if (m_bThreadRunning)
\r
1292 UpdateLogInfoLabel();
\r
1293 int selIndex = m_LogList.GetSelectionMark();
\r
1296 int selCount = m_LogList.GetSelectedCount();
\r
1297 if (selCount != 1)
\r
1300 // Find selected entry in the log list
\r
1301 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1302 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1303 long rev1 = pLogEntry->Rev;
\r
1304 long rev2 = rev1-1;
\r
1305 CTGitPath path = m_path;
\r
1307 // See how many files under the relative root were changed in selected revision
\r
1309 LogChangedPath * changed = NULL;
\r
1310 for (INT_PTR c = 0; c < pLogEntry->pArChangedPaths->GetCount(); ++c)
\r
1312 LogChangedPath * cpath = pLogEntry->pArChangedPaths->GetAt(c);
\r
1313 if (cpath && cpath -> sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
1320 if (m_path.IsDirectory() && nChanged == 1)
\r
1322 // We're looking at the log for a directory and only one file under dir was changed in the revision
\r
1323 // Do diff on that file instead of whole directory
\r
1324 path.AppendPathString(changed->sPath.Mid(m_sRelativeRoot.GetLength()));
\r
1327 m_bCancelled = FALSE;
\r
1328 DialogEnableWindow(IDOK, FALSE);
\r
1329 SetPromptApp(&theApp);
\r
1330 theApp.DoWaitCursor(1);
\r
1332 if (PromptShown())
\r
1334 GitDiff diff(this, m_hWnd, true);
\r
1335 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1336 diff.SetHEADPeg(m_LogRevision);
\r
1337 diff.ShowCompare(path, rev2, path, rev1);
\r
1341 CAppUtils::StartShowCompare(m_hWnd, path, rev2, path, rev1, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1344 theApp.DoWaitCursor(-1);
\r
1349 void CGitLogListBase::OnLvnOdfinditemLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
1351 LPNMLVFINDITEM pFindInfo = reinterpret_cast<LPNMLVFINDITEM>(pNMHDR);
\r
1354 if (pFindInfo->lvfi.flags & LVFI_PARAM)
\r
1356 if ((pFindInfo->iStart < 0)||(pFindInfo->iStart >= m_arShownList.GetCount()))
\r
1358 if (pFindInfo->lvfi.psz == 0)
\r
1361 CString sCmp = pFindInfo->lvfi.psz;
\r
1363 for (int i=pFindInfo->iStart; i<m_arShownList.GetCount(); ++i)
\r
1365 GitRev * pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(i));
\r
1366 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1367 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1369 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1377 if (sCmp.Compare(sRev)==0)
\r
1384 if (pFindInfo->lvfi.flags & LVFI_WRAP)
\r
1386 for (int i=0; i<pFindInfo->iStart; ++i)
\r
1388 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1389 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1390 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1392 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1400 if (sCmp.Compare(sRev)==0)
\r
1412 int CGitLogListBase::FillGitLog(CTGitPath *path,int info,CString *from,CString *to)
\r
1416 this->m_logEntries.ClearAll();
\r
1417 this->m_logEntries.ParserFromLog(path,-1,info,from,to);
\r
1419 //this->m_logEntries.ParserFromLog();
\r
1420 SetItemCountEx(this->m_logEntries.size());
\r
1422 this->m_arShownList.RemoveAll();
\r
1424 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1428 m_logEntries[m_logEntries.size()-i-1].m_IsFull=TRUE;
\r
1429 this->m_arShownList.Add(&m_logEntries[m_logEntries.size()-i-1]);
\r
1433 m_logEntries[i].m_IsFull=TRUE;
\r
1434 this->m_arShownList.Add(&m_logEntries[i]);
\r
1444 int CGitLogListBase::FillGitShortLog()
\r
1448 this->m_logEntries.ClearAll();
\r
1450 m_LogCache.FetchCacheIndex(g_Git.m_CurrentDir);
\r
1453 if(this->m_Path.IsEmpty())
\r
1456 path=&this->m_Path;
\r
1460 mask = CGit::LOG_INFO_ONLY_HASH | CGit::LOG_INFO_BOUNDARY;
\r
1461 // if(this->m_bAllBranch)
\r
1462 mask |= m_ShowMask;
\r
1464 this->m_logEntries.ParserShortLog(path,hash,-1,mask);
\r
1467 //this->m_logEntries.ParserFromLog();
\r
1468 if(IsInWorkingThread())
\r
1469 PostMessage(LVM_SETITEMCOUNT, (WPARAM) this->m_logEntries.size(),(LPARAM) LVSICF_NOINVALIDATEALL);
\r
1471 SetItemCountEx(this->m_logEntries.size());
\r
1473 this->m_arShownList.RemoveAll();
\r
1475 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1477 if(this->m_IsOldFirst)
\r
1479 this->m_arShownList.Add(&m_logEntries[m_logEntries.size()-1-i]);
\r
1483 this->m_arShownList.Add(&m_logEntries[i]);
\r
1489 BOOL CGitLogListBase::PreTranslateMessage(MSG* pMsg)
\r
1491 // Skip Ctrl-C when copying text out of the log message or search filter
\r
1492 BOOL bSkipAccelerator = ( pMsg->message == WM_KEYDOWN && pMsg->wParam=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT) ) && GetKeyState(VK_CONTROL)&0x8000 );
\r
1493 if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')
\r
1495 //if (GetFocus()==GetDlgItem(IDC_LOGLIST))
\r
1497 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1499 DiffSelectedRevWithPrevious();
\r
1504 if (GetFocus()==GetDlgItem(IDC_LOGMSG))
\r
1506 DiffSelectedFile();
\r
1513 if (m_hAccel && !bSkipAccelerator)
\r
1515 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
\r
1521 //m_tooltips.RelayEvent(pMsg);
\r
1522 return __super::PreTranslateMessage(pMsg);
\r
1525 void CGitLogListBase::OnNMDblclkLoglist(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
1527 // a double click on an entry in the revision list has happened
\r
1530 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1531 DiffSelectedRevWithPrevious();
\r
1534 int CGitLogListBase::FetchLogAsync(void * data)
\r
1537 m_bExitThread=FALSE;
\r
1538 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1539 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1540 m_LoadingThread = AfxBeginThread(LogThreadEntry, this);
\r
1541 if (m_LoadingThread ==NULL)
\r
1543 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1544 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1545 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
1551 //this is the thread function which calls the subversion function
\r
1552 UINT CGitLogListBase::LogThreadEntry(LPVOID pVoid)
\r
1554 return ((CGitLogListBase*)pVoid)->LogThread();
\r
1557 void CGitLogListBase::GetTimeRange(CTime &oldest, CTime &latest)
\r
1560 oldest=CTime::GetCurrentTime();
\r
1561 latest=CTime(1971,1,2,0,0,0);
\r
1562 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1564 if(m_logEntries[i].m_AuthorDate.GetTime() < oldest.GetTime())
\r
1565 oldest = m_logEntries[i].m_AuthorDate.GetTime();
\r
1567 if(m_logEntries[i].m_AuthorDate.GetTime() > latest.GetTime())
\r
1568 latest = m_logEntries[i].m_AuthorDate.GetTime();
\r
1573 //Helper class for FetchFullLogInfo()
\r
1574 class CGitCall_FetchFullLogInfo : public CGitCall
\r
1577 CGitCall_FetchFullLogInfo(CGitLogListBase* ploglist):m_ploglist(ploglist),m_CollectedCount(0){}
\r
1578 virtual bool OnOutputData(const BYTE* data, size_t size)
\r
1581 return m_ploglist->m_bExitThread;
\r
1582 //Add received data to byte collector
\r
1583 m_ByteCollector.append(data,size);
\r
1585 //Find loginfo endmarker
\r
1586 static const BYTE dataToFind[]={0,0};
\r
1587 int found=m_ByteCollector.findData(dataToFind,2);
\r
1589 return m_ploglist->m_bExitThread;//Not found
\r
1590 found+=2;//Position after loginfo end-marker
\r
1592 //Prepare data for OnLogInfo and call it
\r
1593 BYTE_VECTOR logInfo;
\r
1594 logInfo.append(&*m_ByteCollector.begin(),found);
\r
1595 OnLogInfo(logInfo);
\r
1597 //Remove loginfo from bytecollector
\r
1598 m_ByteCollector.erase(m_ByteCollector.begin(),m_ByteCollector.begin()+found);
\r
1600 return m_ploglist->m_bExitThread;
\r
1602 virtual void OnEnd()
\r
1604 //Rest should be a complete log line.
\r
1605 if(!m_ByteCollector.empty())
\r
1606 OnLogInfo(m_ByteCollector);
\r
1610 void OnLogInfo(BYTE_VECTOR& logInfo)
\r
1613 fullRev.ParserFromLog(logInfo);
\r
1614 MAP_HASH_REV::iterator itRev=m_ploglist->m_logEntries.m_HashMap.find(fullRev.m_CommitHash);
\r
1615 if(itRev==m_ploglist->m_logEntries.m_HashMap.end())
\r
1617 //Should not occur, only when Git-tree updated in the mean time. (Race condition)
\r
1621 int rev=itRev->second;
\r
1622 GitRev* revInVector=&m_ploglist->m_logEntries[rev];
\r
1625 // fullRev.m_IsUpdateing=TRUE;
\r
1626 // fullRev.m_IsFull=TRUE;
\r
1629 if(InterlockedExchange(&revInVector->m_IsUpdateing,TRUE))
\r
1630 return;//Cannot update this row now. Ignore.
\r
1631 TCHAR oldmark=revInVector->m_Mark;
\r
1632 GIT_REV_LIST oldlist=revInVector->m_ParentHash;
\r
1633 // CString oldhash=m_CommitHash;
\r
1635 //Parse new rev info
\r
1636 revInVector->ParserFromLog(logInfo);
\r
1639 revInVector->m_Mark=oldmark; //parser full log will cause old mark overwrited.
\r
1640 //So we need keep old bound mark.
\r
1641 revInVector->m_ParentHash=oldlist;
\r
1644 InterlockedExchange(&revInVector->m_IsFull,TRUE);
\r
1645 InterlockedExchange(&revInVector->m_IsUpdateing,FALSE);
\r
1647 //Notify listcontrol and update progress bar
\r
1648 ++m_CollectedCount;
\r
1650 ::PostMessage(m_ploglist->m_hWnd,MSG_LOADED,(WPARAM)rev,0);
\r
1652 DWORD percent=m_CollectedCount*98/m_ploglist->m_logEntries.size() + GITLOG_START+1;
\r
1653 if(percent == GITLOG_END)
\r
1654 percent = GITLOG_END -1;
\r
1656 ::PostMessage(m_ploglist->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) percent,0);
\r
1659 CGitLogListBase* m_ploglist;
\r
1660 BYTE_VECTOR m_ByteCollector;
\r
1661 int m_CollectedCount;
\r
1665 void CGitLogListBase::FetchFullLogInfo()
\r
1667 CGitCall_FetchFullLogInfo fetcher(this);
\r
1669 CGit::LOG_INFO_STAT|
\r
1670 CGit::LOG_INFO_FILESTATE|
\r
1671 CGit::LOG_INFO_DETECT_COPYRENAME|
\r
1673 g_Git.GetLog(&fetcher,CString(),NULL,-1,mask);
\r
1676 void CGitLogListBase::FetchFullLogInfoOrig()
\r
1678 unsigned int updated=0;
\r
1683 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1685 if(m_LogCache.GetCacheData(m_logEntries[i]))
\r
1687 if(!m_logEntries.FetchFullInfo(i))
\r
1691 m_LogCache.AddCacheEntry(m_logEntries[i]);
\r
1696 InterlockedExchange(&m_logEntries[i].m_IsUpdateing,FALSE);
\r
1697 InterlockedExchange(&m_logEntries[i].m_IsFull,TRUE);
\r
1700 ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM)i,0);
\r
1704 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1705 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1709 percent=updated*98/m_logEntries.size() + GITLOG_START+1;
\r
1710 if(percent == GITLOG_END)
\r
1711 percent = GITLOG_END -1;
\r
1713 ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) percent,0);
\r
1717 if(updated==m_logEntries.size())
\r
1722 UINT CGitLogListBase::LogThread()
\r
1725 // if(m_ProcCallBack)
\r
1726 // m_ProcCallBack(m_ProcData,GITLOG_START);
\r
1727 ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_START,0);
\r
1729 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1730 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1732 //does the user force the cache to refresh (shift or control key down)?
\r
1733 bool refresh = (GetKeyState (VK_CONTROL) < 0)
\r
1734 || (GetKeyState (VK_SHIFT) < 0);
\r
1736 //disable the "Get All" button while we're receiving
\r
1739 FillGitShortLog();
\r
1741 if(this->m_bExitThread)
\r
1743 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1744 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1748 RedrawItems(0, m_arShownList.GetCount());
\r
1749 // SetRedraw(false);
\r
1750 // ResizeAllListCtrlCols();
\r
1751 // SetRedraw(true);
\r
1753 if ( m_pStoreSelection )
\r
1755 // Deleting the instance will restore the
\r
1756 // selection of the CLogDlg.
\r
1757 delete m_pStoreSelection;
\r
1758 m_pStoreSelection = NULL;
\r
1762 // If no selection has been set then this must be the first time
\r
1763 // the revisions are shown. Let's preselect the topmost revision.
\r
1764 if ( GetItemCount()>0 )
\r
1766 SetSelectionMark(0);
\r
1767 SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
\r
1771 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1774 //FetchFullLogInfo();
\r
1775 FetchFullLogInfoOrig();
\r
1776 //RefreshCursor();
\r
1777 // make sure the filter is applied (if any) now, after we refreshed/fetched
\r
1778 // the log messages
\r
1780 ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_END,0);
\r
1782 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1787 void CGitLogListBase::Refresh()
\r
1789 m_bExitThread=TRUE;
\r
1790 DWORD ret =::WaitForSingleObject(m_LoadingThread->m_hThread,20000);
\r
1791 if(ret == WAIT_TIMEOUT)
\r
1792 TerminateThread();
\r
1796 //Update branch and Tag info
\r
1798 //Assume Thread have exited
\r
1799 //if(!m_bThreadRunning)
\r
1801 this->SetItemCountEx(0);
\r
1802 m_logEntries.clear();
\r
1803 m_bExitThread=FALSE;
\r
1804 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1805 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1806 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
1808 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1809 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1810 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
1812 m_sFilterText.Empty();
\r
1813 m_From=CTime(1970,1,2,0,0,0);
\r
1814 m_To=CTime::GetCurrentTime();
\r
1817 bool CGitLogListBase::ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase /* = false */)
\r
1821 tr1::regex_constants::syntax_option_type type = tr1::regex_constants::ECMAScript;
\r
1823 type |= tr1::regex_constants::icase;
\r
1824 pat = tr1::wregex(regexp_str, type);
\r
1827 catch (exception) {}
\r
1831 void CGitLogListBase::RecalculateShownList(CPtrArray * pShownlist)
\r
1834 pShownlist->RemoveAll();
\r
1835 tr1::wregex pat;//(_T("Remove"), tr1::regex_constants::icase);
\r
1836 bool bRegex = false;
\r
1837 if (m_bFilterWithRegex)
\r
1838 bRegex = ValidateRegexp(m_sFilterText, pat, false);
\r
1840 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_any;
\r
1842 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
1844 if ((bRegex)&&(m_bFilterWithRegex))
\r
1847 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
1849 ATLTRACE(_T("bugID = \"%s\"\n"), (LPCTSTR)m_logEntries[i]->sBugIDs);
\r
1850 if (regex_search(wstring((LPCTSTR)m_logEntries[i]->sBugIDs), pat, flags)&&IsEntryInDateRange(i))
\r
1852 pShownlist->Add(m_logEntries[i]);
\r
1857 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
1859 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries[i].m_Subject);
\r
1860 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_Subject), pat, flags)&&IsEntryInDateRange(i))
\r
1862 pShownlist->Add(&m_logEntries[i]);
\r
1866 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries[i].m_Body);
\r
1867 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_Body), pat, flags)&&IsEntryInDateRange(i))
\r
1869 pShownlist->Add(&m_logEntries[i]);
\r
1874 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
1876 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
1878 bool bGoing = true;
\r
1879 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
1881 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1882 if (regex_search(wstring((LPCTSTR)cpath->sCopyFromPath), pat, flags)&&IsEntryInDateRange(i))
\r
1884 pShownlist->Add(m_logEntries[i]);
\r
1888 if (regex_search(wstring((LPCTSTR)cpath->sPath), pat, flags)&&IsEntryInDateRange(i))
\r
1890 pShownlist->Add(m_logEntries[i]);
\r
1894 if (regex_search(wstring((LPCTSTR)cpath->GetAction()), pat, flags)&&IsEntryInDateRange(i))
\r
1896 pShownlist->Add(m_logEntries[i]);
\r
1905 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
1907 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_AuthorName), pat, flags)&&IsEntryInDateRange(i))
\r
1909 pShownlist->Add(&m_logEntries[i]);
\r
1913 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
1915 sRev.Format(_T("%s"), m_logEntries[i].m_CommitHash);
\r
1916 if (regex_search(wstring((LPCTSTR)sRev), pat, flags)&&IsEntryInDateRange(i))
\r
1918 pShownlist->Add(&m_logEntries[i]);
\r
1925 CString find = m_sFilterText;
\r
1928 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
1930 CString sBugIDs = m_logEntries[i]->sBugIDs;
\r
1932 sBugIDs = sBugIDs.MakeLower();
\r
1933 if ((sBugIDs.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
1935 pShownlist->Add(m_logEntries[i]);
\r
1940 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
1942 CString msg = m_logEntries[i].m_Subject;
\r
1944 msg = msg.MakeLower();
\r
1945 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
1947 pShownlist->Add(&m_logEntries[i]);
\r
1950 msg = m_logEntries[i].m_Body;
\r
1952 msg = msg.MakeLower();
\r
1953 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
1955 pShownlist->Add(&m_logEntries[i]);
\r
1960 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
1962 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
1964 bool bGoing = true;
\r
1965 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
1967 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1968 CString path = cpath->sCopyFromPath;
\r
1970 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
1972 pShownlist->Add(m_logEntries[i]);
\r
1976 path = cpath->sPath;
\r
1978 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
1980 pShownlist->Add(m_logEntries[i]);
\r
1984 path = cpath->GetAction();
\r
1986 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
1988 pShownlist->Add(m_logEntries[i]);
\r
1995 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
1997 CString msg = m_logEntries[i].m_AuthorName;
\r
1998 msg = msg.MakeLower();
\r
1999 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2001 pShownlist->Add(&m_logEntries[i]);
\r
2005 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
2007 sRev.Format(_T("%s"), m_logEntries[i].m_CommitHash);
\r
2008 if ((sRev.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2010 pShownlist->Add(&m_logEntries[i]);
\r
2014 } // else (from if (bRegex))
\r
2015 } // for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
2019 BOOL CGitLogListBase::IsEntryInDateRange(int i)
\r
2021 __time64_t time = m_logEntries[i].m_AuthorDate.GetTime();
\r
2022 if ((time >= m_From.GetTime())&&(time <= m_To.GetTime()))
\r
2029 void CGitLogListBase::StartFilter()
\r
2031 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
2032 RecalculateShownList(&m_arShownList);
\r
2033 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2037 SetItemCountEx(ShownCountWithStopped());
\r
2038 RedrawItems(0, ShownCountWithStopped());
\r
2040 //ResizeAllListCtrlCols();
\r
2045 void CGitLogListBase::RemoveFilter()
\r
2048 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
2050 m_arShownList.RemoveAll();
\r
2052 // reset the time filter too
\r
2054 m_timFrom = (__time64_t(m_tFrom));
\r
2055 m_timTo = (__time64_t(m_tTo));
\r
2056 m_DateFrom.SetTime(&m_timFrom);
\r
2057 m_DateTo.SetTime(&m_timTo);
\r
2058 m_DateFrom.SetRange(&m_timFrom, &m_timTo);
\r
2059 m_DateTo.SetRange(&m_timFrom, &m_timTo);
\r
2062 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
2064 if(this->m_IsOldFirst)
\r
2066 m_arShownList.Add(&m_logEntries[m_logEntries.size()-i-1]);
\r
2069 m_arShownList.Add(&m_logEntries[i]);
\r
2072 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2074 SetItemCountEx(ShownCountWithStopped());
\r
2075 RedrawItems(0, ShownCountWithStopped());
\r
2076 // SetRedraw(false);
\r
2077 // ResizeAllListCtrlCols();
\r
2078 // SetRedraw(true);
\r
2080 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2083 void CGitLogListBase::Clear()
\r
2085 m_arShownList.RemoveAll();
\r
2086 m_logEntries.clear();
\r
2087 m_logEntries.m_HashMap.clear();
\r
2089 m_logEntries.m_Lns.clear();
\r
2091 m_logEntries.m_FirstFreeLane=0;
\r
2092 m_logEntries.m_Lns.clear();
\r
2096 void CGitLogListBase::OnDestroy()
\r
2098 // save the column widths to the registry
\r
2099 SaveColumnWidths();
\r
2101 if(this->m_bThreadRunning)
\r
2103 this->m_bExitThread=true;
\r
2104 DWORD ret =::WaitForSingleObject(m_LoadingThread->m_hThread,20000);
\r
2105 if(ret == WAIT_TIMEOUT)
\r
2106 TerminateThread();
\r
2108 while(m_LogCache.SaveCache())
\r
2110 if(CMessageBox::Show(NULL,_T("Cannot Save Log Cache to Disk. To retry click yes. To give up click no."),_T("TortoiseGit"),
\r
2111 MB_YESNO) == IDNO)
\r
2114 CHintListCtrl::OnDestroy();
\r
2117 LRESULT CGitLogListBase::OnLoad(WPARAM wParam,LPARAM lParam)
\r
2120 int i=(int)wParam;
\r
2121 this->GetItemRect(i,&rect,LVIR_BOUNDS);
\r
2122 this->InvalidateRect(rect);
\r
2127 * Save column widths to the registry
\r
2129 void CGitLogListBase::SaveColumnWidths()
\r
2131 CHeaderCtrl* pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0));
\r
2134 int numcols = pHdrCtrl->GetItemCount();
\r
2135 for (int col = 0; col < numcols; col++)
\r
2137 int width = GetColumnWidth( col );
\r
2139 regentry.Format( _T("Software\\TortoiseGit\\log\\ColWidth%d"), col);
\r
2140 CRegDWORD regwidth(regentry, 0);
\r
2141 regwidth = width; // this writes it to reg
\r