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
86 this->m_HeadHash=g_Git.GetHash(CString(_T("HEAD"))).Left(40);
\r
88 m_From=CTime(1970,1,2,0,0,0);
\r
89 m_To=CTime::GetCurrentTime();
\r
91 m_LoadingThread = NULL;
\r
93 m_bExitThread=FALSE;
\r
94 m_IsOldFirst = FALSE;
\r
95 m_IsRebaseReplaceGraph = FALSE;
\r
98 for(int i=0;i<Lanes::COLORS_NUM;i++)
\r
100 m_LineColors[i] = m_Colors.GetColor((CColors::Colors)(CColors::BranchLine1+i));
\r
102 // get short/long datetime setting from registry
\r
103 DWORD RegUseShortDateFormat = CRegDWORD(_T("Software\\TortoiseGit\\LogDateFormat"), TRUE);
\r
104 if ( RegUseShortDateFormat )
\r
106 m_DateFormat = DATE_SHORTDATE;
\r
110 m_DateFormat = DATE_LONGDATE;
\r
112 // get relative time display setting from registry
\r
113 DWORD regRelativeTimes = CRegDWORD(_T("Software\\TortoiseGit\\RelativeTimes"), FALSE);
\r
114 m_bRelativeTimes = (regRelativeTimes != 0);
\r
115 m_ContextMenuMask = 0xFFFFFFFFFFFFFFFF;
\r
117 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_PICK);
\r
118 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_SQUASH);
\r
119 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_EDIT);
\r
120 m_ContextMenuMask &= ~GetContextMenuBit(ID_REBASE_SKIP);
\r
123 CGitLogListBase::~CGitLogListBase()
\r
125 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
127 DestroyIcon(m_hModifiedIcon);
\r
128 DestroyIcon(m_hReplacedIcon);
\r
129 DestroyIcon(m_hAddedIcon);
\r
130 DestroyIcon(m_hDeletedIcon);
\r
131 m_logEntries.ClearAll();
\r
134 DeleteObject(m_boldFont);
\r
136 if ( m_pStoreSelection )
\r
138 delete m_pStoreSelection;
\r
139 m_pStoreSelection = NULL;
\r
142 if(this->m_bThreadRunning)
\r
144 m_bExitThread=true;
\r
145 WaitForSingleObject(m_LoadingThread->m_hThread,1000);
\r
151 BEGIN_MESSAGE_MAP(CGitLogListBase, CHintListCtrl)
\r
152 ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnNMCustomdrawLoglist)
\r
153 ON_NOTIFY_REFLECT(LVN_GETDISPINFO, OnLvnGetdispinfoLoglist)
\r
154 ON_WM_CONTEXTMENU()
\r
155 ON_NOTIFY_REFLECT(NM_DBLCLK, OnNMDblclkLoglist)
\r
156 ON_NOTIFY_REFLECT(LVN_ODFINDITEM,OnLvnOdfinditemLoglist)
\r
159 ON_MESSAGE(MSG_LOADED,OnLoad)
\r
162 int CGitLogListBase:: OnCreate(LPCREATESTRUCT lpCreateStruct)
\r
164 PreSubclassWindow();
\r
165 return CHintListCtrl::OnCreate(lpCreateStruct);
\r
168 void CGitLogListBase::PreSubclassWindow()
\r
170 SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES);
\r
171 // load the icons for the action columns
\r
172 m_Theme.SetWindowTheme(GetSafeHwnd(), L"Explorer", NULL);
\r
173 CHintListCtrl::PreSubclassWindow();
\r
176 void CGitLogListBase::InsertGitColumn()
\r
180 int c = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;
\r
184 temp.LoadString(IDS_LOG_GRAPH);
\r
186 if(m_IsRebaseReplaceGraph)
\r
192 temp.LoadString(IDS_LOG_GRAPH);
\r
194 InsertColumn(this->LOGLIST_GRAPH, temp);
\r
197 // make the revision column right aligned
\r
199 Column.mask = LVCF_FMT;
\r
200 Column.fmt = LVCFMT_RIGHT;
\r
201 SetColumn(0, &Column);
\r
204 // g_Git.GetLog(log);
\r
206 if(m_IsIDReplaceAction)
\r
208 temp.LoadString(IDS_LOG_ID);
\r
209 InsertColumn(this->LOGLIST_ACTION, temp);
\r
213 temp.LoadString(IDS_LOG_ACTIONS);
\r
214 InsertColumn(this->LOGLIST_ACTION, temp);
\r
216 temp.LoadString(IDS_LOG_MESSAGE);
\r
217 InsertColumn(this->LOGLIST_MESSAGE, temp);
\r
219 temp.LoadString(IDS_LOG_AUTHOR);
\r
220 InsertColumn(this->LOGLIST_AUTHOR, temp);
\r
222 temp.LoadString(IDS_LOG_DATE);
\r
223 InsertColumn(this->LOGLIST_DATE, temp);
\r
226 if (m_bShowBugtraqColumn)
\r
228 // temp = m_ProjectProperties.sLabel;
\r
229 if (temp.IsEmpty())
\r
230 temp.LoadString(IDS_LOG_BUGIDS);
\r
231 InsertColumn(this->LOGLIST_BUG, temp);
\r
236 ResizeAllListCtrlCols();
\r
242 * Resizes all columns in a list control to values in registry.
\r
244 void CGitLogListBase::ResizeAllListCtrlCols()
\r
246 // column max and min widths to allow
\r
247 static const int nMinimumWidth = 10;
\r
248 static const int nMaximumWidth = 1000;
\r
249 CHeaderCtrl* pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0));
\r
252 int numcols = pHdrCtrl->GetItemCount();
\r
253 for (int col = 0; col < numcols; col++)
\r
255 // get width for this col last time from registry
\r
257 regentry.Format( _T("Software\\TortoiseGit\\log\\ColWidth%d"), col);
\r
258 CRegDWORD regwidth(regentry, 0);
\r
262 // no saved value, setup sensible defaults
\r
263 if (col == this->LOGLIST_MESSAGE)
\r
265 cx = LOGLIST_MESSAGE_MIN;
\r
269 cx = ICONITEMBORDER+16*4;
\r
272 if (cx < nMinimumWidth)
\r
274 cx = nMinimumWidth;
\r
275 } else if (cx > nMaximumWidth)
\r
277 cx = nMaximumWidth;
\r
280 SetColumnWidth(col, cx);
\r
287 BOOL CGitLogListBase::GetShortName(CString ref, CString &shortname,CString prefix)
\r
289 TRACE(_T("%s %s\r\n"),ref,prefix);
\r
290 if(ref.Left(prefix.GetLength()) == prefix)
\r
292 shortname = ref.Right(ref.GetLength()-prefix.GetLength());
\r
293 if(shortname.Right(3)==_T("^{}"))
\r
294 shortname=shortname.Left(shortname.GetLength()-3);
\r
299 void CGitLogListBase::FillBackGround(HDC hdc, int Index,CRect &rect)
\r
303 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
304 rItem.mask = LVIF_STATE;
\r
305 rItem.iItem = Index;
\r
306 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
309 GitRev* pLogEntry = (GitRev*)m_arShownList.GetAt(Index);
\r
311 if (m_Theme.IsAppThemed() && m_bVista)
\r
313 m_Theme.Open(m_hWnd, L"Explorer");
\r
314 int state = LISS_NORMAL;
\r
315 if (rItem.state & LVIS_SELECTED)
\r
317 if (::GetFocus() == m_hWnd)
\r
318 state |= LISS_SELECTED;
\r
320 state |= LISS_SELECTEDNOTFOCUS;
\r
325 if (pLogEntry->bCopiedSelf)
\r
327 // unfortunately, the pLVCD->nmcd.uItemState does not contain valid
\r
328 // information at this drawing stage. But we can check the whether the
\r
329 // previous stage changed the background color of the item
\r
330 if (pLVCD->clrTextBk == GetSysColor(COLOR_MENU))
\r
333 brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
336 ::FillRect(pLVCD->nmcd.hdc, &rect, brush);
\r
337 ::DeleteObject(brush);
\r
344 if (m_Theme.IsBackgroundPartiallyTransparent(LVP_LISTDETAIL, state))
\r
345 m_Theme.DrawParentBackground(m_hWnd, hdc, &rect);
\r
347 m_Theme.DrawBackground(hdc, LVP_LISTDETAIL, state, &rect, NULL);
\r
352 if (rItem.state & LVIS_SELECTED)
\r
354 if (::GetFocus() == m_hWnd)
\r
355 brush = ::CreateSolidBrush(::GetSysColor(COLOR_HIGHLIGHT));
\r
357 brush = ::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));
\r
361 //if (pLogEntry->bCopiedSelf)
\r
362 // brush = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
\r
364 if(pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_SQUASH)
\r
365 brush = ::CreateSolidBrush(RGB(156,156,156));
\r
366 else if(pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT)
\r
367 brush = ::CreateSolidBrush(RGB(200,200,128));
\r
369 brush = ::CreateSolidBrush(::GetSysColor(COLOR_WINDOW));
\r
374 ::FillRect(hdc, &rect, brush);
\r
375 ::DeleteObject(brush);
\r
380 void CGitLogListBase::DrawTagBranch(HDC hdc,CRect &rect,INT_PTR index)
\r
382 GitRev* data = (GitRev*)m_arShownList.GetAt(index);
\r
385 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
386 rItem.mask = LVIF_STATE;
\r
387 rItem.iItem = index;
\r
388 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
391 for(unsigned int i=0;i<m_HashMap[data->m_CommitHash].size();i++)
\r
394 str=m_HashMap[data->m_CommitHash][i];
\r
399 if(GetShortName(str,shortname,_T("refs/heads/")))
\r
401 if( shortname == m_CurrentBranch )
\r
402 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::CurrentBranch));
\r
404 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::LocalBranch));
\r
406 }else if(GetShortName(str,shortname,_T("refs/remotes/")))
\r
408 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::RemoteBranch));
\r
410 else if(GetShortName(str,shortname,_T("refs/tags/")))
\r
412 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::Tag));
\r
414 else if(GetShortName(str,shortname,_T("refs/stash")))
\r
416 brush = ::CreateSolidBrush(m_Colors.GetColor(CColors::Stash));
\r
417 shortname=_T("stash");
\r
421 if(!shortname.IsEmpty())
\r
424 memset(&size,0,sizeof(SIZE));
\r
425 GetTextExtentPoint32(hdc, shortname,shortname.GetLength(),&size);
\r
427 rt.SetRect(rt.left,rt.top,rt.left+size.cx,rt.bottom);
\r
429 ::FillRect(hdc, &rt, brush);
\r
430 if (rItem.state & LVIS_SELECTED)
\r
432 COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT));
\r
433 ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER);
\r
434 ::SetTextColor(hdc,clrOld);
\r
437 ::DrawText(hdc,shortname,shortname.GetLength(),&rt,DT_CENTER);
\r
441 ::MoveToEx(hdc,rt.left,rt.top,NULL);
\r
442 ::LineTo(hdc,rt.right,rt.top);
\r
443 ::LineTo(hdc,rt.right,rt.bottom);
\r
444 ::LineTo(hdc,rt.left,rt.bottom);
\r
445 ::LineTo(hdc,rt.left,rt.top);
\r
447 rt.left=rt.right+3;
\r
450 ::DeleteObject(brush);
\r
452 rt.right=rect.right;
\r
454 if (rItem.state & LVIS_SELECTED)
\r
456 COLORREF clrOld = ::SetTextColor(hdc,::GetSysColor(COLOR_HIGHLIGHTTEXT));
\r
457 ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT);
\r
458 ::SetTextColor(hdc,clrOld);
\r
461 ::DrawText(hdc,data->m_Subject,data->m_Subject.GetLength(),&rt,DT_LEFT);
\r
466 void CGitLogListBase::paintGraphLane(HDC hdc, int laneHeight,int type, int x1, int x2,
\r
467 const COLORREF& col,int top
\r
470 int h = laneHeight / 2;
\r
471 int m = (x1 + x2) / 2;
\r
472 int r = (x2 - x1) / 3;
\r
475 #define P_CENTER m , h+top
\r
476 #define P_0 x2, h+top
\r
477 #define P_90 m , 0+top
\r
478 #define P_180 x1, h+top
\r
479 #define P_270 m , 2 * h+top
\r
480 #define R_CENTER m - r, h - r+top, m - r+d, h - r+top+d
\r
482 //static QPen myPen(Qt::black, 2); // fast path here
\r
484 pen.CreatePen(PS_SOLID,2,col);
\r
485 //myPen.setColor(col);
\r
486 HPEN oldpen=(HPEN)::SelectObject(hdc,(HPEN)pen);
\r
488 //p->setPen(myPen);
\r
492 case Lanes::ACTIVE:
\r
493 case Lanes::NOT_ACTIVE:
\r
494 case Lanes::MERGE_FORK:
\r
495 case Lanes::MERGE_FORK_R:
\r
496 case Lanes::MERGE_FORK_L:
\r
498 case Lanes::JOIN_R:
\r
499 case Lanes::JOIN_L:
\r
500 DrawLine(hdc,P_90,P_270);
\r
501 //p->drawLine(P_90, P_270);
\r
504 case Lanes::HEAD_R:
\r
505 case Lanes::HEAD_L:
\r
506 case Lanes::BRANCH:
\r
507 DrawLine(hdc,P_CENTER,P_270);
\r
508 //p->drawLine(P_CENTER, P_270);
\r
511 case Lanes::TAIL_R:
\r
512 case Lanes::TAIL_L:
\r
513 case Lanes::INITIAL:
\r
514 case Lanes::BOUNDARY:
\r
515 case Lanes::BOUNDARY_C:
\r
516 case Lanes::BOUNDARY_R:
\r
517 case Lanes::BOUNDARY_L:
\r
518 DrawLine(hdc,P_90, P_CENTER);
\r
519 //p->drawLine(P_90, P_CENTER);
\r
527 case Lanes::MERGE_FORK:
\r
532 case Lanes::CROSS_EMPTY:
\r
533 case Lanes::BOUNDARY_C:
\r
534 DrawLine(hdc,P_180,P_0);
\r
535 //p->drawLine(P_180, P_0);
\r
537 case Lanes::MERGE_FORK_R:
\r
538 case Lanes::JOIN_R:
\r
539 case Lanes::HEAD_R:
\r
540 case Lanes::TAIL_R:
\r
541 case Lanes::BOUNDARY_R:
\r
542 DrawLine(hdc,P_180,P_CENTER);
\r
543 //p->drawLine(P_180, P_CENTER);
\r
545 case Lanes::MERGE_FORK_L:
\r
546 case Lanes::JOIN_L:
\r
547 case Lanes::HEAD_L:
\r
548 case Lanes::TAIL_L:
\r
549 case Lanes::BOUNDARY_L:
\r
550 DrawLine(hdc,P_CENTER,P_0);
\r
551 //p->drawLine(P_CENTER, P_0);
\r
558 brush.CreateSolidBrush(col);
\r
559 HBRUSH oldbrush=(HBRUSH)::SelectObject(hdc,(HBRUSH)brush);
\r
560 // center symbol, e.g. rect or ellipse
\r
562 case Lanes::ACTIVE:
\r
563 case Lanes::INITIAL:
\r
564 case Lanes::BRANCH:
\r
566 //p->setPen(Qt::NoPen);
\r
567 //p->setBrush(col);
\r
568 ::Ellipse(hdc, R_CENTER);
\r
569 //p->drawEllipse(R_CENTER);
\r
571 case Lanes::MERGE_FORK:
\r
572 case Lanes::MERGE_FORK_R:
\r
573 case Lanes::MERGE_FORK_L:
\r
574 //p->setPen(Qt::NoPen);
\r
575 //p->setBrush(col);
\r
576 //p->drawRect(R_CENTER);
\r
577 Rectangle(hdc,R_CENTER);
\r
579 case Lanes::UNAPPLIED:
\r
581 //p->setPen(Qt::NoPen);
\r
582 //p->setBrush(Qt::red);
\r
583 //p->drawRect(m - r, h - 1, d, 2);
\r
584 ::Rectangle(hdc,m-r,h-1,d,2);
\r
586 case Lanes::APPLIED:
\r
588 //p->setPen(Qt::NoPen);
\r
589 //p->setBrush(DARK_GREEN);
\r
590 //p->drawRect(m - r, h - 1, d, 2);
\r
591 //p->drawRect(m - 1, h - r, 2, d);
\r
592 ::Rectangle(hdc,m-r,h-1,d,2);
\r
593 ::Rectangle(hdc,m-1,h-r,2,d);
\r
595 case Lanes::BOUNDARY:
\r
596 //p->setBrush(back);
\r
597 //p->drawEllipse(R_CENTER);
\r
598 ::Ellipse(hdc, R_CENTER);
\r
600 case Lanes::BOUNDARY_C:
\r
601 case Lanes::BOUNDARY_R:
\r
602 case Lanes::BOUNDARY_L:
\r
603 //p->setBrush(back);
\r
604 //p->drawRect(R_CENTER);
\r
605 ::Rectangle(hdc,R_CENTER);
\r
611 ::SelectObject(hdc,oldpen);
\r
612 ::SelectObject(hdc,oldbrush);
\r
621 void CGitLogListBase::DrawGraph(HDC hdc,CRect &rect,INT_PTR index)
\r
625 GitRev* data = (GitRev*)m_arShownList.GetAt(index);
\r
628 SecureZeroMemory(&rItem, sizeof(LVITEM));
\r
629 rItem.mask = LVIF_STATE;
\r
630 rItem.iItem = index;
\r
631 rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
\r
635 // p->translate(QPoint(opt.rect.left(), opt.rect.top()));
\r
639 if (data->m_Lanes.size() == 0)
\r
640 m_logEntries.setLane(data->m_CommitHash);
\r
642 std::vector<int>& lanes=data->m_Lanes;
\r
643 UINT laneNum = lanes.size();
\r
644 UINT mergeLane = 0;
\r
645 for (UINT i = 0; i < laneNum; i++)
\r
646 if (Lanes::isMerge(lanes[i])) {
\r
651 int x1 = 0, x2 = 0;
\r
652 int maxWidth = rect.Width();
\r
653 int lw = 3 * rect.Height() / 4; //laneWidth()
\r
654 for (UINT i = 0; i < laneNum && x2 < maxWidth; i++) {
\r
660 if (ln == Lanes::EMPTY)
\r
663 UINT col = ( Lanes:: isHead(ln) ||Lanes:: isTail(ln) || Lanes::isJoin(ln)
\r
664 || ln ==Lanes:: CROSS_EMPTY) ? mergeLane : i;
\r
666 if (ln == Lanes::CROSS) {
\r
667 paintGraphLane(hdc, rect.Height(),Lanes::NOT_ACTIVE, x1, x2, m_LineColors[col % Lanes::COLORS_NUM],rect.top);
\r
668 paintGraphLane(hdc, rect.Height(),Lanes::CROSS, x1, x2, m_LineColors[mergeLane % Lanes::COLORS_NUM],rect.top);
\r
670 paintGraphLane(hdc, rect.Height(),ln, x1, x2, m_LineColors[col % Lanes::COLORS_NUM],rect.top);
\r
673 TRACE(_T("index %d %d\r\n"),index,data->m_Lanes.size());
\r
676 void CGitLogListBase::OnNMCustomdrawLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
679 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
\r
680 // Take the default processing unless we set this to something else below.
\r
681 *pResult = CDRF_DODEFAULT;
\r
683 if (m_bNoDispUpdates)
\r
688 switch (pLVCD->nmcd.dwDrawStage)
\r
690 case CDDS_PREPAINT:
\r
692 *pResult = CDRF_NOTIFYITEMDRAW;
\r
696 case CDDS_ITEMPREPAINT:
\r
698 // This is the prepaint stage for an item. Here's where we set the
\r
699 // item's text color.
\r
701 // Tell Windows to send draw notifications for each subitem.
\r
702 *pResult = CDRF_NOTIFYSUBITEMDRAW;
\r
704 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
\r
706 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
708 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
712 if (data->bCopiedSelf)
\r
714 // only change the background color if the item is not 'hot' (on vista with m_Themes enabled)
\r
715 if (!m_Theme.IsAppm_Themed() || !m_bVista || ((pLVCD->nmcd.uItemState & CDIS_HOT)==0))
\r
716 pLVCD->clrTextBk = GetSysColor(COLOR_MENU);
\r
720 crText = m_Colors.GetColor(CColors::Modified);
\r
722 if (data->m_Action& (CTGitPath::LOGACTIONS_REBASE_DONE| CTGitPath::LOGACTIONS_REBASE_SKIP) )
\r
723 crText = RGB(128,128,128);
\r
725 if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_SQUASH)
\r
726 pLVCD->clrTextBk = RGB(156,156,156);
\r
727 else if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_EDIT)
\r
728 pLVCD->clrTextBk = RGB(200,200,128);
\r
730 pLVCD->clrTextBk = ::GetSysColor(COLOR_WINDOW);
\r
732 if(data->m_Action&CTGitPath::LOGACTIONS_REBASE_CURRENT)
\r
734 SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
735 *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
738 if(data->m_CommitHash == m_HeadHash)
\r
740 SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
741 *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
744 // if ((data->childStackDepth)||(m_mergedRevs.find(data->Rev) != m_mergedRevs.end()))
\r
745 // crText = GetSysColor(COLOR_GRAYTEXT);
\r
746 // if (data->Rev == m_wcRev)
\r
748 // SelectObject(pLVCD->nmcd.hdc, m_boldFont);
\r
749 // We changed the font, so we're returning CDRF_NEWFONT. This
\r
750 // tells the control to recalculate the extent of the text.
\r
751 // *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NEWFONT;
\r
755 if (m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
757 if (m_bStrictStopped)
\r
758 crText = GetSysColor(COLOR_GRAYTEXT);
\r
760 // Store the color back in the NMLVCUSTOMDRAW struct.
\r
761 pLVCD->clrText = crText;
\r
765 case CDDS_ITEMPREPAINT|CDDS_ITEM|CDDS_SUBITEM:
\r
767 if ((m_bStrictStopped)&&(m_arShownList.GetCount() == (INT_PTR)pLVCD->nmcd.dwItemSpec))
\r
769 pLVCD->nmcd.uItemState &= ~(CDIS_SELECTED|CDIS_FOCUS);
\r
772 if (pLVCD->iSubItem == LOGLIST_GRAPH)
\r
774 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec && (!this->m_IsRebaseReplaceGraph) )
\r
777 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
779 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
780 DrawGraph(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
\r
782 *pResult = CDRF_SKIPDEFAULT;
\r
788 if (pLVCD->iSubItem == LOGLIST_MESSAGE)
\r
790 if (m_arShownList.GetCount() > (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
792 GitRev* data = (GitRev*)m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec);
\r
793 //if(!data->m_IsFull)
\r
795 //if(data->SafeFetchFullInfo(&g_Git))
\r
796 // this->Invalidate();
\r
797 //TRACE(_T("Update ... %d\r\n"),pLVCD->nmcd.dwItemSpec);
\r
800 if(m_HashMap[data->m_CommitHash].size()!=0)
\r
804 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
806 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
807 DrawTagBranch(pLVCD->nmcd.hdc,rect,pLVCD->nmcd.dwItemSpec);
\r
809 *pResult = CDRF_SKIPDEFAULT;
\r
816 if (pLVCD->iSubItem == 1)
\r
818 if(this->m_IsIDReplaceAction)
\r
820 *pResult = CDRF_DODEFAULT;
\r
823 *pResult = CDRF_DODEFAULT;
\r
825 if (m_arShownList.GetCount() <= (INT_PTR)pLVCD->nmcd.dwItemSpec)
\r
829 int iconwidth = ::GetSystemMetrics(SM_CXSMICON);
\r
830 int iconheight = ::GetSystemMetrics(SM_CYSMICON);
\r
832 GitRev* pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(pLVCD->nmcd.dwItemSpec));
\r
834 GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_BOUNDS, rect);
\r
835 // Get the selected state of the
\r
836 // item being drawn.
\r
838 // Fill the background
\r
839 FillBackGround(pLVCD->nmcd.hdc, (INT_PTR)pLVCD->nmcd.dwItemSpec,rect);
\r
841 // Draw the icon(s) into the compatible DC
\r
842 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_MODIFIED)
\r
843 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left + ICONITEMBORDER, rect.top, m_hModifiedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
846 if (pLogEntry->m_Action & (CTGitPath::LOGACTIONS_ADDED|CTGitPath::LOGACTIONS_COPY) )
\r
847 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hAddedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
850 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_DELETED)
\r
851 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hDeletedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
854 if (pLogEntry->m_Action & CTGitPath::LOGACTIONS_REPLACED)
\r
855 ::DrawIconEx(pLVCD->nmcd.hdc, rect.left+nIcons*iconwidth + ICONITEMBORDER, rect.top, m_hReplacedIcon, iconwidth, iconheight, 0, NULL, DI_NORMAL);
\r
857 *pResult = CDRF_SKIPDEFAULT;
\r
863 *pResult = CDRF_DODEFAULT;
\r
867 // CGitLogListBase message handlers
\r
869 void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
871 NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
\r
873 // Create a pointer to the item
\r
874 LV_ITEM* pItem = &(pDispInfo)->item;
\r
876 // Do the list need text information?
\r
877 if (!(pItem->mask & LVIF_TEXT))
\r
880 // By default, clear text buffer.
\r
881 lstrcpyn(pItem->pszText, _T(""), pItem->cchTextMax);
\r
883 bool bOutOfRange = pItem->iItem >= ShownCountWithStopped();
\r
886 if (m_bNoDispUpdates || bOutOfRange)
\r
889 // Which item number?
\r
890 int itemid = pItem->iItem;
\r
891 GitRev * pLogEntry = NULL;
\r
892 if (itemid < m_arShownList.GetCount())
\r
893 pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(pItem->iItem));
\r
898 temp.Format(_T("%d"),pItem->iItem+1);
\r
902 temp.Format(_T("%d"),m_arShownList.GetCount()-pItem->iItem);
\r
906 switch (pItem->iSubItem)
\r
908 case this->LOGLIST_GRAPH: //Graphic
\r
911 if(this->m_IsRebaseReplaceGraph)
\r
914 path.m_Action=pLogEntry->m_Action&CTGitPath::LOGACTIONS_REBASE_MODE_MASK;
\r
916 lstrcpyn(pItem->pszText,path.GetActionName(), pItem->cchTextMax);
\r
920 case this->LOGLIST_ACTION: //action -- no text in the column
\r
921 if(this->m_IsIDReplaceAction)
\r
922 lstrcpyn(pItem->pszText, temp, pItem->cchTextMax);
\r
924 case this->LOGLIST_MESSAGE: //Message
\r
926 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_Subject, pItem->cchTextMax);
\r
928 case this->LOGLIST_AUTHOR: //Author
\r
930 lstrcpyn(pItem->pszText, (LPCTSTR)pLogEntry->m_AuthorName, pItem->cchTextMax);
\r
932 case this->LOGLIST_DATE: //Date
\r
934 lstrcpyn(pItem->pszText,
\r
935 CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat, true, m_bRelativeTimes ),
\r
936 pItem->cchTextMax);
\r
947 void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point)
\r
950 int selIndex = GetSelectionMark();
\r
952 return; // nothing selected, nothing to do with a context menu
\r
954 // if the user selected the info text telling about not all revisions shown due to
\r
955 // the "stop on copy/rename" option, we also don't show the context menu
\r
956 if ((m_bStrictStopped)&&(selIndex == m_arShownList.GetCount()))
\r
959 // if the context menu is invoked through the keyboard, we have to use
\r
960 // a calculated position on where to anchor the menu on
\r
961 if ((point.x == -1) && (point.y == -1))
\r
964 GetItemRect(selIndex, &rect, LVIR_LABEL);
\r
965 ClientToScreen(&rect);
\r
966 point = rect.CenterPoint();
\r
968 m_nSearchIndex = selIndex;
\r
969 m_bCancelled = FALSE;
\r
971 // calculate some information the context menu commands can use
\r
972 // CString pathURL = GetURLFromPath(m_path);
\r
974 POSITION pos = GetFirstSelectedItemPosition();
\r
975 int indexNext = GetNextSelectedItem(pos);
\r
979 GitRev* pSelLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(indexNext));
\r
981 GitRev revSelected = pSelLogEntry->Rev;
\r
982 GitRev revPrevious = git_revnum_t(revSelected)-1;
\r
983 if ((pSelLogEntry->pArChangedPaths)&&(pSelLogEntry->pArChangedPaths->GetCount() <= 2))
\r
985 for (int i=0; i<pSelLogEntry->pArChangedPaths->GetCount(); ++i)
\r
987 LogChangedPath * changedpath = (LogChangedPath *)pSelLogEntry->pArChangedPaths->GetAt(i);
\r
988 if (changedpath->lCopyFromRev)
\r
989 revPrevious = changedpath->lCopyFromRev;
\r
992 GitRev revSelected2;
\r
995 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
996 revSelected2 = pLogEntry->Rev;
\r
998 bool bAllFromTheSameAuthor = true;
\r
999 CString firstAuthor;
\r
1000 CLogDataVector selEntries;
\r
1001 GitRev revLowest, revHighest;
\r
1002 GitRevRangeArray revisionRanges;
\r
1004 POSITION pos = GetFirstSelectedItemPosition();
\r
1005 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1006 revisionRanges.AddRevision(pLogEntry->Rev);
\r
1007 selEntries.push_back(pLogEntry);
\r
1008 firstAuthor = pLogEntry->sAuthor;
\r
1009 revLowest = pLogEntry->Rev;
\r
1010 revHighest = pLogEntry->Rev;
\r
1013 pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1014 revisionRanges.AddRevision(pLogEntry->Rev);
\r
1015 selEntries.push_back(pLogEntry);
\r
1016 if (firstAuthor.Compare(pLogEntry->sAuthor))
\r
1017 bAllFromTheSameAuthor = false;
\r
1018 revLowest = (git_revnum_t(pLogEntry->Rev) > git_revnum_t(revLowest) ? revLowest : pLogEntry->Rev);
\r
1019 revHighest = (git_revnum_t(pLogEntry->Rev) < git_revnum_t(revHighest) ? revHighest : pLogEntry->Rev);
\r
1025 int FirstSelect=-1, LastSelect=-1;
\r
1026 pos = GetFirstSelectedItemPosition();
\r
1027 FirstSelect = GetNextSelectedItem(pos);
\r
1030 LastSelect = GetNextSelectedItem(pos);
\r
1032 //entry is selected, now show the popup menu
\r
1034 if (popup.CreatePopupMenu())
\r
1037 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_PICK))
\r
1038 popup.AppendMenuIcon(ID_REBASE_PICK, IDS_REBASE_SKIP, IDI_PICK);
\r
1040 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_SQUASH))
\r
1041 popup.AppendMenuIcon(ID_REBASE_SQUASH,IDS_REBASE_SQUASH, IDI_SQUASH);
\r
1043 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_EDIT))
\r
1044 popup.AppendMenuIcon(ID_REBASE_EDIT, IDS_REBASE_EDIT, IDI_EDIT);
\r
1046 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_SKIP))
\r
1047 popup.AppendMenuIcon(ID_REBASE_SKIP, IDS_REBASE_SKIP, IDI_SKIP);
\r
1049 if(m_ContextMenuMask&(GetContextMenuBit(ID_REBASE_SKIP)|GetContextMenuBit(ID_REBASE_EDIT)|
\r
1050 GetContextMenuBit(ID_REBASE_SQUASH)|GetContextMenuBit(ID_REBASE_PICK)))
\r
1051 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1053 if (GetSelectedCount() == 1)
\r
1058 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPARE))
\r
1059 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
\r
1061 // TortoiseMerge could be improved to take a /blame switch
\r
1062 // and then not 'cat' the files from a unified diff but
\r
1064 // But until that's implemented, the context menu entry for
\r
1065 // this feature is commented out.
\r
1066 //popup.AppendMenu(ID_BLAMECOMPARE, IDS_LOG_POPUP_BLAMECOMPARE, IDI_BLAME);
\r
1068 if(m_ContextMenuMask&GetContextMenuBit(ID_GNUDIFF1))
\r
1069 popup.AppendMenuIcon(ID_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF_CH, IDI_DIFF);
\r
1071 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPAREWITHPREVIOUS))
\r
1072 popup.AppendMenuIcon(ID_COMPAREWITHPREVIOUS, IDS_LOG_POPUP_COMPAREWITHPREVIOUS, IDI_DIFF);
\r
1073 //popup.AppendMenuIcon(ID_BLAMEWITHPREVIOUS, IDS_LOG_POPUP_BLAMEWITHPREVIOUS, IDI_BLAME);
\r
1074 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1077 // if (!m_ProjectProperties.sWebViewerRev.IsEmpty())
\r
1079 // popup.AppendMenuIcon(ID_VIEWREV, IDS_LOG_POPUP_VIEWREV);
\r
1081 // if (!m_ProjectProperties.sWebViewerPathRev.IsEmpty())
\r
1083 // popup.AppendMenuIcon(ID_VIEWPATHREV, IDS_LOG_POPUP_VIEWPATHREV);
\r
1085 // if ((!m_ProjectProperties.sWebViewerPathRev.IsEmpty())||
\r
1086 // (!m_ProjectProperties.sWebViewerRev.IsEmpty()))
\r
1088 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1092 // popup.AppendMenuIcon(ID_REVERTTOREV, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT);
\r
1094 // popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREV, IDI_REVERT);
\r
1096 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREV, IDI_MERGE);
\r
1098 CString str,format;
\r
1099 format.LoadString(IDS_RESET_TO_THIS_FORMAT);
\r
1100 str.Format(format,g_Git.GetCurrentBranch());
\r
1102 if(m_ContextMenuMask&GetContextMenuBit(ID_RESET))
\r
1103 popup.AppendMenuIcon(ID_RESET,str,IDI_REVERT);
\r
1105 if(m_ContextMenuMask&GetContextMenuBit(ID_SWITCHTOREV))
\r
1106 popup.AppendMenuIcon(ID_SWITCHTOREV, IDS_SWITCH_TO_THIS , IDI_SWITCH);
\r
1108 if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_BRANCH))
\r
1109 popup.AppendMenuIcon(ID_CREATE_BRANCH, IDS_CREATE_BRANCH_AT_THIS , IDI_COPY);
\r
1111 if(m_ContextMenuMask&GetContextMenuBit(ID_CREATE_TAG))
\r
1112 popup.AppendMenuIcon(ID_CREATE_TAG,IDS_CREATE_TAG_AT_THIS , IDI_COPY);
\r
1114 format.LoadString(IDS_REBASE_THIS_FORMAT);
\r
1115 str.Format(format,g_Git.GetCurrentBranch());
\r
1117 if(pSelLogEntry->m_CommitHash != m_HeadHash)
\r
1118 if(m_ContextMenuMask&GetContextMenuBit(ID_REBASE_TO_VERSION))
\r
1119 popup.AppendMenuIcon(ID_REBASE_TO_VERSION, str , IDI_REBASE);
\r
1121 if(m_ContextMenuMask&GetContextMenuBit(ID_EXPORT))
\r
1122 popup.AppendMenuIcon(ID_EXPORT,IDS_EXPORT_TO_THIS, IDI_EXPORT);
\r
1125 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1129 if (GetSelectedCount() >= 2)
\r
1131 bool bAddSeparator = false;
\r
1132 if (IsSelectionContinuous() || (GetSelectedCount() == 2))
\r
1134 if(m_ContextMenuMask&GetContextMenuBit(ID_COMPARETWO))
\r
1135 popup.AppendMenuIcon(ID_COMPARETWO, IDS_LOG_POPUP_COMPARETWO, IDI_DIFF);
\r
1138 if (GetSelectedCount() == 2)
\r
1140 //popup.AppendMenuIcon(ID_BLAMETWO, IDS_LOG_POPUP_BLAMEREVS, IDI_BLAME);
\r
1141 if(m_ContextMenuMask&GetContextMenuBit(ID_GNUDIFF2))
\r
1142 popup.AppendMenuIcon(ID_GNUDIFF2, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);
\r
1143 bAddSeparator = true;
\r
1148 //popup.AppendMenuIcon(ID_REVERTREV, IDS_LOG_POPUP_REVERTREVS, IDI_REVERT);
\r
1150 // popup.AppendMenuIcon(ID_MERGEREV, IDS_LOG_POPUP_MERGEREVS, IDI_MERGE);
\r
1151 bAddSeparator = true;
\r
1153 if (bAddSeparator)
\r
1154 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1157 if ( GetSelectedCount() >0 )
\r
1159 if ( IsSelectionContinuous() && GetSelectedCount() >= 2 )
\r
1161 if(m_ContextMenuMask&GetContextMenuBit(ID_COMBINE_COMMIT))
\r
1165 headindex = this->GetHeadIndex();
\r
1168 head.Format(_T("HEAD~%d"),LastSelect-headindex);
\r
1169 CString hash=g_Git.GetHash(head);
\r
1170 hash=hash.Left(40);
\r
1171 GitRev* pLastEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(LastSelect));
\r
1172 if(pLastEntry->m_CommitHash == hash)
\r
1173 popup.AppendMenuIcon(ID_COMBINE_COMMIT,IDS_COMBINE_TO_ONE,IDI_COMBINE);
\r
1177 if(m_ContextMenuMask&GetContextMenuBit(ID_CHERRY_PICK))
\r
1178 popup.AppendMenuIcon(ID_CHERRY_PICK, IDS_CHERRY_PICK_VERSION, IDI_EXPORT);
\r
1179 popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1185 // if ((selEntries.size() > 0)&&(bAllFromTheSameAuthor))
\r
1187 // popup.AppendMenuIcon(ID_EDITAUTHOR, IDS_LOG_POPUP_EDITAUTHOR);
\r
1189 // if (GetSelectedCount() == 1)
\r
1191 // popup.AppendMenuIcon(ID_EDITLOG, IDS_LOG_POPUP_EDITLOG);
\r
1192 // popup.AppendMenuIcon(ID_REVPROPS, IDS_REPOBROWSE_SHOWREVPROP, IDI_PROPERTIES); // "Show Revision Properties"
\r
1193 // popup.AppendMenu(MF_SEPARATOR, NULL);
\r
1198 if (GetSelectedCount() == 1)
\r
1200 if(m_ContextMenuMask&GetContextMenuBit(ID_COPYHASH))
\r
1201 popup.AppendMenuIcon(ID_COPYHASH, IDS_COPY_COMMIT_HASH);
\r
1203 if (GetSelectedCount() != 0)
\r
1205 if(m_ContextMenuMask&GetContextMenuBit(ID_COPYCLIPBOARD))
\r
1206 popup.AppendMenuIcon(ID_COPYCLIPBOARD, IDS_LOG_POPUP_COPYTOCLIPBOARD);
\r
1209 if(m_ContextMenuMask&GetContextMenuBit(ID_FINDENTRY))
\r
1210 popup.AppendMenuIcon(ID_FINDENTRY, IDS_LOG_POPUP_FIND);
\r
1212 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
1213 // DialogEnableWindow(IDOK, FALSE);
\r
1214 // SetPromptApp(&theApp);
\r
1216 this->ContextMenuAction(cmd, FirstSelect, LastSelect);
\r
1218 // EnableOKButton();
\r
1219 } // if (popup.CreatePopupMenu())
\r
1223 bool CGitLogListBase::IsSelectionContinuous()
\r
1225 if ( GetSelectedCount()==1 )
\r
1227 // if only one revision is selected, the selection is of course
\r
1232 POSITION pos = GetFirstSelectedItemPosition();
\r
1233 bool bContinuous = (m_arShownList.GetCount() == (INT_PTR)m_logEntries.size());
\r
1236 int itemindex = GetNextSelectedItem(pos);
\r
1239 int nextindex = GetNextSelectedItem(pos);
\r
1240 if (nextindex - itemindex > 1)
\r
1242 bContinuous = false;
\r
1245 itemindex = nextindex;
\r
1248 return bContinuous;
\r
1251 void CGitLogListBase::CopySelectionToClipBoard(bool HashOnly)
\r
1254 CString sClipdata;
\r
1255 POSITION pos = GetFirstSelectedItemPosition();
\r
1259 sRev.LoadString(IDS_LOG_REVISION);
\r
1261 sAuthor.LoadString(IDS_LOG_AUTHOR);
\r
1263 sDate.LoadString(IDS_LOG_DATE);
\r
1265 sMessage.LoadString(IDS_LOG_MESSAGE);
\r
1268 CString sLogCopyText;
\r
1270 GitRev * pLogEntry = reinterpret_cast<GitRev *>(m_arShownList.GetAt(GetNextSelectedItem(pos)));
\r
1274 //pLogEntry->m_Files
\r
1275 //LogChangedPathArray * cpatharray = pLogEntry->pArChangedPaths;
\r
1277 for (int cpPathIndex = 0; cpPathIndex<pLogEntry->m_Files.GetCount(); ++cpPathIndex)
\r
1279 sPaths += ((CTGitPath&)pLogEntry->m_Files[cpPathIndex]).GetActionName() + _T(" : ") + pLogEntry->m_Files[cpPathIndex].GetGitPathString();
\r
1280 sPaths += _T("\r\n");
\r
1283 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
1284 (LPCTSTR)sRev, pLogEntry->m_CommitHash,
\r
1285 (LPCTSTR)sAuthor, (LPCTSTR)pLogEntry->m_AuthorName,
\r
1287 (LPCTSTR)CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat, true, m_bRelativeTimes ),
\r
1288 (LPCTSTR)sMessage, pLogEntry->m_Subject+_T("\r\n")+pLogEntry->m_Body,
\r
1290 sClipdata += sLogCopyText;
\r
1293 sClipdata += pLogEntry->m_CommitHash;
\r
1298 CStringUtils::WriteAsciiStringToClipboard(sClipdata, GetSafeHwnd());
\r
1303 void CGitLogListBase::DiffSelectedRevWithPrevious()
\r
1305 if (m_bThreadRunning)
\r
1308 int FirstSelect=-1, LastSelect=-1;
\r
1309 POSITION pos = GetFirstSelectedItemPosition();
\r
1310 FirstSelect = GetNextSelectedItem(pos);
\r
1313 LastSelect = GetNextSelectedItem(pos);
\r
1316 ContextMenuAction(ID_COMPAREWITHPREVIOUS,FirstSelect,LastSelect);
\r
1319 UpdateLogInfoLabel();
\r
1320 int selIndex = m_LogList.GetSelectionMark();
\r
1323 int selCount = m_LogList.GetSelectedCount();
\r
1324 if (selCount != 1)
\r
1327 // Find selected entry in the log list
\r
1328 POSITION pos = m_LogList.GetFirstSelectedItemPosition();
\r
1329 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(m_LogList.GetNextSelectedItem(pos)));
\r
1330 long rev1 = pLogEntry->Rev;
\r
1331 long rev2 = rev1-1;
\r
1332 CTGitPath path = m_path;
\r
1334 // See how many files under the relative root were changed in selected revision
\r
1336 LogChangedPath * changed = NULL;
\r
1337 for (INT_PTR c = 0; c < pLogEntry->pArChangedPaths->GetCount(); ++c)
\r
1339 LogChangedPath * cpath = pLogEntry->pArChangedPaths->GetAt(c);
\r
1340 if (cpath && cpath -> sPath.Left(m_sRelativeRoot.GetLength()).Compare(m_sRelativeRoot)==0)
\r
1347 if (m_path.IsDirectory() && nChanged == 1)
\r
1349 // We're looking at the log for a directory and only one file under dir was changed in the revision
\r
1350 // Do diff on that file instead of whole directory
\r
1351 path.AppendPathString(changed->sPath.Mid(m_sRelativeRoot.GetLength()));
\r
1354 m_bCancelled = FALSE;
\r
1355 DialogEnableWindow(IDOK, FALSE);
\r
1356 SetPromptApp(&theApp);
\r
1357 theApp.DoWaitCursor(1);
\r
1359 if (PromptShown())
\r
1361 GitDiff diff(this, m_hWnd, true);
\r
1362 diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1363 diff.SetHEADPeg(m_LogRevision);
\r
1364 diff.ShowCompare(path, rev2, path, rev1);
\r
1368 CAppUtils::StartShowCompare(m_hWnd, path, rev2, path, rev1, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
\r
1371 theApp.DoWaitCursor(-1);
\r
1376 void CGitLogListBase::OnLvnOdfinditemLoglist(NMHDR *pNMHDR, LRESULT *pResult)
\r
1378 LPNMLVFINDITEM pFindInfo = reinterpret_cast<LPNMLVFINDITEM>(pNMHDR);
\r
1381 if (pFindInfo->lvfi.flags & LVFI_PARAM)
\r
1383 if ((pFindInfo->iStart < 0)||(pFindInfo->iStart >= m_arShownList.GetCount()))
\r
1385 if (pFindInfo->lvfi.psz == 0)
\r
1388 CString sCmp = pFindInfo->lvfi.psz;
\r
1390 for (int i=pFindInfo->iStart; i<m_arShownList.GetCount(); ++i)
\r
1392 GitRev * pLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(i));
\r
1393 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1394 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1396 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1404 if (sCmp.Compare(sRev)==0)
\r
1411 if (pFindInfo->lvfi.flags & LVFI_WRAP)
\r
1413 for (int i=0; i<pFindInfo->iStart; ++i)
\r
1415 PLOGENTRYDATA pLogEntry = reinterpret_cast<PLOGENTRYDATA>(m_arShownList.GetAt(i));
\r
1416 sRev.Format(_T("%ld"), pLogEntry->Rev);
\r
1417 if (pFindInfo->lvfi.flags & LVFI_PARTIAL)
\r
1419 if (sCmp.Compare(sRev.Left(sCmp.GetLength()))==0)
\r
1427 if (sCmp.Compare(sRev)==0)
\r
1439 int CGitLogListBase::FillGitLog(CTGitPath *path,int info,CString *from,CString *to)
\r
1443 this->m_logEntries.ClearAll();
\r
1444 this->m_logEntries.ParserFromLog(path,-1,info,from,to);
\r
1446 //this->m_logEntries.ParserFromLog();
\r
1447 SetItemCountEx(this->m_logEntries.size());
\r
1449 this->m_arShownList.RemoveAll();
\r
1451 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1455 m_logEntries[m_logEntries.size()-i-1].m_IsFull=TRUE;
\r
1456 this->m_arShownList.Add(&m_logEntries[m_logEntries.size()-i-1]);
\r
1460 m_logEntries[i].m_IsFull=TRUE;
\r
1461 this->m_arShownList.Add(&m_logEntries[i]);
\r
1471 int CGitLogListBase::FillGitShortLog()
\r
1475 this->m_logEntries.ClearAll();
\r
1477 m_LogCache.FetchCacheIndex(g_Git.m_CurrentDir);
\r
1480 if(this->m_Path.IsEmpty())
\r
1483 path=&this->m_Path;
\r
1487 mask = CGit::LOG_INFO_ONLY_HASH | CGit::LOG_INFO_BOUNDARY;
\r
1488 // if(this->m_bAllBranch)
\r
1489 mask |= m_ShowMask;
\r
1491 this->m_logEntries.ParserShortLog(path,hash,-1,mask);
\r
1494 //this->m_logEntries.ParserFromLog();
\r
1495 if(IsInWorkingThread())
\r
1496 PostMessage(LVM_SETITEMCOUNT, (WPARAM) this->m_logEntries.size(),(LPARAM) LVSICF_NOINVALIDATEALL);
\r
1498 SetItemCountEx(this->m_logEntries.size());
\r
1500 this->m_arShownList.RemoveAll();
\r
1502 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1504 if(this->m_IsOldFirst)
\r
1506 this->m_arShownList.Add(&m_logEntries[m_logEntries.size()-1-i]);
\r
1510 this->m_arShownList.Add(&m_logEntries[i]);
\r
1516 BOOL CGitLogListBase::PreTranslateMessage(MSG* pMsg)
\r
1518 // Skip Ctrl-C when copying text out of the log message or search filter
\r
1519 BOOL bSkipAccelerator = ( pMsg->message == WM_KEYDOWN && pMsg->wParam=='C' && (GetFocus()==GetDlgItem(IDC_MSGVIEW) || GetFocus()==GetDlgItem(IDC_SEARCHEDIT) ) && GetKeyState(VK_CONTROL)&0x8000 );
\r
1520 if (pMsg->message == WM_KEYDOWN && pMsg->wParam=='\r')
\r
1522 //if (GetFocus()==GetDlgItem(IDC_LOGLIST))
\r
1524 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1526 DiffSelectedRevWithPrevious();
\r
1531 if (GetFocus()==GetDlgItem(IDC_LOGMSG))
\r
1533 DiffSelectedFile();
\r
1540 if (m_hAccel && !bSkipAccelerator)
\r
1542 int ret = TranslateAccelerator(m_hWnd, m_hAccel, pMsg);
\r
1548 //m_tooltips.RelayEvent(pMsg);
\r
1549 return __super::PreTranslateMessage(pMsg);
\r
1552 void CGitLogListBase::OnNMDblclkLoglist(NMHDR * /*pNMHDR*/, LRESULT *pResult)
\r
1554 // a double click on an entry in the revision list has happened
\r
1557 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE))
\r
1558 DiffSelectedRevWithPrevious();
\r
1561 int CGitLogListBase::FetchLogAsync(void * data)
\r
1564 m_bExitThread=FALSE;
\r
1565 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1566 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1567 m_LoadingThread = AfxBeginThread(LogThreadEntry, this);
\r
1568 if (m_LoadingThread ==NULL)
\r
1570 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1571 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1572 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
1578 //this is the thread function which calls the subversion function
\r
1579 UINT CGitLogListBase::LogThreadEntry(LPVOID pVoid)
\r
1581 return ((CGitLogListBase*)pVoid)->LogThread();
\r
1584 void CGitLogListBase::GetTimeRange(CTime &oldest, CTime &latest)
\r
1587 oldest=CTime::GetCurrentTime();
\r
1588 latest=CTime(1971,1,2,0,0,0);
\r
1589 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1591 if(m_logEntries[i].m_AuthorDate.GetTime() < oldest.GetTime())
\r
1592 oldest = m_logEntries[i].m_AuthorDate.GetTime();
\r
1594 if(m_logEntries[i].m_AuthorDate.GetTime() > latest.GetTime())
\r
1595 latest = m_logEntries[i].m_AuthorDate.GetTime();
\r
1600 //Helper class for FetchFullLogInfo()
\r
1601 class CGitCall_FetchFullLogInfo : public CGitCall
\r
1604 CGitCall_FetchFullLogInfo(CGitLogListBase* ploglist):m_ploglist(ploglist),m_CollectedCount(0){}
\r
1605 virtual bool OnOutputData(const BYTE* data, size_t size)
\r
1608 return m_ploglist->m_bExitThread;
\r
1609 //Add received data to byte collector
\r
1610 m_ByteCollector.append(data,size);
\r
1612 //Find loginfo endmarker
\r
1613 static const BYTE dataToFind[]={0,0};
\r
1614 int found=m_ByteCollector.findData(dataToFind,2);
\r
1616 return m_ploglist->m_bExitThread;//Not found
\r
1617 found+=2;//Position after loginfo end-marker
\r
1619 //Prepare data for OnLogInfo and call it
\r
1620 BYTE_VECTOR logInfo;
\r
1621 logInfo.append(&*m_ByteCollector.begin(),found);
\r
1622 OnLogInfo(logInfo);
\r
1624 //Remove loginfo from bytecollector
\r
1625 m_ByteCollector.erase(m_ByteCollector.begin(),m_ByteCollector.begin()+found);
\r
1627 return m_ploglist->m_bExitThread;
\r
1629 virtual void OnEnd()
\r
1631 //Rest should be a complete log line.
\r
1632 if(!m_ByteCollector.empty())
\r
1633 OnLogInfo(m_ByteCollector);
\r
1637 void OnLogInfo(BYTE_VECTOR& logInfo)
\r
1640 fullRev.ParserFromLog(logInfo);
\r
1641 MAP_HASH_REV::iterator itRev=m_ploglist->m_logEntries.m_HashMap.find(fullRev.m_CommitHash);
\r
1642 if(itRev==m_ploglist->m_logEntries.m_HashMap.end())
\r
1644 //Should not occur, only when Git-tree updated in the mean time. (Race condition)
\r
1648 int rev=itRev->second;
\r
1649 GitRev* revInVector=&m_ploglist->m_logEntries[rev];
\r
1652 // fullRev.m_IsUpdateing=TRUE;
\r
1653 // fullRev.m_IsFull=TRUE;
\r
1656 if(InterlockedExchange(&revInVector->m_IsUpdateing,TRUE))
\r
1657 return;//Cannot update this row now. Ignore.
\r
1658 TCHAR oldmark=revInVector->m_Mark;
\r
1659 GIT_REV_LIST oldlist=revInVector->m_ParentHash;
\r
1660 // CString oldhash=m_CommitHash;
\r
1662 //Parse new rev info
\r
1663 revInVector->ParserFromLog(logInfo);
\r
1666 revInVector->m_Mark=oldmark; //parser full log will cause old mark overwrited.
\r
1667 //So we need keep old bound mark.
\r
1668 revInVector->m_ParentHash=oldlist;
\r
1671 InterlockedExchange(&revInVector->m_IsFull,TRUE);
\r
1672 InterlockedExchange(&revInVector->m_IsUpdateing,FALSE);
\r
1674 //Notify listcontrol and update progress bar
\r
1675 ++m_CollectedCount;
\r
1677 ::PostMessage(m_ploglist->m_hWnd,MSG_LOADED,(WPARAM)rev,0);
\r
1679 DWORD percent=m_CollectedCount*98/m_ploglist->m_logEntries.size() + GITLOG_START+1;
\r
1680 if(percent == GITLOG_END)
\r
1681 percent = GITLOG_END -1;
\r
1683 ::PostMessage(m_ploglist->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) percent,0);
\r
1686 CGitLogListBase* m_ploglist;
\r
1687 BYTE_VECTOR m_ByteCollector;
\r
1688 int m_CollectedCount;
\r
1692 void CGitLogListBase::FetchFullLogInfo()
\r
1694 CGitCall_FetchFullLogInfo fetcher(this);
\r
1696 CGit::LOG_INFO_STAT|
\r
1697 CGit::LOG_INFO_FILESTATE|
\r
1698 CGit::LOG_INFO_DETECT_COPYRENAME|
\r
1700 g_Git.GetLog(&fetcher,CString(),NULL,-1,mask);
\r
1703 void CGitLogListBase::FetchFullLogInfoOrig()
\r
1705 unsigned int updated=0;
\r
1710 for(unsigned int i=0;i<m_logEntries.size();i++)
\r
1712 if(m_LogCache.GetCacheData(m_logEntries[i]))
\r
1714 if(!m_logEntries.FetchFullInfo(i))
\r
1718 m_LogCache.AddCacheEntry(m_logEntries[i]);
\r
1723 InterlockedExchange(&m_logEntries[i].m_IsUpdateing,FALSE);
\r
1724 InterlockedExchange(&m_logEntries[i].m_IsFull,TRUE);
\r
1727 ::PostMessage(m_hWnd,MSG_LOADED,(WPARAM)i,0);
\r
1731 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1732 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1736 percent=updated*98/m_logEntries.size() + GITLOG_START+1;
\r
1737 if(percent == GITLOG_END)
\r
1738 percent = GITLOG_END -1;
\r
1740 ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) percent,0);
\r
1744 if(updated==m_logEntries.size())
\r
1749 UINT CGitLogListBase::LogThread()
\r
1752 // if(m_ProcCallBack)
\r
1753 // m_ProcCallBack(m_ProcData,GITLOG_START);
\r
1754 ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_START,0);
\r
1756 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1757 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1759 //does the user force the cache to refresh (shift or control key down)?
\r
1760 bool refresh = (GetKeyState (VK_CONTROL) < 0)
\r
1761 || (GetKeyState (VK_SHIFT) < 0);
\r
1763 //disable the "Get All" button while we're receiving
\r
1766 FillGitShortLog();
\r
1768 if(this->m_bExitThread)
\r
1770 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1771 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1775 RedrawItems(0, m_arShownList.GetCount());
\r
1776 // SetRedraw(false);
\r
1777 // ResizeAllListCtrlCols();
\r
1778 // SetRedraw(true);
\r
1780 if ( m_pStoreSelection )
\r
1782 // Deleting the instance will restore the
\r
1783 // selection of the CLogDlg.
\r
1784 delete m_pStoreSelection;
\r
1785 m_pStoreSelection = NULL;
\r
1789 // If no selection has been set then this must be the first time
\r
1790 // the revisions are shown. Let's preselect the topmost revision.
\r
1791 if ( GetItemCount()>0 )
\r
1793 SetSelectionMark(0);
\r
1794 SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
\r
1798 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1801 //FetchFullLogInfo();
\r
1802 FetchFullLogInfoOrig();
\r
1803 //RefreshCursor();
\r
1804 // make sure the filter is applied (if any) now, after we refreshed/fetched
\r
1805 // the log messages
\r
1807 ::PostMessage(this->GetParent()->m_hWnd,MSG_LOAD_PERCENTAGE,(WPARAM) GITLOG_END,0);
\r
1809 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1814 void CGitLogListBase::Refresh()
\r
1816 m_bExitThread=TRUE;
\r
1817 if(m_LoadingThread!=NULL)
\r
1819 DWORD ret =::WaitForSingleObject(m_LoadingThread->m_hThread,20000);
\r
1820 if(ret == WAIT_TIMEOUT)
\r
1821 TerminateThread();
\r
1826 //Update branch and Tag info
\r
1828 //Assume Thread have exited
\r
1829 //if(!m_bThreadRunning)
\r
1831 this->SetItemCountEx(0);
\r
1832 m_logEntries.clear();
\r
1833 m_bExitThread=FALSE;
\r
1834 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
1835 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
1836 if (AfxBeginThread(LogThreadEntry, this)==NULL)
\r
1838 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
1839 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
1840 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
1842 m_sFilterText.Empty();
\r
1843 m_From=CTime(1970,1,2,0,0,0);
\r
1844 m_To=CTime::GetCurrentTime();
\r
1847 bool CGitLogListBase::ValidateRegexp(LPCTSTR regexp_str, tr1::wregex& pat, bool bMatchCase /* = false */)
\r
1851 tr1::regex_constants::syntax_option_type type = tr1::regex_constants::ECMAScript;
\r
1853 type |= tr1::regex_constants::icase;
\r
1854 pat = tr1::wregex(regexp_str, type);
\r
1857 catch (exception) {}
\r
1861 void CGitLogListBase::RecalculateShownList(CPtrArray * pShownlist)
\r
1864 pShownlist->RemoveAll();
\r
1865 tr1::wregex pat;//(_T("Remove"), tr1::regex_constants::icase);
\r
1866 bool bRegex = false;
\r
1867 if (m_bFilterWithRegex)
\r
1868 bRegex = ValidateRegexp(m_sFilterText, pat, false);
\r
1870 tr1::regex_constants::match_flag_type flags = tr1::regex_constants::match_any;
\r
1872 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
1874 if ((bRegex)&&(m_bFilterWithRegex))
\r
1877 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
1879 ATLTRACE(_T("bugID = \"%s\"\n"), (LPCTSTR)m_logEntries[i]->sBugIDs);
\r
1880 if (regex_search(wstring((LPCTSTR)m_logEntries[i]->sBugIDs), pat, flags)&&IsEntryInDateRange(i))
\r
1882 pShownlist->Add(m_logEntries[i]);
\r
1887 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
1889 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries[i].m_Subject);
\r
1890 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_Subject), pat, flags)&&IsEntryInDateRange(i))
\r
1892 pShownlist->Add(&m_logEntries[i]);
\r
1896 ATLTRACE(_T("messge = \"%s\"\n"),m_logEntries[i].m_Body);
\r
1897 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_Body), pat, flags)&&IsEntryInDateRange(i))
\r
1899 pShownlist->Add(&m_logEntries[i]);
\r
1904 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
1906 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
1908 bool bGoing = true;
\r
1909 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
1911 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1912 if (regex_search(wstring((LPCTSTR)cpath->sCopyFromPath), pat, flags)&&IsEntryInDateRange(i))
\r
1914 pShownlist->Add(m_logEntries[i]);
\r
1918 if (regex_search(wstring((LPCTSTR)cpath->sPath), pat, flags)&&IsEntryInDateRange(i))
\r
1920 pShownlist->Add(m_logEntries[i]);
\r
1924 if (regex_search(wstring((LPCTSTR)cpath->GetAction()), pat, flags)&&IsEntryInDateRange(i))
\r
1926 pShownlist->Add(m_logEntries[i]);
\r
1935 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
1937 if (regex_search(wstring((LPCTSTR)m_logEntries[i].m_AuthorName), pat, flags)&&IsEntryInDateRange(i))
\r
1939 pShownlist->Add(&m_logEntries[i]);
\r
1943 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
1945 sRev.Format(_T("%s"), m_logEntries[i].m_CommitHash);
\r
1946 if (regex_search(wstring((LPCTSTR)sRev), pat, flags)&&IsEntryInDateRange(i))
\r
1948 pShownlist->Add(&m_logEntries[i]);
\r
1955 CString find = m_sFilterText;
\r
1958 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_BUGID))
\r
1960 CString sBugIDs = m_logEntries[i]->sBugIDs;
\r
1962 sBugIDs = sBugIDs.MakeLower();
\r
1963 if ((sBugIDs.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
1965 pShownlist->Add(m_logEntries[i]);
\r
1970 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_MESSAGES))
\r
1972 CString msg = m_logEntries[i].m_Subject;
\r
1974 msg = msg.MakeLower();
\r
1975 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
1977 pShownlist->Add(&m_logEntries[i]);
\r
1980 msg = m_logEntries[i].m_Body;
\r
1982 msg = msg.MakeLower();
\r
1983 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
1985 pShownlist->Add(&m_logEntries[i]);
\r
1990 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_PATHS))
\r
1992 LogChangedPathArray * cpatharray = m_logEntries[i]->pArChangedPaths;
\r
1994 bool bGoing = true;
\r
1995 for (INT_PTR cpPathIndex = 0; cpPathIndex<cpatharray->GetCount() && bGoing; ++cpPathIndex)
\r
1997 LogChangedPath * cpath = cpatharray->GetAt(cpPathIndex);
\r
1998 CString path = cpath->sCopyFromPath;
\r
2000 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
2002 pShownlist->Add(m_logEntries[i]);
\r
2006 path = cpath->sPath;
\r
2008 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
2010 pShownlist->Add(m_logEntries[i]);
\r
2014 path = cpath->GetAction();
\r
2016 if ((path.Find(find)>=0)&&(IsEntryInDateRange(i)))
\r
2018 pShownlist->Add(m_logEntries[i]);
\r
2025 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_AUTHORS))
\r
2027 CString msg = m_logEntries[i].m_AuthorName;
\r
2028 msg = msg.MakeLower();
\r
2029 if ((msg.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2031 pShownlist->Add(&m_logEntries[i]);
\r
2035 if ((m_nSelectedFilter == LOGFILTER_ALL)||(m_nSelectedFilter == LOGFILTER_REVS))
\r
2037 sRev.Format(_T("%s"), m_logEntries[i].m_CommitHash);
\r
2038 if ((sRev.Find(find) >= 0)&&(IsEntryInDateRange(i)))
\r
2040 pShownlist->Add(&m_logEntries[i]);
\r
2044 } // else (from if (bRegex))
\r
2045 } // for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
2049 BOOL CGitLogListBase::IsEntryInDateRange(int i)
\r
2051 __time64_t time = m_logEntries[i].m_AuthorDate.GetTime();
\r
2052 if ((time >= m_From.GetTime())&&(time <= m_To.GetTime()))
\r
2059 void CGitLogListBase::StartFilter()
\r
2061 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
2062 RecalculateShownList(&m_arShownList);
\r
2063 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2067 SetItemCountEx(ShownCountWithStopped());
\r
2068 RedrawItems(0, ShownCountWithStopped());
\r
2070 //ResizeAllListCtrlCols();
\r
2075 void CGitLogListBase::RemoveFilter()
\r
2078 InterlockedExchange(&m_bNoDispUpdates, TRUE);
\r
2080 m_arShownList.RemoveAll();
\r
2082 // reset the time filter too
\r
2084 m_timFrom = (__time64_t(m_tFrom));
\r
2085 m_timTo = (__time64_t(m_tTo));
\r
2086 m_DateFrom.SetTime(&m_timFrom);
\r
2087 m_DateTo.SetTime(&m_timTo);
\r
2088 m_DateFrom.SetRange(&m_timFrom, &m_timTo);
\r
2089 m_DateTo.SetRange(&m_timFrom, &m_timTo);
\r
2092 for (DWORD i=0; i<m_logEntries.size(); ++i)
\r
2094 if(this->m_IsOldFirst)
\r
2096 m_arShownList.Add(&m_logEntries[m_logEntries.size()-i-1]);
\r
2099 m_arShownList.Add(&m_logEntries[i]);
\r
2102 // InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2104 SetItemCountEx(ShownCountWithStopped());
\r
2105 RedrawItems(0, ShownCountWithStopped());
\r
2106 // SetRedraw(false);
\r
2107 // ResizeAllListCtrlCols();
\r
2108 // SetRedraw(true);
\r
2110 InterlockedExchange(&m_bNoDispUpdates, FALSE);
\r
2113 void CGitLogListBase::Clear()
\r
2115 m_arShownList.RemoveAll();
\r
2116 m_logEntries.clear();
\r
2117 m_logEntries.m_HashMap.clear();
\r
2119 m_logEntries.m_Lns.clear();
\r
2121 m_logEntries.m_FirstFreeLane=0;
\r
2122 m_logEntries.m_Lns.clear();
\r
2126 void CGitLogListBase::OnDestroy()
\r
2128 // save the column widths to the registry
\r
2129 SaveColumnWidths();
\r
2131 if(this->m_bThreadRunning)
\r
2133 this->m_bExitThread=true;
\r
2134 DWORD ret =::WaitForSingleObject(m_LoadingThread->m_hThread,20000);
\r
2135 if(ret == WAIT_TIMEOUT)
\r
2136 TerminateThread();
\r
2138 while(m_LogCache.SaveCache())
\r
2140 if(CMessageBox::Show(NULL,_T("Cannot Save Log Cache to Disk. To retry click yes. To give up click no."),_T("TortoiseGit"),
\r
2141 MB_YESNO) == IDNO)
\r
2144 CHintListCtrl::OnDestroy();
\r
2147 LRESULT CGitLogListBase::OnLoad(WPARAM wParam,LPARAM lParam)
\r
2150 int i=(int)wParam;
\r
2151 this->GetItemRect(i,&rect,LVIR_BOUNDS);
\r
2152 this->InvalidateRect(rect);
\r
2157 * Save column widths to the registry
\r
2159 void CGitLogListBase::SaveColumnWidths()
\r
2161 CHeaderCtrl* pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0));
\r
2164 int numcols = pHdrCtrl->GetItemCount();
\r
2165 for (int col = 0; col < numcols; col++)
\r
2167 int width = GetColumnWidth( col );
\r
2169 regentry.Format( _T("Software\\TortoiseGit\\log\\ColWidth%d"), col);
\r
2170 CRegDWORD regwidth(regentry, 0);
\r
2171 regwidth = width; // this writes it to reg
\r
2176 int CGitLogListBase::GetHeadIndex()
\r
2178 if(m_HeadHash.IsEmpty())
\r
2181 for(int i=0;i<m_arShownList.GetCount();i++)
\r
2183 GitRev *pRev = (GitRev*)m_arShownList[i];
\r
2186 if(pRev->m_CommitHash == m_HeadHash )
\r